Page 9 of 10

Re: Running Raspbian from USB Devices : Made Easy

Posted: Thu Jan 09, 2020 3:53 am
by Maze_fr
Here is my little testing...
As I "locked" my Pi with a bad docker bridge command line (I do network access), and I don't know what to modify manually (as an USB drive) to fix that, I decided to reset it, so I tried the modified script, and it worked perfectly. ;)

Re: Running Raspbian from USB Devices : Made Easy

Posted: Thu Jan 09, 2020 4:07 am
by RonR
Maze_fr wrote:
Thu Jan 09, 2020 3:53 am
As I "locked" my Pi with a bad docker bridge command line (I do network access), and I don't know what to modify manually (as an USB drive) to fix that, I decided to reset it, so I tried the modified script, and it worked perfectly. ;)

Thank you very much for the feedback. I'm so pleased we found the source of the problem and now have a solution.

Re: Running Raspbian from USB Devices : Made Easy

Posted: Fri Jan 10, 2020 10:49 pm
by r00t4rd3d
I have a StarTech USB 3.0 to SATA adapter hooked to a PNY 120gb SSD. I have the drive set up with 1 partition and formatted ext4. Shows up as sda1 under fdisk. When I run usb-boot I get this error:

Code: Select all

[email protected]:~/Desktop/usb-boot $ sudo ./usb-boot 

Replicating BOOT/ROOT contents from /dev/mmcblk0 to /dev/sda (this will take a while)
The file /dev/sda2 does not exist and no size was specified.

Unable to create ROOT filesystem
Anyone know how to fix this?

Re: Running Raspbian from USB Devices : Made Easy

Posted: Sat Jan 11, 2020 12:06 am
by RonR
r00t4rd3d wrote:
Fri Jan 10, 2020 10:49 pm

Code: Select all

[email protected]:~/Desktop/usb-boot $ sudo ./usb-boot 

Replicating BOOT/ROOT contents from /dev/mmcblk0 to /dev/sda (this will take a while)
The file /dev/sda2 does not exist and no size was specified.

Unable to create ROOT filesystem
Anyone know how to fix this?

This issue is discussed a few posts back. It's easily fixed by doing the following:

Edit (nano) usb-boot and change the first occurrence of:

Code: Select all

    fdisk "${USB_DEST}" <<EOF &> /dev/null

to

Code: Select all

    fdisk -c=dos "${USB_DEST}" <<EOF &> /dev/null

Re: Running Raspbian from USB Devices : Made Easy

Posted: Fri Jan 17, 2020 3:42 pm
by Qua294
Hi,
Sorry if it was answered already (I read the whole 9 pages but maye missed it) - how much a "while" can be when writing a 30GB USB flash drive?
I'm well over an hour now (buster lite version), with the RPi 3B green led flashing here and there, the USB drive led flashes all the time and the putty cursor is full green under the "Replicating BOOT/ROOT contents from /dev/mmcblk0 to /dev/sda (this will take a while)" line.
Will closing the putty session can damage something?
Is there a way to verify what is going on?
Thanks.

[Edit]
Apparently I needed to post in order to make it finish :D
It is now done and I can tell it takes well over an hour for 30GB :D :D

Re: Running Raspbian from USB Devices : Made Easy

Posted: Tue Jan 21, 2020 8:40 pm
by blazm
Hi,

Just a short note. I guess it is a good idea to create RAID1 array between boot partition on the SD card and boot partition on the USB HDD/SSD. This way the content of the drives is always in sync. Better than to mount only SD card partition as /boot; since using RAID:
- If SD card fails, you have the latest boot partition on the HDD/SSD.
- If SD card fails, you would probably get notified by the MD adm that syncing of the devices in RAID array failed and you could simple replace SD card with new one - without rebooting RPi and fixing issue offline.
- When USB boot is ready for RPi4, you will probably be able to boot right away from the boot partition on the HDD/SSD.
For now I just did a quick setup without any serious testing (apart from making sure RAID array is in sync - cat /proc/mdstat).

