Raspberry PI - Boot Linux from USB PEN instead of a SDCARD

Oscar Brito

There are on the web several articles about USB booting a raspberry pi, but only a few
describe how to configure tmpfs and swap, important definition for low resources devices.

Note: My USB pen have 16gb of available storage!

1) Copy all SDCard files to your USB partition that will hold linux

You already have a bootable SDCard to boot your raspberry. Now you need to copy all the content of this to the USB Pen.

sudo dd if=/dev/sdc2 of=/dev/sdb3 bs=512k

/dev/sdc2 - SDCARD
/dev/sdb3 - USB Pen partition

* Check article for checking dd progress:

2) Change /boot/cmdline.txt to (setup raspberry boot partition ):

sudo vim /boot/cmdline.txt

3) Change /etc/fstab root partition, like:

sudo vim /etc/fstab

# add rootfs definition
/dev/sda3       /               ext4    defaults,noatime  0       0

4) Change TMP folders settings (24mb is not enouth)

sudo vim /etc/default/tmpfs

TMPSIZE=524288000 #500mb

5) Augment available swap:

If you want to use the raspberry default swap setup:

vim /etc/dphys-swapfile 

If you have a swap partition:

#disables raspberry swap setup
sudo update-rc.d -f  dphys-swapfile remove

# add swap to current loaded linux ( without restart )
sudo mkswap /dev/PARTITION
sudo swapon /dev/PARTITION

sudo vim /etc/fstab
/dev/sda2       swap    swap      0       0

6) Restart

Check your partitions setup:

Check your swap setup:
free -m

Visit www.divhide.com for more informations, contacts and news about Web Development.
See other blog posts at blog.divhide.com.

Divhide purpose is to follow the HTML5 movement and contribute with applications which prove the quality of technology.

Feel free to contact divhide.