Max_G
Posts: 42
Joined: Sat May 28, 2016 8:27 am

Pi4 boot from USB via SD boot folder

Sun Sep 15, 2019 7:06 am

I saw this post https://www.raspberrypi.org/forums/view ... 0#p1498774

which in essence says this:

Simple version of hybrid SD-USB boot tutorial:
  1. Write Raspbian image to USB drive with Etcher.
  2. Edit cmdline.txt to remove the resize script launch (see edit below).
  3. Copy files from USB "boot" partition to FAT32 micro SD card.
  4. Plug card and USB drive into Pi4 and boot it up.
  5. Once the system is up and running, edit /etc/fstab to mount the card as /boot (so that kernel and firmware updates are correctly applied) and reboot.
  6. Also, for headless boot, put ssh and wpa_supplicant.conf files on the USB drive (not the card, because USB mounts as /boot initially).
I followed step 1 to 4. However, I put an empty ssh file on the boot partition to be able to connect to it headless.
... and my cmdline.txt looked like this before modification

Code: Select all

pi@raspberrypi:/boot $ cat cmdline.txt
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=17869b7d-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet init=/usr/lib/raspi-config/init_resize.sh
and this after:

Code: Select all

pi@raspberrypi:/boot $ cat cmdline.txt
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=17869b7d-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

But have no clue what comes next.
The Pi4 did boot.
I seem to boot from sda2

Code: Select all

pi@raspberrypi:/ $ findmnt -n -o SOURCE /
/dev/sda2

Code: Select all

pi@raspberrypi:~ $ sudo blkid
/dev/mmcblk0p1: LABEL="BOOT" UUID="8010-7113" TYPE="vfat" PARTUUID="17869b7d-01"
/dev/sda1: LABEL_FATBOOT="boot" LABEL="boot" UUID="F661-303B" TYPE="vfat" PARTUUID="17869b7d-01"
/dev/sda2: LABEL="rootfs" UUID="8d008fde-f12a-47f7-8519-197ea707d3d4" TYPE="ext4" PARTUUID="17869b7d-02"
/dev/mmcblk0: PTUUID="17869b7d" PTTYPE="dos"

My fstab looks like this

Code: Select all

proc            /proc           proc    defaults          0       0
PARTUUID=17869b7d-01  /boot           vfat    defaults          0       2
PARTUUID=17869b7d-02  /               ext4    defaults,noatime  0       1
# a swapfile is not a swap partition, no line here
#   use  dphys-swapfile swap[on|off]  for that
As I said, I did follow step 1 to 4, and only ran the commands as shown... no reboot, or anything else yet.

Any hints appreciated...

RonR
Posts: 1185
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: Pi4 boot from USB via SD boot folder

Sun Sep 15, 2019 7:14 am

Set it up with usb-boot and you should be in business: Running Raspbian from USB Devices : Made Easy

Then have a look at /boot/cmdline.txt and /etc/fstab and you'll see what they needed to be.

Max_G
Posts: 42
Joined: Sat May 28, 2016 8:27 am

Re: Pi4 boot from USB via SD boot folder

Sun Sep 15, 2019 7:57 am

I appreciate the input, but I am after the steps required to complete the path I have chosen.

I had an SD card and 'etched' Buster lite onto it, and followed two guides, but neither one ended up with the desired outcome.

The post I am following was from @HawaiianPi, who also replied first to your post you've linked to. :)

In essence I am done trying new things, and simply want to know what do I need to change in fstab and/or elsewhere, to have the rPi4 reliably boot from SD and then "hand over" to the USB drive... or whichever way this is described, e.g. finds relevant files on SD card and then loads the rest from the USB-SSD drive.

RonR
Posts: 1185
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: Pi4 boot from USB via SD boot folder

Sun Sep 15, 2019 8:14 am

Max_G wrote:
Sun Sep 15, 2019 7:57 am
In essence I am done trying new things, and simply want to know what do I need to change in fstab and/or elsewhere, to have the rPi4 reliably boot from SD and then "hand over" to the USB drive... or whichever way this is described, e.g. finds relevant files on SD card and then loads the rest from the USB-SSD drive.

Assuming you have a working copy of Raspbian on both the SD card and the USB device:

The SD card's /boot/cmdline.txt: root=PARTUUID=12345678-02
The USB's /etc/fstab root entry: PARTUUID=12345678-02
The USB's /etc/fstab boot entry: /dev/mmcblk0p1

where 12345678 is the PARTUUID of the USB device.
Max_G wrote:
Sun Sep 15, 2019 7:06 am

Code: Select all

