Mo3tasm
Posts: 23
Joined: Thu Apr 07, 2016 12:56 pm

Can't USB boot (with SD card) anymore!

Sun Apr 16, 2017 12:31 pm

Hello

I've always used to flash Raspbian images to a USB flash drive and then copy boot partition to an SD card and point root file system in cmdline.txt as follows:
change "root=/dev/mmcblk0p2" to "root=/dev/sda2" so I can boot Raspbian from USB stick,

But, with the 2017-04-10 update, it becomes "root=PARTUUID=ff22455b-02" and changing it to "root=/dev/sda2" won't boot anymore. I'm using Raspberry pi 3 and don't really want to enable native USB boot mode.

I understand some changes were made to allow USB boot without SD card and that's great, but how can I boot now just like I did before?

Thanks.

User avatar
DougieLawson
Posts: 34096
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Can't USB boot (with SD card) anymore!

Sun Apr 16, 2017 12:36 pm

Get the PARTUUID from a sudo blkid command. Use that it's better than hard-coded /dev names.

The latest Raspbian uses that because it means an image that's dd'd or Etcher'd to a USB stick will just boot first go with no changes needed.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

Mo3tasm
Posts: 23
Joined: Thu Apr 07, 2016 12:56 pm

Re: Can't USB boot (with SD card) anymore!

Sun Apr 16, 2017 1:30 pm

So I didn't have to change anything =D...

Thank you so much.

User avatar
PeterO
Posts: 4257
Joined: Sun Jul 22, 2012 4:14 pm

Re: Can't USB boot (without SD card) anymore!

Sun Apr 16, 2017 2:32 pm

SDcard-less USB booting is also broken again....

With the boot and root partitions on an external USB hard disk 2017-04-10-raspbian-jessie is unbootable.

It stops trying to mount the root partition from the non-existat partition "root=PARTUUID=402e4a57-02" Now can this ever work ?
And if I put the correct UUID in there it still doesn't work.
The only way I've got further is to put "root=/dev/sda2" in there, and then the resize.sh script throws multiple syntax error, and complains it can't find "PARTUUID=402e4a57-02" Of course it can't... It doesn't exist !

Why Oh Why can't the boot process be left alone once it works. It seems every release brakes something :-(

PeterO :evil:
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),Aeromodelling,1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

User avatar
DougieLawson
Posts: 34096
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Can't USB boot (with SD card) anymore!

Sun Apr 16, 2017 2:34 pm

If you take a straight dd of the Raspbian 2017-04-10 image then it has the right blkid in /boot/cmdline.txt and /etc/fstab. It worked for me.

If you muck about with the blkid you'll need to update those two places.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

User avatar
PeterO
Posts: 4257
Joined: Sun Jul 22, 2012 4:14 pm

Re: Can't USB boot (with SD card) anymore!

Sun Apr 16, 2017 3:06 pm

DougieLawson wrote:If you take a straight dd of the Raspbian 2017-04-10 image then it has the right blkid in /boot/cmdline.txt and /etc/fstab. It worked for me.
I can't do that, it's a 1Tb disk that is already partitioned so I can hold latest and two previous releases in case the latest proves to be unbootable :roll: It's sooooo close to working so I've not given up hope yet though....

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),Aeromodelling,1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

User avatar
DougieLawson
Posts: 34096
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Can't USB boot (with SD card) anymore!

Sun Apr 16, 2017 3:34 pm

You can re-write the blkid (just don't try it with fdisk because it doesn't work).
I do it by copying the bootsector with dd count=1 bs=512, editing that with hexedit, then copying it back.

This http://www.linuxquestions.org/questions ... ost4088143 gives a much better way of writing 0xdeadbeef as the first eight bytes of the PARTUUID.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

User avatar
PeterO
Posts: 4257
Joined: Sun Jul 22, 2012 4:14 pm

Re: Can't USB boot (with SD card) anymore!

Sun Apr 16, 2017 3:49 pm

Ok, I have it working.

Obviously I had to remove the resizing stuff from cmdline.txt as that just failed to do the right thing when faced with something other than the default image written to an sdcard.

