Sunday, January 6, 2013

Installing second Arch Linux partition for dual boot on Raspberry Pi without using other computer

Recently I managed to set up an AirPlay http streaming server on my raspberry pi. Now I also want to have a web server on the pi. Since it is supposed to be public I want to do it on a fresh install of Arch Linux. But I don't want to buy a new SD card for this and I don't want to loose my AirPlay setup.

So I started to look into dual booting the pi. All I could find was how to use berryboot but that seemed to require another computer and also wipes the SD card. I wanted to do it directly on the pi and as simple as possible. And I had not resized the original Arch install so I had room for another on my 4Gb SD. This is how I did it.

First I downloaded the at the moment latest image:
#wget http://mirrors.dotsrc.org/rpi/images/archlinuxarm/archlinux-hf-2012-09-18/archlinux-hf-2012-09-18.zip
Then I setup a second partition EXACTLY the same size as the current root:
#sudo parted
GNU Parted 3.1
Using /dev/mmcblk0
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) unit MiB
(parted) print
Model: SD SD4GB (sd/mmc)
Disk /dev/mmcblk0: 3796MiB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number Start End Size Type File system Flags
1 1.00MiB 95.0MiB 94.0MiB primary fat16 boot, lba
2 95.0MiB 1886MiB 1791MiB primary ext4

(parted) mkpart ext4 1886MiB 3677MiB
(parted) quit
Then I used unzip and dd together to write the downloaded root partition to the new partition:
#su -
#unzip -p archlinux-hf-2012-09-18.zip | dd of=/dev/mmcblk0p3 bs=1M skip=99614720 iflag=fullblock,skip_bytes
DANGER: Be sure to use the right path for the of flag or else you could wipe your whole boot or root partition!!!!
The skip part is because the image has a partition table and a boot partition in front of the root partition. By looking at the partition table above we can see that the root begins at 95MiB into the image. unzip -p pipes the output to dd. This is very useful since there is not enough room to uncompress the whole image.

By mounting the new partition we can see that it seems good:
#mount /dev/mmcblk0p3 /mnt/dual
TBD: Setting up cmdline.txt and config.txt in /boot to use new partition

No comments:

Post a Comment