Debootstrap Raspberry Pi

For USB devices

For this task I have decided to use an external USB HDD as my file system host. I found my SD card compatibility to be rather disappointing, and I’d rather not be buying additional memory cards for this.

So my RPi is connected to a 4 port powered USB hub, though this may look strange I’m drawing power from the hub via a micro USB lead and I’m connected to one of the 2 USB ports in order to connect external devices.

Using the most recent Debian SD card image, I’ve booted up with the external drive attached to the second USB port

1.Logged in to debian with the pi/raspberry account

2.sudo su (switch to su mode without the root password)

3.ls /dev

(list all devices, depending on the type of drive)

Look for /dev/sda

Note your SD card will be listed as /dev/mmcblk0 (with partitions p1, p2, p3)

4.fdisk /dev/sda (obviously change this to match your HDD configuration)

5.p (print the partition table)

6.d <Enter> <number> (for each partition to delete them)

7.n <Enter> p <Enter> 1 <Enter> (Choose appropriate size for your main file area)

8.n <Enter> p <Enter> 2 <Enter> (make sure to have left yourself some swapspace)

9.You can set the boot flag if you want, but it isn’t needed since your booting from the SD card

10.mkfs.ext4 /dev/sda1 (format the first partition)

11.mkswap /dev/sda2 (format the swap space)

Now we need to prepare the installation onto this new drive ready to boot

1.mkdir /a (create a folder called a in the root, this is where we will build our new install)

2.mount /dev/sda1 /a (mount our new drive on /a)

3.apt-get update (update our package sources)

4.apt-get install debootstrap (install debootstrap)

5.debootstrap squeeze /a http://192.168.1.11:3142/ftp.debian.org/debian/

(do a minimal build onto our folder)

I use apt-cacher-ng on another machine, use http://ftp.debian.org/debian/

Once the packages have downloaded and installed we should have an extremely minimal debian install in /a

Let’s move across into this new environment and start to build it up to be able to operate on it’s own

Download the kernel file from http://www.bootc.net/raspberrypi/linux- ... _armel.deb

(Note : You may find that the version has been updated since I wrote this note, please go to http://www.bootc.net/raspberrypi/ to find the latest file name if needed)

wget http://www.bootc.net/raspberrypi/linux- ... _armel.deb

Copy the downloaded files, linux-image-3.2.18-rpi1+_5_armel.deb and linux-raspberrypi-3.1.9-18-arm.pkg.tar to your new area (/a/root/installation was where I put the files)

1.chroot /a (Change root to our new folder)

2.passwd <Enter> (follow instructions to set the new passwd for root on your new install)

3.apt-get update

4.apt-get install aptitude openssh-server locales ntp

5.dpkg-reconfigure locales

This should provide us with a remotely accessible platform once we get the kernel installed

Let’s get the kernel and modules installed

1.cd /root/installations

2.dpkg -i linux-image-3.2.18-rpi1+_5_armel.deb

The new kernel is now stored in /boot. In order to update your SD card to use this kernel you now need to do a little slight of hand

The file you need is in /boot called vmlinuz-3.2.18-rpi1+, and to use it we need to copy this file and rename it to kernel.img and store it on the SD card

When I applied the kernel update on my SD card, I did the following

1.mkdir /tempSD

2.mount /dev/mmcblk0p1 /tempSD

3.mv /tempSD/kernel.img /tempSD/kernel.img.original

4.cp /boot/vmlinuz-3.2.18-rpi1+ /tempSD/kernel.img

5.nano /tempSD/cmdline.txt

6.(modify the boot command by changing root=/dev/mmcblk0p2 to root=/dev/sda1)

7.CTRL+O,<Enter>,CTRL+X

8.umount /tempSD

9.rmdir /tempSD

These changes now mean you have the up to date kernel on the SD card and you’ve modified the boot commands to use your USB HDD as the root file system

Now do a reboot (reboot <Enter>) and let’s see what happens

The first thing you should notice is that it boots up fairly quickly. Always a good sign I think

The second is that you should be able to logon as root, using the password you set earlier

Now we need to make a few modifications to the configuration in order to automatically get the internet connection up and running

1.Log on to the PI

2.nano /etc/network/interfaces

3.Add the following lines to the file if they are not already present

auto eth0

iface eth0 inet dhcp

4.Before we forget, we need to turn on our swap if it hasn’t already

5.nano /etc/fstab

add the following line

none /dev/sda2 swap sw 0 0

6.exit

7.swapon /dev/sda2

8.To address a bug I keep finding with the network connection, edit the sysctl.conf file in /etc and include the line vm.min_free_kbytes=32768

9.Now you should be able to reboot and have networking available

XBMC time (incomplete text, still trying to make this bit work correctly)

Edit apt sources.list file to include a local mirror for debian-multimedia

When you try to do an apt-get update you will get an error due to the gpg key, use the following command and substitude the code returned in the error message in order to correct the problem

1. wget -q ""http://keyserver.ubuntu.com:11371/pks/lookup?op=get&search=0x4874D3686E80C6B7"" -O- | sudo apt-key add -

Now we can install xbmc using “apt-get install xbmc lxde”. File sizes are around 260Mb alone for XBMC, probably about the same for LXDE packages so be prepared to wait

1. dpkg-reconfigure x11-common

2. Choose Anybody

Posted on Jan 1
Written by Andrew Ord