Jump to content

Welcome, Guest!

nemrod

Full guide to Arch Linux on the Raspberry Pi

Recommended Posts

Full guide to Arch Linux on the Raspberry Pi


This guide assumes basic knowledge of how to extract zip files and downloading files.

The first step is of course to download the Arch distribution for the Pi from the Raspberry Pi downloads page. Once you have done so extract the zip file and you'll end up with a .img file (and a SHA1 hash file to verify, but let's ignore that), which is what we need to put on the SD card for the Pi to boot from.

The next step differs between your host OS, i.e. if you're using Windows or Linux to create the SD card. Either way, start by inserting the SD card (it will be wiped, remember to use one with nothing important on it). If you're using Windows download Win32 Disk Imager, extract and run Win32DiskImager.exe. Select the device (make sure you choose the correct one or you'll end up corrupting something you shouldn't have) and pick the .img file we extracted in the first step. Click Write and you're done! If you're using Linux you'll instead want to insert the card and run "dd if=path/to/img/file of=/dev/device bs=1M" as root. To find out what device the card is you can run dmesg, 5-10 lines should appear at the end starting with something like "sd 0:0:0:0: [sda]", where sda is the device. An example line could look like this: "dd if=~/archlinuxarm-29-04-2012.img of=/dev/sda bs=1M". It won't print any progress so just wait patiently until it's done and returns you to the command line.

Now that you've got Arch on an SD card the next step is booting it up. Insert it into the Pi, connect your peripherals and you're good to go. Note that unlike Debian Arch has SSH activated by default and so you don't need to connect a monitor and keyboard as long as it's got network connectivity.

Now you probably want to resize the partition to match the SD card since there is likely to be a lot of unused/unusable space by default. Log in with username root and password root (either via SSH or with a keyboard and screen connected to the Raspberry Pi, either will work). Run "fdisk /dev/mmcblk0". Type the command 'p' and press enter. You should see two lines looking similar to this:
 
/dev/mmcblk0p1               1      195312       97656    c  W95 FAT32 (LBA) 
/dev/mmcblk0p2          197265    15544319     7673527+  83  Linux 


Those are the current partitions. What we need to do is delete the second one and recreate it larger. Make a note of the first number on the second line (in this case 197265) and then type the command 'd' (and press enter). Choose 2. Now we create a new one with 'n' and enter 'p' for primary and 2 for partition number 2. Now we get to the first sector, and here it's important that you enter the number we took note of earlier, in this case 197265. Select the largest value for last sector. Now that we've done that enter 'w' to write and then 'q' to quit. Reboot with the command 'reboot' and once you've booted and logged in again run 'resize2fs /dev/mmcblk0p2'. It'll take a while to complete but once done you'll be able to utilise the full size of the SD card.

The next step is to update the system so you have the latest software running. Normally you would just need to run 'pacman -Syu' to update, but some manual intervention is required because of some recent changes. I won't go into much detail, I'll just give a list of commands to execute. This is from memory when I did this a couple of days ago, so give me a shout if something seems not to be working.

 
pacman -Sy pacman 
pacman-key --init 
pacman -S archlinux-keyring 
pacman-key --populate archlinux 
pacman -Syu --ignore filesystem 
pacman -S filesystem --force 


It will ask if you want to replace for example udev with systemd-tools etcetra, and yes, you do.

Once that's done you should have a fully up-to-date Arch Linux system on your Raspberry Pi!

Extra tips
To enable sound edit /etc/rc.conf and add snd-bcm2835 to MODULES like so:

 
MODULES=(snd-bcm2835) 



You can also change hostname in the same file (the HOSTNAME variable), which takes a reboot to take effect.

To create a swap file (which is a good idea in case you end up in a situation where you need one) run the following commands (taken from Arch wiki):

 
fallocate -l 128M /swapfile 
chmod 600 /swapfile 
mkswap /swapfile 
swapon /swapfile 


and add "/swapfile none swap defaults 0 0" to /etc/fstab.

You might want to limit writes to your root partition by disabling atime and diratime (sets a timestamp of latest access). For normal usage there are no real benefits to having them enabled while it can give you a performance boost (and can boost your cards longevity) to disable them.
Here's how your fstab might look:

 
devpts                 /dev/pts      devpts    defaults                        0      0 
shm                    /dev/shm      tmpfs     nodev,nosuid                    0      0 
/dev/mmcblk0p1         /boot         vfat      defaults                        0      0 
/dev/mmcblk0p2         /             ext4      defaults,noatime,nodiratime     0      0 
/swapfile              none          swap      defaults                        0      0 



