Micro SDHC to USB drive and boot on Raspberry Pi 3 Ubuntu

Reviews, software, hardware and electronics.

Moderator: embleton

Post Reply
User avatar
Site Admin
Posts: 555
Joined: Sat Aug 02, 2014 1:40 pm
Location: Plymouth

Micro SDHC to USB drive and boot on Raspberry Pi 3 Ubuntu

Post by embleton » Sun Jul 29, 2018 7:32 pm

The firmware on the Raspberry Pi must be updated to boot from the USB. 3 files need to be edited for the process needs the following to accomplish it:

1. Micro SDHC card with an original image and SDHC adaptor. My image was in place from an existing Ubuntu MATE 18.04.1 LTS system which I'd upgraded from Ubuntu MATE 16.04.02 LTS during the process. That's what we are going to talk about moving a live system to USB mSATA drive.
2. StarTech.com USB to mSATA card (PIB2MS1). mSATA microdrive of the size required. mSATA drives are relatively cheap and larger capacities are available for most desktop and server setups for Raspberry Pi 3 model B.
3. Knowledge of Ubuntu nano editor or PC text editor. Knowledge of ssh to remote access the box itself. Knowledge of terminal on MacOS and Ubuntu. And knowledge about mounting and unmounting files systems on Ubuntu. Knowledge about dd.
4. Access to the latest kernel for Raspberry Pi for the boot partition.
5. A PC or Mac to burn images and backups. I used a MacBook Air.

Back up the micro SDHC image on MacOS by its adaptor if using MacBook Air.

Place the SDHC adaptor with its micro SDHC card into SDXC card reader. Perform the following to back up the SDHC card.

sudo diskutil unmountDisk /dev/disk4 # For drive 4 continue with the disk4 in this example but your disk mount will likely be different.
sudo dd if=/dev/rdisk4 of=backup.img
sudo diskutil unmount /dev/rdisk4
sudo diskutil eject /dev/disk4

Remove the SDHC card adaptor with its original image. Plug the USB drive into the USB port on the MacBook Air. For the USB we'll assume its drive 3, but please confirm yours for getting it wrong will cost you, dear!

sudo diskutil unmountDisk /dev/disk3
sudo dd if=backup.img of=/dev/rdisk3
sudo diskutil unmount /dev/rdisk3
sudo diskutil eject /dev/disk3

Unplug USB and reinsert into the USB port. Get the latest built kernel firmware for the Raspberry Pi from GitHub (https://github.com/raspberrypi/firmware) this is important for standard kernel builds will not boot from USB. Copy all the kernel files and drivers right over the top of the DOS partition PI_BOOT files that is mounted for USB drive.

Plug micro SDHC card and USB drive into Raspberry Pi 3. Boot up the Raspberry Pi. Run the command below.

echo program_usb_boot_mode=1 | sudo tee -a /boot/config.txt

Reboot the Raspberry Pi with sudo reboot. Create a folder sudo mkdir /boot1 on the file system to mount partitions.
mount /dev/sda1 /boot1
Edit with nano the cmdline.txt file with sudo nano /boot1/cmdline.txt and replace the section root=/dev/mmcblk0p2 with root=/dev/sda2 which is the USB second partition root file system.
Resize the /dev/sda2 with sudo resize2fs /dev/sda2
Mount sda2 with mkdir /sda2 and then mount /dev/sda2 /sda2
And edit fstab at sudo nano /etc/fstab replace the first line /dev/mmcbblk0p2 to /dev/sda2 and /dev/mmcblk0p1 with /dev/sda1
Shutdown the Raspberry Pi with sudo shutdown 0
And then power off and remove the micro SDXC card.
Start up the system it will now boot from the USB drive.


sudo mkdir /boot1
mount /dv/sda1 /boot1
nano /boot1/cmdline.txt
resize2fs /dev/sda2
mkdir /sda2
mount /dev/sda2 /sda2
nano /etc/fstab
shutdown 0

Upgrading Ubuntu MATE 16.04.02 LTS to Ubuntu MATE 18.04.1 LTS when there is not enough space on the boot partition.

Create a folder for storing the kernel files as follow sudo mkdir /kernel
And then mv the kernel files kernel.img by mv /boot/kernel.img /kernel/kernel.img
And mv /boot/kernel7.img /kernel/kernel7.img
Perform The release upgrade with do-release-upgrade and do NOT reboot the system when prompted to do so at the end.
Move the kernel files back to the original location with mv /kernel/kernel.img /boot/kernel.img and mv /kernel/kernel7.img /boot/kernel7.img
Then reboot with sudo reboot


sudo mkdir /kernel
mv /boot/kernel.img /kernel/kernel.img
mv /boot/kernel7.img /kernel/kernel7.img
do-release-upgrade # don't reboot
mv /kernel/kernel.img /boot/kernel.img
mv /kernel/kernel7.img /boot/kernel7.img
sudo rmdir /kernel
sudo reboot

Also for the kernel, the /lib/modules need copying from the kernel firmware obtained from the GitHub.


Post Reply