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

Re: STICKY: HOWTO: Move the filesystem to a USB stick/Drive

Mon Apr 27, 2020 11:46 pm

messypotamia wrote:
Mon Apr 27, 2020 11:41 pm
Sir, I'm not booting from the USB using a "native boot mode", RPI4 isn't capable.

usb-boot works on all Raspberry Pi's, including the Raspberry Pi 4.

tofflock
Posts: 12
Joined: Mon Mar 05, 2012 11:53 am

Re: STICKY: HOWTO: Move the filesystem to a USB stick/Drive

Tue Apr 28, 2020 2:44 am

messypotamia wrote: ↑
The more I look at this, the more I don't see what I did wrong however the danged thing hangs -- never comes up -- when I use the .usb version of cmdline.
When I look at the output of your blkid command I see that your USB disk doesn't have any PARTUUID ids, just UUIDs.
In your cmdline.usb file, you have:

Code: Select all

... root=PARTUUID=d05c536f-3181-4abd-9922-cf1c66a15563 ...
that would make more sense if it said:

Code: Select all

... root=UUID=d05c536f-3181-4abd-9922-cf1c66a15563 ...
since you're using the UUID code.
You would have to amend /etc/fstab on the USB drive to use the same identifier (I mean UUID, rather than PARTUUID).

However...
I don't know if cmdline.txt can use UUID codes and I don't have time to try the experiment.
What I would do is make sure the USB drive has a unique PARTUUID code - NB it's very important that no two disks (partitions) attached to a system have the same UUID or PARTUUID code. (One gets identical PARTUUID codes if one clones a disk, or generates it from the same image file, so beware.)

With your system booted from the SDcard, and the USB disk attached, but not mounted, run

Code: Select all

sudo fdisk /dev/sda
NB Your output shows that your USB drive is sda, if it's changed (eg because you have 2 USB drives attached), then make sure you are changing the correct drive - I can't see your system!

Health Warning!
fdisk is all powerful! Don't be tempted to try any other options, other than those I mention below, unless you really know what you're doing, and there is nothing on the disk, or any other disk attached to the system, which contains vital information which is not backed up somewhere else and said backup is off-line.



You should then display the partition table and disk information block by typing

Code: Select all

p
Here's the output from one of my SSDs:

Code: Select all

Disk /dev/sda: 58.7 GiB, 63023063040 bytes, 123091920 sectors
Disk model: SSD U110 64GB
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 33553920 bytes
Disklabel type: dos
Disk identifier: 0x47709169                    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 