pi@raspberrypi:~ $ sudo blkid
/dev/mmcblk0p1: LABEL="BOOT" UUID="8010-7113" TYPE="vfat" PARTUUID="17869b7d-01"
/dev/sda1: LABEL_FATBOOT="boot" LABEL="boot" UUID="F661-303B" TYPE="vfat" PARTUUID="17869b7d-01"
/dev/sda2: LABEL="rootfs" UUID="8d008fde-f12a-47f7-8519-197ea707d3d4" TYPE="ext4" PARTUUID="17869b7d-02"
/dev/mmcblk0: PTUUID="17869b7d" PTTYPE="dos"

Your SD card and USB device have the same PARTUUID. This is a NO NO (usb-boot will warn you of this problem).

Max_G
Posts: 42
Joined: Sat May 28, 2016 8:27 am

Re: Pi4 boot from USB via SD boot folder

Sun Sep 15, 2019 9:37 am

Well, I etched the USB drive and copied the boot partition to the SD card as outlined in my original post.

Welcome to the Linux world, where there is no straight answer... as it seems.

What do I need to do, after step 1 to 4 to make this work?

User avatar
HawaiianPi
Posts: 5668
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: Pi4 boot from USB via SD boot folder

Sun Sep 15, 2019 11:11 am

Max_G wrote:
Sun Sep 15, 2019 9:37 am
Well, I etched the USB drive and copied the boot partition to the SD card as outlined in my original post.
If you did what I said, it should have worked.

  1. What kind of USB drive are you using?
  2. What size SD card (GB)?
  3. What are you using for a power supply?
  4. Which version of Raspbian Buster (Desktop or Lite)?

I haven't tried RonR's script myself, but others here have said it worked great for them.
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

Max_G
Posts: 42
Joined: Sat May 28, 2016 8:27 am

Re: Pi4 boot from USB via SD boot folder

Sun Sep 15, 2019 11:33 am

If you did what I said, it should have worked.
You're a funny man... I did what you said :)
Step 1 to 4... and then I was lost... still am.

What exactly do I need to do from here?
edit fstab... doing what exactly?

@RonR: yes. my UIDs are the same, as I etched the USB SSD, and copied /boot to the SSD.

Buster light on rPi4 with 4MB RAM; orignal Pi4 power supply. SD 16GB (brand SanDisk), USB SSD is a WD 250GB in an Orico USB3 case.

The thing booted, and as stated in my original post, the boot device is sda2.

I did not proceed beyond step 4, what exactly do I have to do next?

User avatar
HawaiianPi
Posts: 5668
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: Pi4 boot from USB via SD boot folder

Sun Sep 15, 2019 12:19 pm

Max_G wrote:
Sun Sep 15, 2019 11:33 am
The thing booted, and as stated in my original post, the boot device is sda2.

I did not proceed beyond step 4, what exactly do I have to do next?
Oh, sorry, I misunderstood your post. I though it didn't boot.

Code: Select all

sudo nano /etc/fstab
Change the /boot mount point to /dev/mmcblk0p1

Code: Select all

proc			/proc	proc    defaults          0       0
/dev/mmcblk0p1		/boot	vfat    defaults          0       2
#PARTUUID=17869b7d-01	/boot	vfat    defaults          0       2
PARTUUID=17869b7d-02 	/	ext4    defaults,noatime  0       1
This is so that kernel and firmware updates get written to the card (because the system is not booting from the SSD /boot partition). Essentially the /boot partition on the SSD is not being used (but once USB boot is officially supported you can copy the card back to the SSD to update it).

Note in the example above I commented out the original /boot mount point, but kept it in the file so it will be easier to transition to full USB boot when the time comes.
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

RonR
Posts: 1185
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: Pi4 boot from USB via SD boot folder

Sun Sep 15, 2019 7:23 pm

Max_G wrote:
Sun Sep 15, 2019 11:33 am
@RonR: yes. my UIDs are the same, as I etched the USB SSD, and copied /boot to the SSD.

Every device (SD card / USB device) must have it's own PTUUID (partition table universally unique identifier) which consists of 8 hex digits. The PTUUID is stored in the device's MBR (master boot record). Partitions on those devices have a PARTUUID (partition universally unique identifier) which is created by appending the partition number (-01, -02, ...) to the device's PTUUID.

The 2019-07-10-raspbian-buster-lite.img file has a PTUUID value of 17869b7d. When you write that image file to any device, it initially has that PTUUID. Normally, that device is an SD card and upon booting it the first time, /usr/lib/raspi-config/init_resize.sh resizes the root partition using parted, which changes the PTUUID to a new value. init_resize.sh also updates /boot/cmdline.txt and /etc/fstab to match the new PTUUID.

