Booting the raspberry pi 2 from a usb hd (SOLVED)

Victor vdemart at gmail.com
Thu Oct 4 11:04:19 UTC 2018


Dear All,
As I pointed out my problem is that I have a postgresql db on my pi2 heavily operating in read/write mode and therefore I expect a quick deterioration of the sd card.
reading the very fragmented pieces of info on the problem and combining them all in the end I found a solution for using a complete FreeBSD-armv6-12.0-RPI2-310476 installation (I mean thee root filesystem) on  an external usb device connected to my raspberry pi 2.

First of all I specify that the sd card MUST be in the raspberry for the very first boot of FreeBSD because the dos programs involved read the /etc/fstab and the various loader  files from /dev/mmcsd0s2, that is on the sd card itself. 

This is the procedure to follow:

1) As usual copy the image of file into the sd card via dd which in my Mac OS X is called /dev/disk1

sudo dd if = FreeBSD-armv6-12.0-RPI2-310476.img of=/dev/disk1 bs=1M conv=sync


2) Start the fresh installation of FreeBSD from the pi2 and verify what the external drive is called. In my case /dev/da0. Therefore the root filesystem will be in /dev/da0s2a.

3) Modify /etc/fstab in this way:

#/etc/fstab
# Custom /etc/fstab for FreeBSD embedded images
#/dev/ufs/rootfs   /       ufs     rw      1       1
/dev/da0s2a	/	ufs	rw	1	1
/dev/msdosfs/MSDOSBOOT /boot/msdos msdosfs rw,noatime 0 0
tmpfs /tmp tmpfs rw,mode=1777,size=50m 0 0

4) Create - because in the stock image there is not such a file - a  loader.conf file under the /boot directory with the following content:

#/boot/loader.conf
#Allowance of some more time for the recognition of the usb devices
kern.cam.boot_delay=10000 
#Inform where the root filesystem is
vfs.root.mountfrom="ufs:/dev/da0s2a"

5) Halt FreeBSD remove the sd card and copy it onto the external usb drive (/dev/disk2 on my Mac):
 
sudo dd if = /dev/disk1 of=/dev/disk2 bs=1M conv=sync

6) Insert again the sd card and the usb drive in your pi2 and ....start

Now you are using FreeBSD booted from the sd card but using the root filesystem on your external drive for the heavy read/write work! 
It works like a charm!

Be careful. The external hard drive shouldn't be too demanding in terms of electricity for the tiny raspberry. Do not use the "old" external hard-disk but the new and more expensive ssd drives. Believe me, in spite of the usb 2 the increase in speed is incredible.

Ciao
Vittorio  











More information about the freebsd-arm mailing list