Enjoy,

Blaz

Re: Running Raspbian from USB Devices : Made Easy

Posted: Wed Jan 22, 2020 8:39 am
by Maze_fr
blazm wrote:
Tue Jan 21, 2020 8:40 pm
Just a short note. I guess it is a good idea to create RAID1 array between boot partition on the SD card and boot partition on the USB HDD/SSD.
That's a brilliant idea !
I was wondering how to do backups for the boot partition and that would solve it perfectly.

Re: Running Raspbian from USB Devices : Made Easy

Posted: Thu Jan 23, 2020 5:32 am
by RonR
Maze_fr wrote:
Wed Jan 22, 2020 8:39 am
blazm wrote:
Tue Jan 21, 2020 8:40 pm
Just a short note. I guess it is a good idea to create RAID1 array between boot partition on the SD card and boot partition on the USB HDD/SSD.
That's a brilliant idea !
I was wondering how to do backups for the boot partition and that would solve it perfectly.

While it's a trivial task to create and dissolve mirroring between the SD card's boot partition and SSD's boot partition, if you shutdown or reboot while mirroring is in effect, you're dead. When mirrored using mdadm, each partition by itself appears as filesystem type 'linux_raid_member' which neither Raspbian nor the Raspberry Pi bootloader can decipher.

Re: Running Raspbian from USB Devices : Made Easy

Posted: Thu Jan 23, 2020 11:16 pm
by RonR
usb-boot.zip in the first post of this topic has been updated to accommodate an issue with USB SSD/HDD adapters which use an ASMedia Technology Inc. controller. See recent posts to this topic for additional information.

Re: Running Raspbian from USB Devices : Made Easy

Posted: Sat Jan 25, 2020 3:08 am
by Jeepsterjc
Thanks for the script and updates. I've just run it on my pi4 using the Star Tech USB cable to a 1tb wd ssd. It ran without a hitch. How do I know it's actually running off of the SSD and not off the sdcard?

Re: Running Raspbian from USB Devices : Made Easy

Posted: Sat Jan 25, 2020 5:19 am
by RonR
Jeepsterjc wrote:
Sat Jan 25, 2020 3:08 am
How do I know it's actually running off of the SSD and not off the sdcard?

Run 'lsblk' and take note of the MOUNTPOINT column:

Code: Select all

NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda           8:0    0 465.8G  0 disk
├─sda1        8:1    0   256M  0 part
└─sda2        8:2    0 465.5G  0 part /
mmcblk0     179:0    0  14.9G  0 disk
├─mmcblk0p1 179:1    0   256M  0 part /boot
└─mmcblk0p2 179:2    0  14.6G  0 part

Re: Running Raspbian from USB Devices : Made Easy

Posted: Sat Jan 25, 2020 6:18 pm
by Jeepsterjc
RonR wrote:
Sat Jan 25, 2020 5:19 am
Jeepsterjc wrote:
Sat Jan 25, 2020 3:08 am
How do I know it's actually running off of the SSD and not off the sdcard?

Run 'lsblk' and take note of the MOUNTPOINT column:

Code: Select all

NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda           8:0    0 465.8G  0 disk
├─sda1        8:1    0   256M  0 part
└─sda2        8:2    0 465.5G  0 part /
mmcblk0     179:0    0  14.9G  0 disk
├─mmcblk0p1 179:1    0   256M  0 part /boot
└─mmcblk0p2 179:2    0  14.6G  0 part
Thank you.

Re: Running Raspbian from USB Devices : Made Easy

Posted: Mon Feb 10, 2020 12:02 pm
by carver1
RonR,
Just wanted to let you know that it there's now a potential bug in the commands

Code: Select all

sudo shutdown -r now
that you happen to use in your sdc-boot script (run as root) since the latest updates installed via apt update/full-upgrade or the newest 2020-02-05 Raspbian Buster with Desktop image on a RPI4.