Device     Boot    Start       End  Sectors  Size Id Type
/dev/sda1           8192    532479   524288  256M  c W95 FAT32 (LBA)
/dev/sda2         532480  31981079 31448600   15G 83 Linux
/dev/sda3       31981080  52952279 20971200   10G 83 Linux
/dev/sda4       52952280 123091919 70139640 33.5G  5 Extended
/dev/sda5       53017815  73989014 20971200   10G 83 Linux
/dev/sda6       74054550 123091919 49037370 23.4G 83 Linux
You'll see that the bottom line of the header block reports the disk identifier (I've marked the line). It's this hex number that is used as the basis for the PARTUUID. If yours is missing, or it's the same as the PARTUUID for your SD card (which appears to be 0x29606f3c, then you need to add an identifier, or change the current one. This is done from the expert menu, so press

Code: Select all

x
then

Code: Select all

i
to change the disk identifier. You'll need to enter a new id which is not the same as that of the SD card. My quick way is to swap the first & last digits of the SD card identifier (assuming they're not the same!), rather than trying to think up a new random hex integer (humans don't do random very well, apart from one...). So if I were doing it, I'd enter (here's the full line including the prompt)

Code: Select all

Enter the new disk identifier: 0xc9606f32 <Enter>
You need to then return to the "Main Menu" by pressing

Code: Select all

r
and then display the disk details and partition table again to show that you now have a (new) disk identifier. Do that by pressing

Code: Select all

p
If all looks good (I mean disk identifier), then you'll need to write this data back to the disk and exit. Do this by pressing

Code: Select all

w
.

I would then reboot the Pi, and run blkid again and it should report the new PARTUUID ids for sda which will match the new id that you entered with fdisk, and there will be a -nn appended to each PARTUUID for each partition on your USB disk, starting with -01 for partion 1, and so on.

Then you need to correct your cmdline.usb file, and your /etc/fstab file and test a boot handing over to root on the USB disk.

HTH

PeterF
Last edited by tofflock on Tue Apr 28, 2020 8:53 am, edited 1 time in total.

gkreidl
Posts: 6307
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: STICKY: HOWTO: Move the filesystem to a USB stick/Drive

Tue Apr 28, 2020 6:34 am

RonR wrote:
Mon Apr 27, 2020 11:17 pm
messypotamia wrote:
Mon Apr 27, 2020 10:24 pm
Someone knows what's wrong.

Try usb-boot : Running Raspbian from USB Devices : Made Easy
I have used this thread (the OP) for all my RPis, starting with a Pi B, to move the file system to HDDs, up to my latest 4B4G. I know it works. It it doesn't work, the user did something wrong or there is another kind of problem (Power?).

Telling someone: throw everything away you've done and use my script instead is not very helpfull. I'd call this is thread-hijacking.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

paulv
Posts: 563
Joined: Tue Jan 15, 2013 12:10 pm
Location: Netherlands

Re: STICKY: HOWTO: Move the filesystem to a USB stick/Drive

Tue Apr 28, 2020 8:57 am

I'm the author of this post. just last week I verified it to work with the model 4 (again).
You may need to go through the procedure very carefully, it will work.

tofflock
Posts: 12
Joined: Mon Mar 05, 2012 11:53 am

Re: STICKY: HOWTO: Move the filesystem to a USB stick/Drive

Tue Apr 28, 2020 10:26 am

paulv wrote:
I'm the author of this post. just last week I verified it to work with the model 4 (again).
I did read through your post before replying to messypotamia and agreed with the philosophy. My reply to messypotamia was just trying to address the problem that I thought existed with his attempt to implement your method and looking at what I perceived were errors in his config files. Please remember that I don't know what he actually did, I can only see what he ended up with, and the problems that I thought I could identify in his configuration that wouldn't boot.

However, I think I may have spotted a typo in your original post which may have possibly misled him to use a UUID instead of a PARTUUID.
In the 16th code block in your original post (I think I've counted correctly), you show the output of a blkid command. I'll reproduce that code block here:

Code: Select all

pi@raspberrypi:~ $ sudo blkid
/dev/mmcblk0p1: LABEL_FATBOOT="boot" LABEL="boot" UUID="4BBD-D3E7" TYPE="vfat" PARTUUID="738a4d67-01"

/dev/mmcblk0p2: LABEL="rootfs" UUID="45e99191-771b-4e12-a526-0779148892cb" TYPE="ext4" PARTUUID="738a4d67-02"

/dev/mmcblk0: PTUUID="738a4d67" PTTYPE="dos"

/dev/sda1: LABEL="rootfs" UUID="3479031e-d58e-4204-8a27-666e0ba15e17" TYPE="ext4" PARTLABEL="Linux filesystem" PARTUUID="bb73d7cc-01f2-4e71-aeeb-90bd3b6b009e"
                                                                                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The last line (you'll have to scroll to the right in the box) shows a PARTUUID code for device /dev/sda1 which looks to be of an incorrect format. It looks to me like a UUID code has slipped in there. I've highlighted the "error" in the box above using a block of carets.

HTH

PeterF

paulv
Posts: 563
Joined: Tue Jan 15, 2013 12:10 pm
Location: Netherlands

Re: STICKY: HOWTO: Move the filesystem to a USB stick/Drive

Tue Apr 28, 2020 1:42 pm

PeterF,
Thank you for bringing that up. When I updated the procedure recently, I took a shortcut and did not update the result of sudo blkid correctly. It was a mix of the old and the new.
It's fixed now.

Cheers,
paulv

messypotamia
Posts: 81
Joined: Tue Jan 27, 2015 12:12 am

Re: STICKY: HOWTO: Move the filesystem to a USB stick/Drive

Tue Apr 28, 2020 6:17 pm

IT NOW WORKS :D :D :D And here's what seems to have fixed it, but bottom line up front, for some reason that Pi4 running latest Buster lite does **NOT** like USB3 sticks., but I copied the UUIDPART(s) correctly, re-read everything an umpteenth time going back & forth between my files & the Sticky, and I'm sure it met the tutorial.
I can't quite put my finger on why it doesn't like usb3 (although when I went out in town shopping for a USB 2.0 short stick, and had a conversation with a computer store guy, I mentioned Debian Buster & USB3 booting, and he beat me to the words "it doesn't work", so it apparently isn't just me).
I did the same thing using a usb2 32G shorty (I like them, they don't stick out) brand I've never heard of, re-checked everything, rebooted w/ console plugged in, felt my BP rise, and it worked like a charm.
So it seems, subject to your all's comments, that it wasn't me this time, it was a problem with the stick I used. FWIW -- the one that didn't work was a USB3.1 SanDiskUltraFit 32G; the one that's in there working now is some brand I never heard of, "Intenso Micro Line 2.0 High Speed USB Drive".
I noticed something strange, maybe you will know why: the PARTUUIDs on the USB3.1 were very long, while the PARTUUIDs on the Intenso USB2.0 were short, e.g.,

Code: Select all

cat /etc/fstab
proc            /proc           proc    defaults          0       0
PARTUUID=29606f3c-01  /boot           vfat    defaults          0       2
PARTUUID=85e6416d-01  /               ext4    defaults,noatime  0       1
PARTUUID=85e6416d-02  /mnt/usbdata    ext4    defaults  0       1
Anyway it's working now. Thanks to all who input. //MP//

mxrider108
Posts: 7
Joined: Fri May 08, 2020 10:34 pm

Re: STICKY: HOWTO: Move the filesystem to a USB stick/Drive

Fri May 08, 2020 10:41 pm

I followed this guide exactly as it is written with my Pi 4 (Raspbian Buster lite) and a brand new SanDisk Extreme Pro USB stick (speedy SSD).

Everything works great... for a while :| I am able to boot up, SSH, reboot, etc. without any issues. But after several hours/days eventually I come back to see my Pi still on but not able to SSH, access any web servers, etc. The unit is still lit up and the USB drive is still lighting up as if it's being accessed. Plugging into a monitor via HDMI shows a black screen.

Any idea what's going on here? Happy to provide my cmdline and fstab files etc.

I tried fiddling with the /boot/config.txt flags, using a USB extension cable to make sure it wasn't getting too hot, etc. with no luck. I had no issues before when running off the SD card.

Thanks :geek:
Last edited by mxrider108 on Tue May 12, 2020 10:05 pm, edited 1 time in total.

messypotamia
Posts: 81
Joined: Tue Jan 27, 2015 12:12 am

Re: STICKY: HOWTO: Move the filesystem to a USB stick/Drive

Sat May 09, 2020 2:48 pm

But after several hours/days eventually I come back to see my Pi still on but not able to SSH, access any web servers, etc.
In my post earlier this subj, I noted my conclusion that the system does *not* work well with USB3.1. (I couldn't get mine to work at all) Check dmesg, messages, and syslog for anomalies. You probably don't have anything wrong with your setup files. Probably. The logs will give the best clue. You might have to find a USB2.0 32G stick, set it up on that (after you've done it a few times it goes really fast, in case you haven't noticed),
let it run, and see how that goes after a while. Mine works reliably, whereas it would never finish even booting with the USB3.1 stick I had in there.

mxrider108
Posts: 7
Joined: Fri May 08, 2020 10:34 pm

Re: STICKY: HOWTO: Move the filesystem to a USB stick/Drive

Mon May 11, 2020 6:23 pm

messypotamia,

Thanks for the reply. One question: how do I read the

Code: Select all

dmesg
logs if I can't even SSH or access the system anymore? On reboot those logs seem to be gone. :roll: Edit: I'm going to try running the PI off the SD card with the USB 3.1 device just mounted to the filesystem as a normal external drive, and then see if it will eventually trigger the issue so I can actually check dmesg without the system crashing as well.

Very sad to hear that USB 3.1 doesn't work well with the PI 4... I wonder if doing something like the quirks mode described in this sticky would potentially help resolve the issue? I haven't tried that yet.

I also have a powered USB hub coming via Amazon as I've read a few places mentioning USB flakiness could be due to the amount of power needed... I would assume a solid state flash drive would not exceed limits, but I figure it's worth a shot.

Question for the thread: has anyone else experienced issues with USB 3.1? If so is there any way to force the 3.1 device to operate via USB 3 or USB 2 instead?

messypotamia
Posts: 81
Joined: Tue Jan 27, 2015 12:12 am

Re: STICKY: HOWTO: Move the filesystem to a USB stick/Drive

Mon May 11, 2020 7:43 pm

There were a few times I had to take the sd card out and edit cmdline.txt to move around the cmdline.usb /.txt /.sd, reboot, try something else, until I finally did the whole thing over again (I had it memorized by then -- didn't have to refer to the tutorial once) using a USB2.0 32G stick. It worked perfectly.
The 3.1 *might* work as a secondary file system, i.e. /data file system for whatever, but I don't feel like trying it.
Out here.

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

Re: STICKY: HOWTO: Move the filesystem to a USB stick/Drive

Mon May 11, 2020 8:10 pm

mxrider108 wrote:
Mon May 11, 2020 6:23 pm
Question for the thread: has anyone else experienced issues with USB 3.1?

I've been using these USB 3.1 flash drives to boot Raspberry Pi's (1/2/3/4) for 1.5+ years without any problems whatsoever using usb-boot:

https://www.amazon.com/Samsung-BAR-Plus ... 07BPKKYHY/

mxrider108
Posts: 7
Joined: Fri May 08, 2020 10:34 pm

Re: STICKY: HOWTO: Move the filesystem to a USB stick/Drive

Mon May 11, 2020 8:19 pm

Thanks - if I already have followed the directions in the OP of this thread could I easily run usb-boot without wiping my USB raspbian install? If so, what would be the difference?
Last edited by mxrider108 on Mon May 11, 2020 8:59 pm, edited 1 time in total.

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

Re: STICKY: HOWTO: Move the filesystem to a USB stick/Drive

Mon May 11, 2020 8:33 pm

mxrider108 wrote:
Mon May 11, 2020 8:19 pm
Thanks - if I already have followed the directions in the OP of this thread could I easily run usb-boot without wiping my USB raspian install?

Unfortunately, the directions in this thread creates a non-standard Raspbian partition layout (which means it almost certainly won't be usable when the Raspberry Pi 4 has native USB capability). As such, it cannot be used with usb-boot either.

mxrider108
Posts: 7
Joined: Fri May 08, 2020 10:34 pm

Re: STICKY: HOWTO: Move the filesystem to a USB stick/Drive

Tue May 12, 2020 6:01 pm

Just as an update: I've been running the PI off the SD card with the USB 3.1 device mounted to the filesystem as a normal external drive overnight and it has not triggered any issues (dmesg is clean as well).

Normally when running as the boot filesystem it will happen within hours.

Perhaps because I'm not reading/writing to the USB drive as much it's not triggering the error?

Not sure what to do next to resolve this issue :?

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

Re: STICKY: HOWTO: Move the filesystem to a USB stick/Drive

Tue May 12, 2020 7:01 pm

mxrider108 wrote:
Tue May 12, 2020 6:01 pm
Not sure what to do next to resolve this issue :?

Have you tried the latest VL805 firmware?:

Raspberry Pi 4 VL805 firmware release 0138a1

Code: Select all

root@raspberrypi:~# rpi-eeprom-update
BCM2711 detected
BOOTLOADER: up-to-date
CURRENT: Thu 16 Apr 17:11:26 UTC 2020 (1587057086)
 LATEST: Thu 16 Apr 17:11:26 UTC 2020 (1587057086)
 FW DIR: /lib/firmware/raspberrypi/bootloader/critical
VL805: up-to-date
CURRENT: 000138a1
 LATEST: 000137ad

mxrider108
Posts: 7
Joined: Fri May 08, 2020 10:34 pm

Re: STICKY: HOWTO: Move the filesystem to a USB stick/Drive

Tue May 12, 2020 10:04 pm

RonR wrote:
Tue May 12, 2020 7:01 pm
Have you tried the latest VL805 firmware?:

Raspberry Pi 4 VL805 firmware release 0138a1

Code: Select all

root@raspberrypi:~# rpi-eeprom-update
BCM2711 detected
BOOTLOADER: up-to-date
CURRENT: Thu 16 Apr 17:11:26 UTC 2020 (1587057086)
 LATEST: Thu 16 Apr 17:11:26 UTC 2020 (1587057086)
 FW DIR: /lib/firmware/raspberrypi/bootloader/critical
VL805: up-to-date
CURRENT: 000138a1
 LATEST: 000137ad
Just tried it and it says I was already up to date.

Code: Select all

BCM2711 detected
BOOTLOADER: up-to-date
CURRENT: Thu 16 Apr 17:11:26 UTC 2020 (1587057086)
 LATEST: Thu 16 Apr 17:11:26 UTC 2020 (1587057086)
 FW DIR: /lib/firmware/raspberrypi/bootloader/critical
VL805: up-to-date
CURRENT: 000137ad
 LATEST: 000137ad
 

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

Re: STICKY: HOWTO: Move the filesystem to a USB stick/Drive

Tue May 12, 2020 10:10 pm

mxrider108 wrote:
Tue May 12, 2020 10:04 pm
Just tried it and it says I was already up to date.

You didn't follow the instructions. If you did, you would see:

VL805: up-to-date
CURRENT: 000138a1

instead of:

VL805: up-to-date
CURRENT: 000137ad

mxrider108
Posts: 7
Joined: Fri May 08, 2020 10:34 pm

Re: STICKY: HOWTO: Move the filesystem to a USB stick/Drive

Tue May 12, 2020 10:31 pm

Apologies. got ahead of myself and didn't read closely. I've now flashed the new eeprom correctly. Will report back once I get a chance to test more. Thanks again!

Code: Select all

BCM2711 detected
BOOTLOADER: up-to-date
CURRENT: Thu 16 Apr 17:11:26 UTC 2020 (1587057086)
 LATEST: Thu 16 Apr 17:11:26 UTC 2020 (1587057086)
 FW DIR: /lib/firmware/raspberrypi/bootloader/critical
VL805: up-to-date
CURRENT: 000138a1
 LATEST: 000137ad
 

gkreidl
Posts: 6307
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: STICKY: HOWTO: Move the filesystem to a USB stick/Drive

Wed May 13, 2020 6:54 am

RonR wrote:
Mon May 11, 2020 8:33 pm
Unfortunately, the directions in this thread creates a non-standard Raspbian partition layout (which means it almost certainly won't be usable when the Raspberry Pi 4 has native USB capability). As such, it cannot be used with usb-boot either.
This tutorial serves exactly what it was supposed to do: describe a method to move the root file system to an external USB device while keeping the boot sector on the SD card. This method works for all RPi models independent from any USB-Boot feature. It has been published in 2013 and could be used on Wheezy, Jessie, Stretch and Buster. It received a lot of edits and was always kept up to date.

And it is a good tutorial (and rightfully became a sticky), because it doesn't simpy say "do this, do that ..." but explains every single step. This is for people who prefer to know and understand what they are doing and really want to learn something (which is the main reason why the RPi was created).

Nobody has kept you from publishing your scripted solution and there may be a lot of people who like to use it. But you should really stop hijacking this thread to promote your solution.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

paulv
Posts: 563
Joined: Tue Jan 15, 2013 12:10 pm
Location: Netherlands

Re: STICKY: HOWTO: Move the filesystem to a USB stick/Drive

Wed May 13, 2020 11:26 am

Thank you gkreidl for stepping in and setting the record straight.

mxrider108
Posts: 7
Joined: Fri May 08, 2020 10:34 pm

Re: STICKY: HOWTO: Move the filesystem to a USB stick/Drive

Thu May 14, 2020 6:45 pm

Update: new eeprom did not resolve the issue. Running via SD card (even with USB device mounted) has no issues, but after I reboot with USB as the root mount point I eventually run into a bad state (no SSH, no web servers, no HDMI output) after about ~12 hours.

DouglasBremer
Posts: 25
Joined: Mon Oct 30, 2017 11:17 pm

Re: STICKY: HOWTO: Move the filesystem to a USB stick/Drive

Sun May 17, 2020 4:18 am

I've been running the filesystem on USB hard disk drives for both Raspberry Pi and Banana Pi for years. It's a real good way to go.
My notes are a bit different and I'll share them here. They work with Raspian versions Jessie up to Buster.
1. Download the iso file from here. You can pick any version. http://downloads.raspberrypi.org/raspbian/images/
2. Download imager.exe from here. http://downloads.raspberrypi.org/imager/
3. Run imager.exe and load the iso on a SD card.
4. Run imager.exe and load the iso on the USB hard disk drive.
5. Edit cmdline.txt on the SD card and change root=/dev/mmcblk0p2 to root=/dev/sda2 (This edit is the meat-and-potatoes of the process)
6. Insert the SD card and connect the USB hard disk drive and boot the system.
That's it. The operating system is running off the hard disk drive.
The next step I do after completing the install is to install gparted and either resize /dev/sda2 paritition, or create a new partition.
# sudo apt-get update
# sudo apt-get upgrade
# sudo apt-get install gparted
Gparted is a GUI partition tool and a shortcut will be created in the Start menu.
Start - System Tools - Gparted
Resize the partition /dev/sda2 to utilize the full size of the drive. This is the simple way to go and doesn't require any additional steps.

If you create a new partition, then perform these additional steps.
7. Use Gparted and create a new partition on the hard disk drive's free space. Gparted will assign the name /dev/sda3.
a) Leave the [Partition Name] field blank, but in the field [Label] give it a name. I use "data." (without the quotes)
8. Edit /etc/fstab and create a mount for the new partition.
Use the command # sudo nano /etc/fstab and enter the following line: (use Ctrl-X to exit, saying Y to save changes)
/dev/sda3 /media/data ext4 defaults 0 0
9. Create the folder for the mount
# sudo mkdir /media/data
You're done. Reboot the system

Going a bit further, I create a partition for swap file. Size the partition twice the size of your desired swap file. I use 2048 for a swap file size 1024. Create the swap partition using the same steps above. It will be /dev/sda4. You'll also need to add a new line in /etc/fstab to mount it in the /media/swap folder. Don't forget to create the folder (# sudo mkdir /media/swap)
/dev/sda4 /media/swap ext4 defaults 0 0
10. Setup the swapfile using the following commands.
# sudo dphys-swapfile swapoff (this turns the swapfile off)
# sudo nano /etc/dphys-swapfile (you will edit the swapfile configuration file and make two changes)
CONF_SWAPFILE= /media/swap/swap
CONF_SWAPSIZE=1024 (use Ctrl-X to exit, saying Y to save changes)
# sudo dphys-swapfile setup (this command sets up the swap file)
# sudo dphys-swapfile swapon (this command starts the swapfile)

User avatar
procount
Posts: 2209
Joined: Thu Jun 27, 2013 12:32 pm
Location: UK

Re: STICKY: HOWTO: Move the filesystem to a USB stick/Drive

Sun May 17, 2020 9:33 am

DouglasBremer wrote:
Sun May 17, 2020 4:18 am
My notes are a bit different and I'll share them here. They work with Raspian versions Jessie up to Buster.
For the majority of users this may work fine. However, there are some caveats to this method which will catch some people out.

1. Referencing your USB drive as /dev/sda only works if you only have 1 USB drive attached.
If you have 2 USB drives attached, one will be called /dev/sda and the other /dev/sdb - but which one is which?
The OS assigns these names according to which one starts up first, so it is not deterministic. Maybe 90% of the time they will be assigned in the correct order, but the other 10% of the time, your system won't boot because the wrong drive will be labelled /dev/sda. A quick reboot might help and uers will shrug their shoulders and carry on, thinking it was just a glitch.
For deterministic behaviour, you should reference the PARTUIID of the partition instead, since this will be consistent. It will also be unique (unless you have cloned a disk and not assigned it a new set of PARTUIIDS).

2. For a more general solution, you should also check the /etc/fstab file. Any /dev/sdX devices here should also be converted to appropriate PARTUUID references to ensure that the correct partitions are used. The OS uses this file to determine which drives to mount. If the root partition on here is still referencing /dev/mmcblk0p2, then you might think you are running on the USB drive, but actually you are still using the SD card. Most of the time, this may be fine, but for some users or OSes, this might be a problem.
Worse is if the boot partition in here is mapped to a different drive to the one that was actually used to boot. After an full OS upgrade, you may find the root partition has been updated along with the incorrect boot partition. So on the next boot the new kernel will not match the kernel modules on the root partition and it will not boot properly, possibly ending in a kernel panic.

So like I said, for the majority of users using Raspbian, this will work fine. But just be aware of the pitfalls, especially if it is used more generally to other OSes.
NOTE: some OSes use the partition labels instead of PARTUUIDs to mount the correct partitions (which means you can't multboot them) and still others use UUIDs. Like most things in Linux - there's usually more than one way to do things, which makes creating a general solution very difficult.
PINN - NOOBS with the extras... https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=142574

DouglasBremer
Posts: 25
Joined: Mon Oct 30, 2017 11:17 pm

Re: STICKY: HOWTO: Move the filesystem to a USB stick/Drive

Sun May 17, 2020 2:34 pm

Thanks for adding your comments; they help clear up a possible problem if two hard disk drives are used instead of one.

The Raspberry Pi4 with Gig ethernet, USB 3.0, and a hard disk drive makes a great file-server. Here are two of my file-servers that are installed in my pantry. The one on the right is a Banana Pi that's been running since 2016, 24/7/365. The Raspberry Pi 4 on the left is it's replacement and will take over the rolls as file-server, web-server, ftp-server, music-server, movie-server, and MySql server.

These are wonderful computers!

Image
Image
Image

Return to “Advanced users”