So! RPi post 3!
NOTE: This was pretty much an abject failure and is only included here for completion purposes (i.e. it was on the wrong blog and I wanted it moved!)
Get the Pi booting from a USB flash drive.
For reasons of speed and to allow more to be installed on the operating system.
It’s impossible to boot from a USB flash drive directly. What you will be doing is to use the SD card as a ‘bios’ and then bootstrap it to jump to the flash drive.
I decided not to try and do this all by myself. I tried the guide here:
but found that it didn’t give me enough information to do anything with.
I then found this guide from Andrew Ord in Somerset, UK:
It’s not completely accurate (or wasn’t when I ran through it on July 4/5 2012, so here’s an updated version.
- Raspberry Pi model B.
- 2GB SD card (from MobyMemory, their own brand).
- 16GB flash drive. (from Play.com)
- USB keyboard.
- Ethernet cable.
- A 3.5″ car rear view camera screen. (You can use any monitor/screen that will connect)
- Laptop running Windows 7 and the Putty terminal.
A – Preparation
Install the Debian Wheezy Beta distribution. This was done on Windows. You may find that the image writer doesn’t work. There are alternatives, but the most import thing is to get this done. You can’t go any further unless you do.
- Download from the link above.
- Download the newest version of win32 diskimager from https://launchpad.net/win32-image-writer/+download
- Using it, write the image you downloaded to your SD card.
- Put the card in pi.
B – Devices and Partitions and Swaps, Oh My!
Sort out partitions and swaps and mount points. NB This will wipe your USB card
- Boot up the Pi with your flash drive and other cables plugged in. All the steps from here on (up to the networking step) were done over a Putty terminal.
- Log in as root with password root. (You’re going to sudo loads of stuff anyway, so logging in as root seems sensible).
- ls /dev and look for a device called ‘sda’. This is the whole USB flash drive. You are now going to sort it out so you can actually use it.
- fdisk /dev/sda
- Do p <enter> to see the partition table.
- Delete any existing partitions by doing d <enter> and picking the partition if necessary.
- Create new partitions:
- Do n <enter> p <enter> 1 <enter>
- Hit <enter> so it takes the default ‘start’ position.
- Choose an appropriate size for the main boot partition by following the instructions on that line. I think it’s something like size=+12GB or something. It says it on screen.
- Once you’re back to the fdisk console, do n <enter> p <enter> 2 <enter>.
- Use the default ‘start’ and ‘end’ positions (so that it automatically takes up the whole disk).
- This gives you two partitions. Exit from fdisk.
- At the prompt, type mkfs.ext4 /dev/sda1 (formats the main partition)
- Then do mkswap /dev/sda2 (which formats the swap drive).
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)
(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)
1. 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)
4.apt-get install aptitude openssh-server locales ntp
This should provide us with a remotely accessible platform once we get the kernel installed
Let’s get the kernel and modules installed
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
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
6.(modify the boot command by changing root=/dev/mmcblk0p2 to root=/dev/sda1)
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
3.Add the following lines to the file if they are not already present
iface eth0 inet dhcp
4.Before we forget, we need to turn on our swap if it hasn’t already
add the following line
none /dev/sda2 swap sw 0 0
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