You obviously wrote 2019-07-10-raspbian-buster-lite.img to both the SD card and USB device, but you removed init=/usr/lib/raspi-config/init_resize.sh from /boot/cmdline.txt, leaving both devices having the same PTUUID. The boot partition on the USB device is never used/accessed, so its contents aren't relevant.

Copying files from one device to another does not copy the PTUUID/PARTUUID of the source device to destination device.

For reliable and predictable operation, every device must have a different PTUUID.

Subtle issues like this often aren't spelled out in the numerous 'tutorials' people have written. I created usb-boot to ensure critical steps aren't missed and conflicts are detected and reported. usb-boot also takes care of resizing the USB's root partition, which an unmodified raspi-config cannot accomplish.

User avatar
HawaiianPi
Posts: 5668
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: Pi4 boot from USB via SD boot folder

Sun Sep 15, 2019 8:24 pm

Max_G wrote:
Sun Sep 15, 2019 11:33 am
@RonR: yes. my UIDs are the same, as I etched the USB SSD, and copied /boot to the SSD.
That's a confusing statement.

You should have used Etcher to write the image to the SSD, and then copied the files on the SSD "boot" partition to a FAT32 formatted card. If you somehow cloned the /boot partition to the card, you did not do what I said.
HawaiianPi wrote: 3. Copy files from USB "boot" partition to FAT32 micro SD card.

You really should just use RonR's script, since you are having difficulty with this.
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

RonR
Posts: 1185
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: Pi4 boot from USB via SD boot folder

Sun Sep 15, 2019 9:00 pm

HawaiianPi wrote:
Sun Sep 15, 2019 8:24 pm
You should have used Etcher to write the image to the SSD, and then copied the files on the SSD "boot" partition to a FAT32 formatted card. If you somehow cloned the /boot partition to the card, you did not do what I said.

Formatting an SD card to FAT32 does not change its PTUUID. If an SD card has previously been written with the 2019-07-10-raspbian-buster-lite.img file but not then booted with its init_resize.sh intact , its PTUUID will be 17869b7d, the same as the USB device being written with the same image file. Formatting the SD card to FAT32 will not then alter its PTUUID. Deleting its second partition with fdisk or Windows Disk Manager will not change its PTUUID. You end up with both devices having the same PTUUID, which is a NO NO.

Max_G
Posts: 42
Joined: Sat May 28, 2016 8:27 am

Re: Pi4 boot from USB via SD boot folder

Mon Sep 16, 2019 9:19 am

Thanks Gents.

It's becoming an interesting topic.
HawaiianPi wrote:
Max_G wrote:
Sun Sep 15, 2019 11:33 am
@RonR: yes. my UIDs are the same, as I etched the USB SSD, and copied /boot to the SSD.
That's a confusing statement.

You should have used Etcher to write the image to the SSD, and then copied the files on the SSD "boot" partition to a FAT32 formatted card. If you somehow cloned the /boot partition to the card, you did not do what I said.
...
It may well be confusing... but Ron figured out what actually happened... and this is what happened.
And yes, I did follow your instructions as stated in my original post.

In any case, thanks for following up on this; I added this line to fstab:

Code: Select all

/dev/mmcblk0p1          /boot           vfat    defaults                0       2
So fstab looks like this now:

Code: Select all

proc                    /proc           proc    defaults                0       0
/dev/mmcblk0p1          /boot           vfat    defaults                0       2
#PARTUUID=17869b7d-01   /boot           vfat    defaults                0       2
PARTUUID=17869b7d-02    /               ext4    defaults,noatime        0       1
# a swapfile is not a swap partition, no line here
#   use  dphys-swapfile swap[on|off]  for that
Interestingly enough:

Code: Select all

 findmnt -n -o SOURCE /
/dev/sda2
returns sda2 as source drive... is this as expected?

this is the current storage environment:

Code: Select all

 lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda           8:0    0 232.9G  0 disk
├─sda1        8:1    0   256M  0 part
└─sda2        8:2    0   1.8G  0 part /
mmcblk0     179:0    0  14.5G  0 disk
└─mmcblk0p1 179:1    0  14.5G  0 part /boot
Also, do I have to add:

Code: Select all

 init=/usr/lib/raspi-config/init_resize.sh
back into the cmdline.txt

Maybe it is time to start from scratch and use Ron's usb-boot.zip after all.

RonR
Posts: 1185
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: Pi4 boot from USB via SD boot folder