Seems that with an external USB hard disk, "root=UUID=xxxxxxxxxxxxxxxxxxxx" or "root=PARTUUID=xxxxx-xx" formats don't work in cmdline.txt. The only format I have found to work is "root=/dev/sda2"
but PARTUUID values do work in /etc/fstab.

PeterO

I'm not sure what is going on here.... I just gave it one last try with "root=PARTUUID=xxxxx-xx" and it worked ! Must have been some finger trouble somewhere in earlier tries (and yes I have got my reading glasses on :lol: )

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),Aeromodelling,1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

hommar
Posts: 144
Joined: Sat Mar 25, 2017 1:55 pm
Location: Russia, Yekaterinburg

Re: Can't USB boot (with SD card) anymore!

Sun Apr 16, 2017 4:10 pm

DougieLawson wrote:(just don't try it with fdisk because it doesn't work).

Code: Select all

$ sudo fdisk -l /dev/mmcblk0
....
Disk identifier: 0xcc00ffee
....
PARTUUID second partition is = cc00ffee-02
if you want change UUID то 0x1234abcd:

Code: Select all

$ sudo fdisk -l /dev/mmcblk0
x
i
0x1234abcd
r
w
then PARTUUID second partition is = 1234abcd-02

PS I test it on my RPi, it work
Last edited by hommar on Sun Apr 16, 2017 7:49 pm, edited 2 times in total.

User avatar
DougieLawson
Posts: 34096
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Can't USB boot (with SD card) anymore!

Sun Apr 16, 2017 7:02 pm

I had no success with fdisk, but a modified version (to generate a random id rather the 0xdeadbeef) of the program I found on the other forum works.

I've got five Raspberries with root filesystems on USB devices they use
root=UUID=2ebfb7f2-0c0b-4de2-964c-8fe9b20aacee
root=PARTUUID=0cf63fa8-02
root=PARTUUID=20a75729-06
root=PARTUUID=02532899-06
root=PARTUUID=2728eaec-06

All of the others use root=/dev/mmcblk0p2

I'll probably go round and change the other nine to use PARTUUID at some point in the near future.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

vinntec
Posts: 144
Joined: Thu Aug 02, 2012 9:37 am
Location: Basingstoke, UK

Re: Can't USB boot (with SD card) anymore!

Mon May 29, 2017 7:49 am

Hi Dougie

As you have clearly got this to work easily, please can you clarify if any special customisation is needed of the original Raspbian image once you have burned it to the USB HDD?

I have followed the official instructions on the blog (to set program_usb_boot_mode=1 and check it has taken etc). But do I need to change anything on the USB HDD copy of the latest Raspbian image (with second partition enlarged to fit available space) before I remove the mSD card and reboot? I am thinking of cmdline.txt & /etc/fstab on the HDD and their references to the mSD card - or does the USB boot change the USB HDD to have the same PARTUUID as in the original?

It doesn't work for me at the moment but I need to be sure I have everything setup how it should be.

Thanks in advance.

Peter

User avatar
DougieLawson
Posts: 34096
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Can't USB boot (with SD card) anymore!

Sat Jun 03, 2017 6:52 pm

None needed, nothing, zip, zilch, nada, rien.

Simply write the latest Raspbian 2017-04-10 to your USB device, boot once from an SDCard to set the OTP bit. Insert USB device, remove SDCard and you're done.

BTW, I'm hoping to be at the Roebuck PH for Southampton, Winchester, Andover and Basingstoke Pi Interest Group (SWABPiIG) in Winchester on 14th June @ 20:00 (day job permitting).
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

vinntec
Posts: 144
Joined: Thu Aug 02, 2012 9:37 am
Location: Basingstoke, UK

Re: Can't USB boot (with SD card) anymore!

Sat Jun 03, 2017 9:12 pm

DougieLawson wrote:None needed, nothing, zip, zilch, nada, rien.
Hi Dougie - I did try this but it booted fine from the HDD then hung unable to find the root. I got it to work eventually by pointing to /dev/sda2 in both /boot/cmdline.txt and /etc/fstab. I have a second RPi3 to setup with the same type of HDD so I will try that one as a vanilla installation and see if that works without any changes - it is possible that one or other of the things I tried messed things up the first time around.

