ArchLinux Install Guide
This guide is intended to help someone install the Arch Linux ARM distribution on their Raspberry Pi. The guide presupposes you have some familiarity with the linux system and are comfortable working from the command line, but it does not require you to be an expert. We learn a great deal by doing, and if you'd like to learn more about how linux operates, Arch Linux is an excellent choice for many reasons.
Arch Linux, pacman, documentation, and scripts are Copyright © 2002-2007 by Judd Vinet, Copyright © 2007-2011 by Aaron Griffin and are licensed under the GNU General Public License Version 2.
Arch Linux ARM is Copyright © 2011-2012 and is licensed under the GNU GPLv2, with full source being free and open software. Each package is licensed under its respective license. The PlugApps distribution is copyright Mike Staszel. You may modify, adapt, and copy it to fit your needs. If you do so, it must be licensed under a similar license to the GPLv2.
One of the greatest advantages of the Arch Linux distribution is its simplicity in approach and attitude. The Arch Linux Beginner's Guide describes this attitude very well:
- The design principles behind Arch are aimed at keeping it simple.
- 'Simple', in this context, shall mean 'without unnecessary additions, modifications, or complications'. In short; an elegant, minimalist approach.
- Some thoughts to keep in mind as you consider simplicity:
- " 'Simple' is defined from a technical standpoint, not a usability standpoint. It is better to be technically elegant with a higher learning curve, than to be easy to use and technically [inferior]." -Aaron Griffin
- Entia non sunt multiplicanda praeter necessitatem or "Entities should not be multiplied unnecessarily." -Occam's razor. The term razor refers to the act of shaving away unnecessary complications to arrive at the simplest explanation, method or theory.
- "The extraordinary part of [my method] lies in its simplicity..The height of cultivation always runs to simplicity." - Bruce Lee
Arch gives you the ability to build your system from the ground up, including only the software you actually need. This minimizes the amount of SD card memory it takes to hold the operating system for your Raspberry Pi, leaving more space for everything else you'll be doing.
On a cautionary note, Arch moves forward as technology evolves, and this can sometimes lead to documentation lagging behind. Arch has now finished it's transition to SystemD from the old initscripts. Any guides or information that reference these scripts, or a file called /etc/rc.conf is now depreciated and will probably break your system.
Obtain the latest image
- You can download the latest Arch Linux ARM image for the Raspberry Pi here. The current version is 29-04-2012, and this guide pertains to this release. Download the image to any computer that has a way for you to connect your SD card.
Check the image integrity
- Unzip the downloaded image to obtain a directory with the image itself and the SHA-1 checksum. You can verify the integrity of the image with:
- * linux: $ sha1sum --check name_of_checksum_file.txt
- replacing name_of_checksum_file.txt with the name of the .txt file in the downloaded directory.
- * Windows:
- * Mac OS-X:
Write image to the SD card
- Plug your SD card into your computer, and write the Arch Linux ARM image by following the Easy SD Card Setup instructions.
Optional: Resize partitions
- If your SD card is larger than 2 GB, you will want to resize the partitions to make use of your entire card. The Easy SD Card Setup page also has instructions for resizing using parted, though you may also use graphical tools like gparted if you wish.
- The image creates two partitions, which will be available as /dev/mmcblk0p1 and /dev/mmcblk0p2 when you boot up your Raspberry Pi. The first partition (100 MB) is mounted to /boot, and the second (1.7 GB by default) is mounted to the root directory /. Leave the first partition as it is, and expand the second to as large as you desire within the space available on your card. You may also consider creating a third or even fourth partition for /home and/or swap if desired. Neither is necessary, and the two partitions alone are all that are necessary.
When you boot up your Pi, it will bring you to a login prompt. Log in as root (password root). Now we'll change a few settings to personalize your Pi.
Dealing with a Black Screen
- If you boot up your Pi but nothing is displayed on your monitor, it's probably not a hardware problem. Have your Pi plugged in to your network, then from another computer you should be able to connect to it remotely with ssh. (Linux and Mac OS-X have ssh already; Windows users can use any client, such as PuTTY or Bitvise Tunnelier.)
- From another computer connected on the same network, open ssh to alarmpi, the default hostname of the Arch Linux ARM installation. Log in as root (password root), and in a shell run
- # mv /boot/config.txt /boot/config.old
- # reboot
- The ssh session will end, your Pi will reboot, and the display on the monitor or TV connected to it should come up just fine. You no longer need to work through ssh, though if you don't have a keyboard connected to your Pi you can.
Change Root Password
- The first task is to change the root password by running the command passwd. True, you don't really have to do this-- but if you're going to connect to the internet you really ought to. Change it to something at least fairly secure, but rememberable.
- # passwd
Modify System Files
- Arch uses a handful of files to control the startup scripts. These files are located in /etc. Open the files described below in either nano or vi, whichever is more comfortable to you. (If you've never used vi, it is highly recommended to stick with nano; the remainder of this tutorial will assume you use it.) You will need to change two things: you will specify your local timezone and give your Pi a name.
- To change your local timezone, you need to edit the file /etc/timezone.
- The default timezone is "Europe/London". If you live somewhere else, you can find the possible settings in the /usr/share/timezone/ directory. Find the subdirectory that describes where you live best, then find the file that corresponds to the location closest to you within your timezone.
- # ls /usr/share/zoneinfo
- # ls /usr/share/zoneinfo/America
- With the above commands, I locate my timezone as "America/New_York".
- First you will need to remove your old timezone link and make a new one.
- # rm /etc/localtime
- You can now create a symlink to the appropriate timezone information.
- # ln -s /usr/share/zoneinfo/America/New_York /etc/localtime
- You should also change /etc/timezone. Change "Europe/London" to the value you just found.
- Open /etc/timezone in an editor and input "America/New_York".
- # nano /etc/timezone
- To change the name for your Pi, you need to edit the file /etc/hostname and /etc/hosts
- Open /etc/hostname in an editor.
- # nano /etc/hostname
- Change "alarmpi" to the name chosen for your Pi.
- If using nano, use CTRL-x to exit, hit Y to save the file.
- Now we need to edit the /etc/hosts file to reflect the hostname.
- # nano /etc/hosts
- Modify the line of the file to read
- 127.0.0.1 localhost.localdomain localhost yourhostname
- replacing yourhostname with the name you put in /etc/hostname.
Mount Extra Partitions
- If you put a separate /home partition on your SD card, you need to specify where to mount it. Edit the /etc/fstab file:
- # nano /etc/fstab
- Add at the bottom of the file the line:
- /dev/mmcblk0p3 /home ext4 defaults 0 0
- using whatever partition you've established for that directory. If you've used a filesystem other than ext4, change it accordingly.
- If you want to add a swap partition you will need either free space on your SD-Card, or an external drive like an old USB thumb drive. The following instructions will assume that you have an old small thumbdrive lying around and will be using that. Start off by inserting the thumbdrive into a USB port, you should be able to use a port on a hub without problems. You can find the device name of the drive with:
- # fdisk -l
- You will need to partition the drive, use the following command changing your drive letter for sdX:
- # cfdisk /dev/sdX
- You will have to not only create a partition but also change it's type. You will use number 82 in the type menu to make a swap partition. Write the changes to disk and then exit. Now you should create swap on the disk.
- # mkswap /dev/sdX#
- Where # is the partiton number. Now you can activate the swap immediately with:
- # swapon /dev/sdX#
- To have the swap automatically mount at boot you will need to edit your /etc/fstab.
- # nano /etc/fstab
- add the following line:
- /dev/sdX# none swap defaults 0 0
- After a reboot you can confirm that the swap is mounted correctly with the following command.
- # free
- Bring your system installation up to date using pacman. You will first have to creat a pacman key for this to work:
- # pacman-key --init
- Now, in order to create random entropy on your system you need to switch to a second console with <ALT><F2> and:
- #ls -R / && ls -R / && ls -R /
- You may have to run this multiple times, it will take a while. Preiodically switch back to the first console <ALT> <F1> to check the status of the key generation. After a key is generated you can update with:
- # pacman -Syu
- It will update your repositories, and prompt you for permission to update any out of date programs. When that is done, reboot your Pi and log in again as root using your new root password. The initial installation is now done!
Many of the steps here can be considered optional, depending on how you intend to use your Raspberry Pi. The steps described here assume typical usage, and if you're not already familiar with the system are recommended.
- It's not wise to use your system always as the root user, so you'll want to create a regular user account with permision to perform root functions under sudo. To install sudo:
- # pacman -S sudo
- To give your regular user permission to use sudo, you need to edit the configuration file using visudo:
- # EDITOR=nano visudo
- Locate the section marked as:
- ## User privilege specification
- and uncomment the line below to say
- %wheel ALL=(ALL) ALL
- Save and exit.
Create Regular User Account
- Install the adduser package:
- # pacman -S adduser
- Create a new user to use regularly:
- # adduser
- Follow the prompts; use whatever username you'd like to log in. The next available UID is fine. Use the default users as the initial group. For additional groups, add the following:
- tbd: which of these are actually necessary?
- The default home directory and shell are both fine. Unless you want one, don't bother putting an expiration date in. The script will then ask you to confirm the entry as you've entered it. If all is satisfactory, continue to make the account, give the user a password, and add any other information it asks for as desired.
- Save and exit
- Logout, and relogin as the regular user:
- # logout
- login: newuser
- password: yourpassword
- (Note the change in prompt from # to $. This will help you know if you're logged in as root or not.) From now on, you should use your regular user for everything. When root needs to do something on your system, use sudo. (The first time you use it, the display will show some general good-behavior rules for its use.)
Keeping Boot Messages on the Display with systemd
- Look at the Arch guide, here: https://wiki.archlinux.org/index.php/Disable_Clearing_of_Boot_Messages
- (NB in the above instructions, the filename firstname.lastname@example.org contains a numeral one and not a lower-case L!)
Install Any Desired Software
- Pacman is used to install any new software. You can search for program names using:
- $ pacman -Ss keyword
- Install software with:
- $ pacman -S program-name
Suggested software to install
- xorg: for graphical display
- $ sudo pacman -S xorg xorg-xinit xorg-server xorg-server-utils
- lxde: LXDE Desktop Environment
- $ sudo pacman -S lxde
- or xfce: XFCE Desktop Environment
- $ sudo pacman -S xfce4
- Vim: powerful text editor
- $ sudo pacman -S vim or $ sudo pacman -S gvim
- Emacs: likewise, for those so-inclined
- $ sudo pacman -S emacs
- Python 3: Python v3 programming language
- $ sudo pacman -S python
- Python 2: Python v2 programming language
- $ sudo pacman -S python2
- GCC: GNU C/C++ compiler
- $ sudo pacman -S gcc