Mon Sep 16, 2019 6:48 pm

Max_G wrote:
Mon Sep 16, 2019 9:19 am

Code: Select all

 findmnt -n -o SOURCE /
/dev/sda2
returns sda2 as source drive... is this as expected?

Yes. Your SSD is currently /dev/sda and its second partition is mounted on /
Max_G wrote:
Mon Sep 16, 2019 9:19 am
Also, do I have to add:

Code: Select all

 init=/usr/lib/raspi-config/init_resize.sh
back into the cmdline.txt

No. If you do, the first time you reboot, it will be deleted and the system will hang (the system will boot properly after a power cycle).
Max_G wrote:
Mon Sep 16, 2019 9:19 am
Maybe it is time to start from scratch and use Ron's usb-boot.zip after all.

It's the simplest and easiest way to get to a properly configured system (you currently have an SD card and an SSD with the same PTUUID).

If you want to keep what you currently have on your SSD, don't do anything to it.

If you want to start over with a clean SSD, either:

1. Use Etcher to write a fresh copy of Raspbian to the SSD (fastest).
or
2. Have usb-boot copy the contents of your SD card to the SSD (slower).

Use Etcher to put a fresh copy Raspbian on your SD card and boot it.

Run usb-boot and follow the yellow brick road.

RedPanther
Posts: 39
Joined: Thu Sep 12, 2019 9:20 pm

Re: Pi4 boot from USB via SD boot folder

Mon Sep 16, 2019 7:08 pm

If I’m reading this correctly, the purpose of what you’re trying to do is run a boot/recovery system on you SD card while having your root file system(where the computer runs from once it’s booted) on an HDD/SSD?

Why not simply use an 8Gb SD card, FAT32 format it, and just copy the NOOBS files to it? On first boot, change your installation destination to whichever drive you want. Once the system has finished installing, you will have a running “hybrid” system.

At least, that’s how I set up mine. Then I added whatever drives I wanted in my /etc/fstab file for extra storage.
One more is never enough ;)

Max_G
Posts: 42
Joined: Sat May 28, 2016 8:27 am

Re: Pi4 boot from USB via SD boot folder

Tue Sep 17, 2019 11:10 am

RonR wrote:
Mon Sep 16, 2019 6:48 pm

...
If you want to keep what you currently have on your SSD, don't do anything to it.

...
Thanks for staying with me on this one! Much appreciated.
The process was simple, and now that it is clear it works, I can easily replicate it... until such time the Pi4 boots off USB directly.

But... I will try usb-boot as well. :)

RonR
Posts: 1185
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: Pi4 boot from USB via SD boot folder

Tue Sep 17, 2019 6:12 pm

Max_G wrote:
Tue Sep 17, 2019 11:10 am
RonR wrote:
Mon Sep 16, 2019 6:48 pm

...
If you want to keep what you currently have on your SSD, don't do anything to it.

...
Thanks for staying with me on this one! Much appreciated.
The process was simple, and now that it is clear it works, I can easily replicate it... until such time the Pi4 boots off USB directly.

But... I will try usb-boot as well. :)

I think you misunderstood. What I meant to convey was:
RonR wrote:
Mon Sep 16, 2019 6:48 pm
If you want to keep what you currently have on your SSD, don't do anything to it.

OR
RonR wrote:
Mon Sep 16, 2019 6:48 pm
If you want to start over with a clean SSD, either:

1. Use Etcher to write a fresh copy of Raspbian to the SSD (fastest).
or
2. Have usb-boot copy the contents of your SD card to the SSD (slower).

In either case:
RonR wrote:
Mon Sep 16, 2019 6:48 pm
Use Etcher to put a fresh copy Raspbian on your SD card and boot it.

Run usb-boot and follow the yellow brick road.

kirpat
Posts: 11
Joined: Thu Sep 13, 2018 3:06 am

Re: Pi4 boot from USB via SD boot folder

Tue Nov 26, 2019 3:15 pm

I have succesfully booted form SSD
but now when i connect another ntfs formatted usb flash drive as additional external storage,
rpi4 4g is unable to boot and get stucked and after this i have to remove my added usb flash drive and turnoff and turnon rpi4 again.
Is this problem faced by anuone.
or if there are any config files to suggest.
Please guide,
thanks

RonR
Posts: 1185
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: Pi4 boot from USB via SD boot folder

Tue Nov 26, 2019 6:30 pm