I commented suddenly recently experiencing the same as the op on the same hardware, and that if I just change
"shutdown -r now"
to
"reboot"
and run "sudo src-boot <args>" it consistently reboots with no hard shutdowns as usual.

https://www.raspberrypi.org/forums/view ... 6&t=264518

And thanks for sharing usb-boot!

Re: Running Raspbian from USB Devices : Made Easy

Posted: Mon Feb 10, 2020 7:06 pm
by RonR
carver1 wrote:
Mon Feb 10, 2020 12:02 pm
Just wanted to let you know that it there's now a potential bug in the commands

Code: Select all

sudo shutdown -r now
that you happen to use in your sdc-boot script (run as root) since the latest updates installed via apt update/full-upgrade or the newest 2020-02-05 Raspbian Buster with Desktop image on a RPI4.

It appears there are several problems with the 2020-02-05 Raspbian Buster images (and the updates issued just prior to these images).

Until the Raspberry Pi folks sort it all out, the solution is to simply run:

Code: Select all

sudo rpi-update 993f475

See also:

https://www.raspberrypi.org/forums/view ... 6&t=264374

https://www.raspberrypi.org/forums/view ... 5#p1608966

Re: Running Raspbian from USB Devices : Made Easy

Posted: Wed Feb 19, 2020 6:18 pm
by JMKS
For me, it didn't go as planned :( (so far, at least). RPi4, so no direct USB boot.

My expectations:
given working system on SD, clone it to USB-HDD, set bootloader once, and "forget about it".

Reality:
after cloning and setting bootloader I booted from that config, updated system and set booting to CLI. Rebooted, and all I've got was the splash logo; nothing more.
Now I can't boot from SD/USB nor from SD card alone.
Additional issue: I have 5TB HDD, but it only created 2TB ext4 partition.

Is there some FAQ available, eg. "you can't update system to version X; you can't change raspi-config after cloning; you can fix unbootable situation by doing Y" etc.?
Now (after my own failure) I see this kind of info across this thread, but it's more anecdotal than precisely explained.

Re: Running Raspbian from USB Devices : Made Easy

Posted: Wed Feb 19, 2020 11:42 pm
by RonR
JMKS wrote:
Wed Feb 19, 2020 6:18 pm
For me, it didn't go as planned :( (so far, at least). RPi4, so no direct USB boot.
.
.
.
after cloning and setting bootloader I booted from that config, updated system and set booting to CLI. Rebooted, and all I've got was the splash logo; nothing more.

Please explain the exact steps you took, especially 'after cloning and setting bootloader I booted from that config, updated system and set booting to CLI.' After running usb-boot, simply rebooting should have had you up and running on the USB device. Updating Raspbian should not cause any problems (I do it daily here). I'm not aware of anyone else having problems.

Re: Running Raspbian from USB Devices : Made Easy

Posted: Fri Feb 21, 2020 8:42 am
by JMKS
As I remember it:
sudo ./usb-boot
sudo ./sdc-boot /dev/sda
reboot

Supposedly booted to correct SD + external-HDD configuration (I have not inspected it at that moment)
sudo apt-update && apt-upgrade
sudo raspi-config, then change some params, especially boot to CLI instead of GUI
reboot

