ArchLinux Install Guide
CHANGED INSTALLATION METHOD
NOTE: THE INSTRUCTIONS IN THE REST OF THIS PAGE ARE NO LONGER VALID BECAUSE THE ARCH LINUX ARM OWNER HAS DECIDED TO STOP ISSUING SD-CARD IMAGES. ONLY ".TAR.GZ" FILES OF THE FILESYSTEM WILL BE AVAILABLE FROM NOW ON. THESE CAN NORMALLY ONLY BE INSTALLED FROM A LINUX MACHINE, FOLLOWING A MORE COMPLEX INSTALLATION PROCEDURE. PLEASE REFER TO THE ARCHLINUXARM.ORG SITE FOR DETAILS.
A minimal guide for experienced Linux users to set up the SD-card is as follows:
Start fdisk to partition the SD card: fdisk /dev/sdX At the fdisk prompt, delete old partitions and create a new one: Type o. This will clear out any partitions on the drive. Type p to list partitions. There should be no partitions left. Type n, then p for primary, 1 for the first partition on the drive, press ENTER to accept the default first sector, then type +100M for the last sector. Type t, then c to set the first partition to type W95 FAT32 (LBA). Type n, then p for primary, 2 for the second partition on the drive, and then press ENTER twice to accept the default first and last sector. Write the partition table and exit by typing w. Create and mount the FAT filesystem: mkfs.vfat /dev/sdX1 mkdir boot mount /dev/sdX1 boot Create and mount the ext4 filesystem: mkfs.ext4 /dev/sdX2 mkdir root mount /dev/sdX2 root Download and extract the root filesystem (as root, not via sudo): wget http://archlinuxarm.org/os/ArchLinuxARM-rpi-latest.tar.gz bsdtar -xpf ArchLinuxARM-rpi-latest.tar.gz -C root sync Move boot files to the first partition: mv root/boot/* boot Unmount the two partitions: umount boot root Insert the SD card into the Raspberry Pi, connect ethernet, and apply 5V power. Use the serial console or SSH to the IP address given to the board by your router. The default root password is 'root'.
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.
- 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
- 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 create 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. Periodically 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
- Create a new user to use regularly:
On a typical desktop system, use the following command to add a new user, specify Bash as their login shell and add them to the wheel group:
# useradd -m -G wheel -s /bin/bash newuser
This command will also automatically create a group called after your username with the same GID as the UID of the user and makes this the default group for your account on login. Making each user have their own group (with group name same as user name and GID same as UID) is the preferred way to add users.
Now set a password:
# passwd newuser
- 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 email@example.com 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 xterm
- 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
Example of a bash script that makes the sdcard for Arch on the Raspberry Pi (and version 2):