Meta

Raspbian on Raspberry Pi using SD card + USB memory stick

Submitted by admin, on August 5th, 2012

Raspbian is a Debian based Linux distribution, specifically for use with the Raspberry Pi. The Raspberry Pi requires that the system is initially booted of SD. Because of this, a default install of Raspbian requires an SD card of at least 2gb.

I received my Raspberry Pi the other day, and didn’t have a spare 2gb SD card that wasn’t already being used, but I had a few smaller ones around the place (128mb, 256mb, etc). I wanted to find a way to utilize one of these smaller SD cards just for the system boot files, and then run the main system off a USB memory stick.

It turns out that the Raspbian image contains a boot partition, and as long as you can copy this to a SD card (and modify the cmdline.txt file to point to the root partition on the USB memory stick), you will be able to initially boot of a small SD card, then load the rest of the system off a larger USB memory stick.

Requirements:

A linux PC (Only required for this guide. The same process could be done using tools on other operating systems).

SD card (minimum 64mb)

USB memory stick (minimum 2gb)

Determining device names:

Find the device names for both your USB device, and your SD device. You can usually use the ‘dmesg’ command to find the device names for your storage devices.

At the time of writing, the latest release was 2012-07-15-wheezy-raspbian.zip

Installing Raspbian to a USB memory stick:

Extract the zip to a location on your PC.

unzip 2012-07-15-wheezy-raspbian.zip

This should extract a single file named “2012-07-15-wheezy-raspbian.img”.

Write this image to your USB memory stick device. Make sure you get the “of” (output file) part of the command line parameters correct, so you don’t overwrite your hard drive, or any other storage device.

sudo dd if=2012-07-15-wheezy-raspbian.img of=/dev/sdj

2012-07-15-wheezy-raspbian.img being the input file.
/dev/sdj being the output file/device (the USB memory stick device).

Preparing the SD card:

Make sure you obtain the correct device name for your SD card. In this example, my SD card is /dev/sdf.

Remove any partitions that may already exist on the SD card.

(you can do this via fdisk, or use ‘sudo dd if=/dev/zero of=/dev/sdf’)

Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.
$

Now that you have a FAT32 partition created, you need to put a filesystem on it.

(This is just changing /dev/mmcblk0p2 (the 2nd partition on the SD card) to /dev/sda2 (the second partition on the USB memory stick). This tells the Raspberri Pi device where to find the root partition.

Save and exit the editor.

Finishing up:

Unmount the devices.

$ sudo umount /tmp/mnt_usb
$ sudo umount /tmp/mnt_sd

Remove the temporary mount folders. (Make sure they unmounted OK first, otherwise it will delete the data on the device itself).

$ sudo rm -rf /tmp/mnt_usb
$ sudo rm -rf /tmp/mnt_sd

You can now unplug your USB memory stick, and SD card, and insert them into your Raspberry Pi.

Power up your Raspberry Pi, and make sure it boots up into Raspbian correctly. If all goes well, it should boot up fine.

A little addition to this howto: You can create a new, empty, partition table in fdisk with the ‘o’ command.

Command (m for help): o

This is easier than the dd command in the section below, and less dangerous.
“Remove any partitions that may already exist on the SD card. (you can do this via fdisk, or use ‘sudo dd if=/dev/zero of=/dev/sdf’)”

You’re right, it will leave an unused partition on the USB device. I wasn’t too concerned by the wasted space on the USB memory stick, as it was minimal, and I wanted to keep the filesystem layout the same in case there were issues in /etc/fstab.

I haven’t tested your method, but it looks like an easier way to do it. Always good to see alternate methods.