not booting anymore :(, just splash logo.

Re: Running Raspbian from USB Devices : Made Easy

Posted: Fri Feb 21, 2020 8:56 am
by RonR
JMKS wrote:
Fri Feb 21, 2020 8:42 am
As I remember it:
sudo ./usb-boot
sudo ./sdc-boot /dev/sda
reboot

Supposedly booted to correct SD + external-HDD configuration (I have not inspected it at that moment)
sudo apt-update && apt-upgrade
sudo raspi-config, then change some params, especially boot to CLI instead of GUI
reboot

not booting anymore :(, just splash logo.

If you set boot to CLI instead of GUI, why do you expect the desktop to come up? Doesn't booting to CLI imply disabling the desktop? Have you tried to log in via SSH (i.e.the CLI)?

Re: Running Raspbian from USB Devices : Made Easy

Posted: Sun Feb 23, 2020 1:14 pm
by JMKS
Well, I definitely can differentiate "stuck at splash logo" (that multi-colored image at boot) vs. "logged-in CLI" with Bash, which I set to boot to. And it was the former.

Nevermind that bricked OS, I just want it to work for good.
What's the simplest guide to setting booting via USB, probably without having to clone OS from SD card?
As I see it, there could a NOOBS-like bootable image that writes full OS to USB-device & only bootloader to SD card (a few MB). Or, an image just for SD card with just bootloader, requiring additional step of manually writing OS directly to USB, just like with Pi3B.
Is there something like this (not necessarily that script from this thread)?

Re: Running Raspbian from USB Devices : Made Easy

Posted: Sun Feb 23, 2020 7:34 pm
by RonR
JMKS wrote:
Sun Feb 23, 2020 1:14 pm
What's the simplest guide to setting booting via USB, probably without having to clone OS from SD card?

I don't believe you're going to find anything simpler than usb-boot for booting from a USB device:

1. Boot the Raspberry Pi from an SD card as usual.

2. Run usb-boot.

3. Select the USB device you wish to boot to.

4. If that USB device does not already contain a Raspbian system you wish to use, select 'Yes' to 'Replicate BOOT/ROOT contents from /dev/mmcblk0 to /dev/sdX?. [ If you'd rather start with a fresh copy of Raspbian on the USB device, write it to the USB device with Etcher and answer 'No' to 'Replicate BOOT/ROOT contents from /dev/mmcblk0 to /dev/sdX?. ]

5. When usb-boot completes, reboot and verify that you're running from the USB device (run lsblk).

What could be simpler?

Re: Running Raspbian from USB Devices : Made Easy

Posted: Sun Feb 23, 2020 9:20 pm
by fbe
You should not use usb-boot if your USB drive has more than 2TB size. You need a GPT partition table to use more than 2TB on a drive.
usb-boot creates a boot partition on the target drive that may or may not be used for booting without SD card if your Raspberry Pi supports it.
A boot partition works only on a drive with MS-DOS (MBR) partition table.

You should not create a root file system with 2TB or even more size. By default the root filesystem is checked in certain intervalls while booting. If you have a huge filesystem it may look as if your Raspberry Pi stops booting if you are running a headless system or if the splash screen hides progress messages.

Re: Running Raspbian from USB Devices : Made Easy

Posted: Thu Mar 05, 2020 9:17 am
by royhenderson
@RonR - just ran your script on an RPi4 with a Samsung T5 SSD and it worked flawlessly. An extremely useful utility. Many thanks for developing and sharing!

Re: Running Raspbian from USB Devices : Made Easy

Posted: Thu Mar 05, 2020 9:21 am
by RonR
royhenderson wrote:
Thu Mar 05, 2020 9:17 am
@RonR - just ran your script on an RPi4 with a Samsung T5 SSD and it worked flawlessly. An extremely useful utility. Many thanks for developing and sharing!

I'm pleased to hear of your success.

Thanks for feedback.

Re: Running Raspbian from USB Devices : Made Easy

Posted: Thu Mar 05, 2020 10:33 am
by royhenderson
Just ran the script on a headless RPi4 with another Samsung T5 and again it worked perfectly.

It looks like the script automatically generates PARTUUIDs which (most probably) will be unique.

That's the behaviour I would want, is that assumption correct?

Re: Running Raspbian from USB Devices : Made Easy

Posted: Thu Mar 05, 2020 12:57 pm
by tw99
Thanks for the script, it worked fine on my rpi4, which is now happily working off a USB thumb drive that is quite a bit faster than the SD card.

The only issue I had was that my fstab included a line to mount another USB drive at /dev/sda , and at some point during the process, the device numbering changed so that drive became /dev/sdb. I just needed to change the fstab to use PARTUUID when mounting, to make this independent of device naming.