If you have any additional tips or questions post away!


 

Share this post


Link to post
Share on other sites

Greetings!

 

...and many thanks for the tutorial. It has brought me far further than any other in getting Arch (my first experience) into shape on our RasPi. Reason for doing this is that I can fool around with RasPi SD cards without stuffing up a working PC or shredding a working HDD.

 

I'm using this image - archlinux-hf-2012-09-18.img SHA1 says it checks out OK.

It's installed to a 16GB class 10 SDHC card using dd

It booted up OK, and I've been working my way down your tutorial, taking notes. (Did skip the partition enlargement.)

 

I've run into a non-existant /etc/rc.conf when attempting to add: MODULES=(snd-bcm2835)

 

My disorientation when attempting to parse the 'pacman' commands via man pages is almost complete! <grin>

 

So I'm not properly sure what I'm doing, unless the missing rc.conf is related to systemd?

 

About to do another reboot, wish me luck....

  • Like 1

Share this post


Link to post
Share on other sites

OK.... it rebooted! Thanks!

 

We do have some funnies at the end of the boot process :

The login:

alarmpi login:

.....appears OK

 

...and then five or so more boot items appear:

 

[ OK ] Started dhcpcd on eth0

[ OK ] Reached target network

Starting OpenNTP Daemon

[ OK ] Started OpenNTP Daemon

[ OK ] Rreached target Multi-User

[ OK ] Reached target Graphical Interface

 

...which looks like boot tasks completing asynchronously, but despite the last line there's no sign of anything graphical yet! ;)

 

I'm about to take a punt at loading LXDE, thanks for the guide!

  • Like 1

Share this post


Link to post
Share on other sites

Yes indeed! Not up to speed on Arch, yet, so all suggestions are welcomed with open arms.

LXDE would not load with startlxde, with a puzzlingly complete absence of any response/log/dmesg/whatever.

 

"The clue is, that there were no clues at all, Watson"

 

So I started again from scratch, this time using the Arch systemd documentation to translate the traditional initscripts as best I could.

So far, so good. This time my user seems to have validity and appropriate permissions, and man no longer gets upset about fonts etc.

 

Updating with pacman -Syu throws a bunch of 'pacnew' warnings about four or five altered files that will probably need merging by hand.

Much like this: warning /etc/sysctl.conf installed as /etc/sysctl.conf.pacnew

 

Arch is fun, it's much like booting SVR1 on a 32016 back in1983! ....only without sysvinit, of course.

 

Would caution others that it can be as involving and time consuming as Colossal Cave. If I had not been inveigled into sorting Arch on Pi out for a curious young chap (and become trapped in a recursion of twisty configurations, all looking the same) I'd probably have ditched it by now and gone back to Bodhi, which works well.

Share this post


Link to post
Share on other sites

OK, we're running - but not 100% yet - and had to back off and try again from scratch. Not certain now what all the steps were, brain gets fuzzy in the small hours of the morning. It's still a systemd configuration, and it does boot pretty well - but only to a tty login.

Hitting it with startx gets OpenBox running, and that's probably good enough for this project. Looks good, runs well enough, but uses more RAM than I expected.

Raspbian derivatives seem to be more practical, at least at this stage, and Bodhi Linux is still seriously lean indeed despite the smooth desktop bling.

 

All of them suffer from the 256MB RAM limitation. Even when the reported OS RAM usage is less than 50MB (not counting buffers and caches, which vary with the weather), if you start with 256MB and the shared-RAM video reduces that to 182MB, there ain't a lot left for your browser pages to load.

 

A couple of tabs open is fine, but it gets sticky around 6 to 8 tabs, depending on the content and on any other progs loaded. All the distros suffer once their RAM is full, which is to be expected.

 

So the newly-announced and already in production Raspberry Pi built in Wales with 512MB for the same price is a gem! I'm ordering one....

Share this post


Link to post
Share on other sites

Many thanks for this how-to.

 

Since recent change to image (currently archlinux-hf-2013-02-11.img from zip file) there's no need to run archlinux keyring so the simple 'pacman -Syu' will once again suffice.

 

Also (for safety reasons) might it be useful to suggest that the example SD card location in your second paragraph be amended to /dev/sdb (hard drives are often /dev/sda), or alternatively add a warning for new users?

 

Thanks again for your work here.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

About Us

Bringing you the latest Raspberry Pi news, tutorials and user forum.

The Fruity Computer

×