kirpat wrote:
Tue Nov 26, 2019 3:15 pm
I have succesfully booted form SSD
but now when i connect another ntfs formatted usb flash drive as additional external storage,
rpi4 4g is unable to boot and get stucked and after this i have to remove my added usb flash drive and turnoff and turnon rpi4 again.
Is this problem faced by anuone.
or if there are any config files to suggest.
Please guide,
thanks

How did you configure your Raspberry Pi to boot from SSD? If you use usb-boot, you should not experience any problem with additional USB devices being inserted or removed (bootable or non-bootable, NTFS or otherwise).

kirpat
Posts: 11
Joined: Thu Sep 13, 2018 3:06 am

Re: Pi4 boot from USB via SD boot folder

Wed Nov 27, 2019 2:44 am

i have managed to boot by changing location of my root in cmdline.txt boot partition,
suggested here: https://www.stewright.me/2019/10/run-ra ... erry-pi-4/

i am able to boot and use my ssd as root but if i plugin my another usb flash drive it cant boot.

RonR
Posts: 1185
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: Pi4 boot from USB via SD boot folder

Wed Nov 27, 2019 3:49 am

kirpat wrote:
Wed Nov 27, 2019 2:44 am
i have managed to boot by changing location of my root in cmdline.txt boot partition,
suggested here: https://www.stewright.me/2019/10/run-ra ... erry-pi-4/

i am able to boot and use my ssd as root but if i plugin my another usb flash drive it cant boot.

The procedure outlined at the link above is incomplete and flawed.

Download usb-boot and run it. Select 'No' if prompted 'Replicate BOOT/ROOT contents...?'. When usb-boot completes, reboot and your problem should be corrected.

User avatar
HawaiianPi
Posts: 5668
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: Pi4 boot from USB via SD boot folder

Wed Nov 27, 2019 5:59 am

kirpat wrote:
Wed Nov 27, 2019 2:44 am
i have managed to boot by changing location of my root in cmdline.txt boot partition,
suggested here: https://www.stewright.me/2019/10/run-ra ... erry-pi-4/

i am able to boot and use my ssd as root but if i plugin my another usb flash drive it cant boot.
That's because it's a bad tutorial. It recommends using /dev/sda rather than UUID or PARTUUID, and there is no way to assure a given drive will always be /dev/sda when another drive is added. Your boot failure is due to the added drive being assigned /dev/sda with your original drive ending up as /dev/sdb, and your cmdline.txt pointing to the wrong drive as a result.

If you want to try and fix this yourself (rather than using RonR's script) boot without the extra drive and run the following command.

Code: Select all

ls -l /dev/disk/by-partuuid
This will give you the PARTUUID of the SD card and USB boot drive. Note the ID of the / (rootfs) partition on the drive you want to boot and use that in /boot/cmdline.txt (root=PARTUUID=1234abcd-02).
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

kirpat
Posts: 11
Joined: Thu Sep 13, 2018 3:06 am

Re: Pi4 boot from USB via SD boot folder

Thu Nov 28, 2019 3:29 am

I have set my cmdline.txt with UUID=
And now as per your recommendation I have changed my root to PARTUUID
Now after reboot with attached usb flash drive stucked at booting

RonR
Posts: 1185
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: Pi4 boot from USB via SD boot folder

Thu Nov 28, 2019 3:52 am

kirpat wrote:
Thu Nov 28, 2019 3:29 am
I have set my cmdline.txt with UUID=
And now as per your recommendation I have changed my root to PARTUUID
Now after reboot with attached usb flash drive stucked at booting

How's that old saying go?:

"You can lead a horse to water, but you can't make him drink."

One last suggestion (click here)

kirpat
Posts: 11
Joined: Thu Sep 13, 2018 3:06 am

Re: Pi4 boot from USB via SD boot folder

Thu Nov 28, 2019 4:46 am

Ok if I want to install this way,
How to do without messing my existing system installed on it.

RonR
Posts: 1185
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: Pi4 boot from USB via SD boot folder

Thu Nov 28, 2019 5:17 am

kirpat wrote:
Thu Nov 28, 2019 4:46 am
Ok if I want to install this way,
How to do without messing my existing system installed on it.

1. Disconnect all USB drives except the SSD

2. Run usb-boot

3. Select the SSD (should be the only USB device listed) and then OK

4. Answer 'No' if prompted 'Replicate BOOT/ROOT contents...?'

5. usb-boot will quickly finish

6. Reboot

7. After successful reboot, insert the additional USB drive

8. Run 'sudo blkid' and ensure that there is no duplication of PTUUID/PARTUUID's between devices

9. Reboot

If the system still hangs, there is almost certainly something wrong with the additional USB drive or its compatibility with the Raspberry Pi 4.

Return to “Advanced users”