User avatar
DougieLawson
Posts: 34096
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Can't USB boot (with SD card) anymore!

Sun Jun 04, 2017 6:20 am

If you drop NOOBS and stick with plain Raspbian then it should "just work" with no changes needed as long as the PARTUUID is set to "402e4a57".

Take a look with the blkid command.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

User avatar
rpdom
Posts: 12855
Joined: Sun May 06, 2012 5:17 am
Location: Ankh-Morpork

Re: Can't USB boot (with SD card) anymore!

Sun Jun 04, 2017 7:30 am

The problem that Dougie is ignoring is that the SD card and the hard disk will have the same PARTUUIDs.

User avatar
DougieLawson
Posts: 34096
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Can't USB boot (with SD card) anymore!

Sun Jun 04, 2017 8:41 am

rpdom wrote:The problem that Dougie is ignoring is that the SD card and the hard disk will have the same PARTUUIDs.
USB booting means removing the SDCard, it's not needed in a 3B.

In other Raspberries you need an SD with just bootcode.bin on a simple FAT partition (although with my B+ it needs a special version of bootcode.bin as the hard drive takes too long to spin up and won't spin up without max_usb_current=1).
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

vinntec
Posts: 144
Joined: Thu Aug 02, 2012 9:37 am
Location: Basingstoke, UK

Re: Can't USB boot (with SD card) anymore!

Sun Jun 04, 2017 9:10 am

DougieLawson wrote:If you drop NOOBS and stick with plain Raspbian then it should "just work" with no changes needed as long as the PARTUUID is set to "402e4a57".
Take a look with the blkid command.
Hi Dougie
If I do now with the RPi3 booted (using sda2) then I get
[email protected]:~ $ sudo blkid
/dev/sda1: LABEL="boot" UUID="95E0-9AC4" TYPE="vfat" PARTUUID="663d1468-01"
/dev/sda2: UUID="b105f9a8-f450-4976-8ac8-69053f57bab4" TYPE="ext4" PARTUUID="663d1468-02"
(without SUDO I get exactly the same)
If I boot from SD card unchanged with the HDD automounted I get:
[email protected]:~ $ sudo blkid
/dev/mmcblk0p1: LABEL="boot" UUID="95E0-9AC4" TYPE="vfat" PARTUUID="b4ea1f81-01"
/dev/mmcblk0p2: UUID="b105f9a8-f450-4976-8ac8-69053f57bab4" TYPE="ext4" PARTUUID="b4ea1f81-02"
/dev/mmcblk0: PTUUID="b4ea1f81" PTTYPE="dos"
/dev/sda1: LABEL="boot" UUID="95E0-9AC4" TYPE="vfat" PARTUUID="663d1468-01"
/dev/sda2: UUID="b105f9a8-f450-4976-8ac8-69053f57bab4" TYPE="ext4" PARTUUID="663d1468-02"
The original cmdline.txt says
root=PARTUUID=b4ea1f81-02
Oh my aching head!
Peter

vinntec
Posts: 144
Joined: Thu Aug 02, 2012 9:37 am
Location: Basingstoke, UK

Re: Can't USB boot (with SD card) anymore!

Sun Jun 04, 2017 9:20 am

By the way, I send an email to RPi about it and got the rather unhelpful reply
Please refer to GitHub issues for the documentation.
as I can't find this.

User avatar
DougieLawson
Posts: 34096
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Can't USB boot (with SD card) anymore!

Sun Jun 04, 2017 9:23 am

So you didn't create the USB bootable device with Etcher or Win32DiskImager or dd. That's why the partuuid is wrong.

What you need in fstab is

Code: Select all

PARTUUID=663d1468-01 /boot vfat defaults 0 2
PARTUUID=663d1468-02 / ext4 defaults,noatime 0 1
What you need in /boot/cmdline.txt is

Code: Select all

dwc_otg.lpm_enable=0 console=tty1 root=PARTUUID=663d1468-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles
And that should boot with no problems regardless of how the USB devices are enumerated.

Github docs at: https://github.com/raspberrypi/document ... des/msd.md

If they aren't correct open an issue at: https://github.com/raspberrypi/documentation/issues
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

vinntec
Posts: 144
Joined: Thu Aug 02, 2012 9:37 am
Location: Basingstoke, UK

Re: Can't USB boot (with SD card) anymore!

Sun Jun 04, 2017 9:32 am

Hi Dougie - the SD card was burned using Win32DiskImager. The img file was copied to a USB stick asis (on Windows) then copied to the HDD on the RPi using DD (sudo dd if=/media/pi/E47B-CBE8/2017-04-10-raspbian-jessie.img of=/dev/sda). Is it the copy to USB on Windows which is messing things up?

User avatar
DougieLawson
Posts: 34096
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Can't USB boot (with SD card) anymore!

Sun Jun 04, 2017 9:36 am

The latest Raspbian image file has the right stuff. The idea being that it's going to work on an SDCard, a USB stick or a USB hard (or SSD) drive.

Moving it from one device to another appears to have lost the PARTUUIDs which are stored in the MBR/partition table hence your troubles and the need to use blkid to discover the current values so you can fix things.

You could re-write the partition table, but that needs some serious hacking.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

vinntec
Posts: 144
Joined: Thu Aug 02, 2012 9:37 am
Location: Basingstoke, UK

Re: Can't USB boot (with SD card) anymore!

Sun Jun 04, 2017 11:34 am

Dougie - when you say the latest distribution do you mean 2017-04-10 as this is the one I used? If a newer one, which is the one to use and from where? Sorry if I'm being dozy!

User avatar
DougieLawson
Posts: 34096
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Can't USB boot (with SD card) anymore!

Sun Jun 04, 2017 11:49 am

Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

vinntec
Posts: 144
Joined: Thu Aug 02, 2012 9:37 am
Location: Basingstoke, UK

Re: Can't USB boot (with SD card) anymore!

Sun Jun 04, 2017 12:19 pm

Hi Dougie - OK that's the one I am using. I have reburned the HDD from Windows (Etcher wouldn't recognise it so I had to use Win32DiskImager) and it boots absolutely fine with no SD card inserted (and I know it's new as I forgot to put ssh file on there first time around as it is running headless). If I do blkid after booting I get
[email protected]:~ $ sudo blkid
/dev/sda1: LABEL="boot" UUID="95E0-9AC4" TYPE="vfat" PARTUUID="de478a7a-01"
/dev/sda2: UUID="b105f9a8-f450-4976-8ac8-69053f57bab4" TYPE="ext4" PARTUUID="de478a7a-02"
but it is working fine.
/boot/cmdline.txt says "root=PARTUUID=de478a7a-02" which matches, and /etc/ftab says
proc /proc proc defaults 0 0
PARTUUID=de478a7a-01 /boot vfat defaults 0 2
PARTUUID=de478a7a-02 / ext4 defaults,noatime 0 1
# a swapfile is not a swap partition, no line here
# use dphys-swapfile swap[on|off] for that
which also matches. I haven't touched either of them. So it must be something to do with copying the image on a running RPi which messes things up. Not sure I understand where these PARTUUIDs come from otherwise no problem.

User avatar
DougieLawson
Posts: 34096
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Can't USB boot (with SD card) anymore!

Sun Jun 04, 2017 6:42 pm

The root of the partition identifiers are in the partition table (first 512 bytes on a storage device).

Code: Select all

00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001b0  00 00 00 00 00 00 00 00  a8 3f f6 0c 00 00 00 82  |.........?......|
000001c0  03 00 0c 28 20 08 00 20  00 00 00 e0 01 00 00 00  |...( .. ........|
000001d0  01 40 83 3f e0 3f 00 00  02 00 00 00 b8 03 00 00  |[email protected]?.?..........|
000001e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
00000200
at offset == 0x1b8 to 0x1bb in reverse byte order.

Code: Select all

[email protected]:/tmp# blkid
/dev/sda1: SEC_TYPE="msdos" LABEL="boot" UUID="35ED-46FE" TYPE="vfat" PARTUUID="0cf63fa8-01"
/dev/sda2: UUID="443559ba-b80f-4fb6-99d9-ddbcd6138fbd" TYPE="ext4" PARTUUID="0cf63fa8-02"
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

Return to “Raspbian”