cyberfantome
Posts: 29
Joined: Thu Apr 17, 2014 8:18 pm

UUID vs /dev/sdx path

Thu Mar 19, 2015 1:58 pm

I am trying to move Rasbian to a USB HDD and mount via UUID in FSTAB and cmdline.txt. My HDD is is /dev/sda1 and /dev/sda2, the former being root and later being swap. If I mount my HDD

Code: Select all

mount /dev/sda1 /mnt
and edit fstab to reflect /dev/sdx I can boot to the HDD and get my swap to work after disabling the default swap file, etc.. However if I use

Code: Select all

sudo blkid
to get UUID's and replace /dev/sdax with UUID=blahblahblah for root and swap, upon reboot my system is dead. Note I have tried pointing /boot/cmdline.txt root=/dev/sda1 and root=UUID=blahblahblah but both result in a dead system. I have no monitor so don't know if it's throwing up a code.

Any ideas? I thought I read somewhere about using PARTUUID instead of UUID, is that my problem? I've read there are problems with mounting root long term to a /dev/sdx path because if the HDD is ever moved to another USB port it may change the sdax. Am I just making my own headache?

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

Re: UUID vs /dev/sdx path

Thu Mar 19, 2015 3:01 pm

1. Have you created an initramfs and added that to /boot/config.txt
mkinitramfs -o /boot/initrd

Code: Select all

initramfs initrd
2. Have you added rootdelay=5 (or rootdelay=10 if your drive takes longer to spin up) to /boot/cmdline.txt
3. Have you added UUID= to /boot/cmdline.txt

Code: Select all

dwc_otg.lpm_enable=0 console=tty1 root=UUID=xxxeeeyy-qbbp-4444-8888-f0f0f0f03333 rootfstype=ext4 elevator=deadline rootwait rootdelay=5
4. Have you added UUID= to /etc/fstab

Code: Select all

proc            /proc           proc    defaults          0       0
/dev/mmcblk0p1  /boot           vfat    defaults          0       2
#/dev/mmcblk0p2  /               ext4    defaults,noatime  0       1
UUID=xxxeeeyy-qbbp-4444-8888-f0f0f0f03333 /     ext4    defaults,noatime       0 1
5. Since it's a USB drive have you added

Code: Select all

max_usb_current=1
to /boot/config.txt

Using UUID is much better because it doesn't matter if the drive appears as /dev/sda, /dev/sdb or /dev/sdq it will still mount.
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

cyberfantome
Posts: 29
Joined: Thu Apr 17, 2014 8:18 pm

Re: UUID vs /dev/sdx path

Thu Mar 19, 2015 3:34 pm

1. No, I don't know what that does.
2. No. I assumed since when cmdline.txt and /etc/fstab point to /dev/sda that USB timeours were not an issue. Also I got this to work before but being the noob idiot I am, forgot to document my steps.
3. I have but have not tried doing it there and not in /etc/fstab.
4. Yes and after reboot it fails. But again, I did the same UUID= in cmdline.txt so maybe that is a problem? I've read some forums saying cmdline.txt only likes /dev/sdax.
5. No, my USB HDD is connected to a powered USB HDD and otherwise works until I got about editing cmdline.txt and /etc/fstab.

So perhaps I need educated on how to find the correct UUID to use in cmdline.txt and /etc/fstab. From gdisk I type i and then 1 for my first partition, root, and copy that UUID. Is that not the correct one to use in cmdline.txt and /etc/fstab?

DougieLawson wrote:1. Have you created an initramfs and added that to /boot/config.txt
mkinitramfs -o /boot/initrd

Code: Select all

initramfs initrd
2. Have you added rootdelay=5 (or rootdelay=10 if your drive takes longer to spin up) to /boot/cmdline.txt
3. Have you added UUID= to /boot/cmdline.txt

Code: Select all

dwc_otg.lpm_enable=0 console=tty1 root=UUID=xxxeeeyy-qbbp-4444-8888-f0f0f0f03333 rootfstype=ext4 elevator=deadline rootwait rootdelay=5
4. Have you added UUID= to /etc/fstab

Code: Select all

proc            /proc           proc    defaults          0       0
/dev/mmcblk0p1  /boot           vfat    defaults          0       2
#/dev/mmcblk0p2  /               ext4    defaults,noatime  0       1
UUID=xxxeeeyy-qbbp-4444-8888-f0f0f0f03333 /     ext4    defaults,noatime       0 1
5. Since it's a USB drive have you added

Code: Select all

max_usb_current=1
to /boot/config.txt

Using UUID is much better because it doesn't matter if the drive appears as /dev/sda, /dev/sdb or /dev/sdq it will still mount.

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

Re: UUID vs /dev/sdx path

Thu Mar 19, 2015 3:48 pm

So, run through my recipe and you should be able to get your hard drive running as your root filesystem.

It's working on my shiny new B+.
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

cyberfantome
Posts: 29
Joined: Thu Apr 17, 2014 8:18 pm

Re: UUID vs /dev/sdx path

Thu Mar 19, 2015 6:50 pm

DougieLawson wrote:So, run through my recipe and you should be able to get your hard drive running as your root filesystem.

It's working on my shiny new B+.
Ok just so we're on the same page, here is a sample of what gdisk shows of one of my partitions:

Code: Select all

GPT fdisk (gdisk) version 0.8.5

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): i
Partition number (1-2): 1
Partition GUID code: 0FC63DAF-8483-4772-8E79-3D69D8477DE4 (Linux filesystem)
Partition unique GUID: BD295BB6-64D2-8158-9EC7-37BD2265537F
First sector: 2048 (at 1024.0 KiB)
Last sector: 1949263838 (at 929.5 GiB)
Partition size: 1949261791 sectors (929.5 GiB)
Attribute flags: 0000000000000000
Partition name: 'Linux filesystem'

Command (? for help):
The Partition unique GUID is what I want to put in cmdline.txt and /etc/fstab correct? And I do that with root=UUID=xxxxx and UUID=xxxxx accordingly?

RobHenry
Posts: 452
Joined: Fri Sep 21, 2012 9:04 pm
Location: UK

Re: UUID vs /dev/sdx path

Thu Mar 19, 2015 7:07 pm

cyberfantome wrote:
DougieLawson wrote:So, run through my recipe and you should be able to get your hard drive running as your root filesystem.

It's working on my shiny new B+.
Ok just so we're on the same page, here is a sample of what gdisk shows of one of my partitions:

Code: Select all

GPT fdisk (gdisk) version 0.8.5

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): i
Partition number (1-2): 1
Partition GUID code: 0FC63DAF-8483-4772-8E79-3D69D8477DE4 (Linux filesystem)
Partition unique GUID: BD295BB6-64D2-8158-9EC7-37BD2265537F
First sector: 2048 (at 1024.0 KiB)
Last sector: 1949263838 (at 929.5 GiB)
Partition size: 1949261791 sectors (929.5 GiB)
Attribute flags: 0000000000000000
Partition name: 'Linux filesystem'

Command (? for help):
The Partition unique GUID is what I want to put in cmdline.txt and /etc/fstab correct? And I do that with root=UUID=xxxxx and UUID=xxxxx accordingly?
Use that with root=PARTUUID=

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

Re: UUID vs /dev/sdx path

Thu Mar 19, 2015 7:29 pm

I use
sudo blkid
to find the UUIDs and PARTUUIDs.
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

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

Re: UUID vs /dev/sdx path

Thu Mar 19, 2015 9:24 pm

Those UUIDs can be used as root=UUID= and in /etc/fstab UUID=

cmdline.txt

Code: Select all

dwc_otg.lpm_enable=0 console=tty1 root=UUID=f24a4949-f4b2-8cad-a780-a168695079ec rootfstype=ext4 elevator=deadline rootwait rootdelay=5
fstab

Code: Select all

proc            /proc           proc    defaults          0       0
/dev/mmcblk0p1  /boot           vfat    defaults          0       2
#/dev/mmcblk0p2  /               ext4    defaults,noatime  0       1
UUID=f24a4949-f4b2-8cad-a780-a168695079ec /     ext4    defaults,noatime       0 1
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

cyberfantome
Posts: 29
Joined: Thu Apr 17, 2014 8:18 pm

Re: UUID vs /dev/sdx path

Thu Mar 19, 2015 11:35 pm

And yet I fail again. I really dont get what I'm doing wrong.

blkid

Code: Select all

/dev/mmcblk0p1: SEC_TYPE="msdos" LABEL="boot" UUID="140A-14B7" TYPE="vfat"
/dev/mmcblk0p2: UUID="f24a4949-f4b2-4cad-a780-a138695079ec" TYPE="ext4"
/dev/sda1: UUID="f24a4949-f4b2-4cad-a780-a138695079ec" TYPE="ext4"
/dev/sda2: UUID="4b5dc4d9-756d-46ea-8952-bf30f7683b33" TYPE="swap"
cmdline.txt

Code: Select all

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=UUID=f24a4949-f4b2-4cad-a780-a138695079ec rootfstype=ext4 elevator=deadline rootwait rootdelay=5

fstab

Code: Select all

proc            /proc           proc    defaults          0       0
/dev/mmcblk0p1  /boot           vfat    defaults          0       2
#/dev/mmcblk0p2  /               ext4    defaults,noatime  0       1
UUID=f24a4949-f4b2-4cad-a780-a138695079ec / ext4 defaults,noatime 0 1
UUID=59ff3198-63bc-4363-8156-f7e066f57b33 none swap sw 0 0
DougieLawson wrote:Those UUIDs can be used as root=UUID= and in /etc/fstab UUID=

cmdline.txt

Code: Select all

dwc_otg.lpm_enable=0 console=tty1 root=UUID=f24a4949-f4b2-8cad-a780-a168695079ec rootfstype=ext4 elevator=deadline rootwait rootdelay=5
fstab

Code: Select all

proc            /proc           proc    defaults          0       0
/dev/mmcblk0p1  /boot           vfat    defaults          0       2
#/dev/mmcblk0p2  /               ext4    defaults,noatime  0       1
UUID=f24a4949-f4b2-8cad-a780-a168695079ec /     ext4    defaults,noatime       0 1

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

Re: UUID vs /dev/sdx path

Thu Mar 19, 2015 11:45 pm

Have you created a initramfs and added that to /boot/config.txt?
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

cyberfantome
Posts: 29
Joined: Thu Apr 17, 2014 8:18 pm

Re: UUID vs /dev/sdx path

Thu Mar 19, 2015 11:54 pm

I have gotten this to work before following http://www.raspberrypi.org/forums/viewt ... fs#p122476 only using gdisk instead of fdisk and UUID's instead of /dev/sdax.

I missed that when I scrolling back. What is that and what does it do?
DougieLawson wrote:Have you created a initramfs and added that to /boot/config.txt?

cyberfantome
Posts: 29
Joined: Thu Apr 17, 2014 8:18 pm

Re: UUID vs /dev/sdx path

Fri Mar 20, 2015 2:20 am

Got it! Use GUID from info in gdisk in /boot/cmdline.txt as root=PARTUUID=XXXXXXXX

While the UUID is used in /etc/fstab. That is from output of sudo blkid.

/dev/mmcblk0p1: SEC_TYPE="msdos" LABEL="boot" UUID="140A-14B7" TYPE="vfat"
/dev/mmcblk0p2: UUID="f24a4949-f4b2-4cad-a780-a138695079ec" TYPE="ext4"
/dev/sda1: UUID="f24a4949-f4b2-4cad-a780-a138695079ec" TYPE="ext4"
/dev/sda2: UUID="8094eff9-b5fc-4599-8390-2b3829351b3c" TYPE="swap"

Filesystem Size Used Avail Use% Mounted on
rootfs 915G 2.4G 866G 1% /
/dev/root 915G 2.4G 866G 1% /
devtmpfs 460M 0 460M 0% /dev
tmpfs 93M 228K 93M 1% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 596M 0 596M 0% /run/shm
/dev/mmcblk0p1 56M 15M 42M 26% /boot

Swap shows 2097128 total after disabling swap file and adding UUID for swap in fstab.

Man... I just could not get my mind wrapped around this. Thank you for your help DougieLawson. I'm kinda confused why the UUID is the same from my HD #1 and mmcblk0p2. Maybe because of the copying over data process? Anyways thanks again!

User avatar
rpdom
Posts: 14412
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: UUID vs /dev/sdx path

Fri Mar 20, 2015 6:26 am

cyberfantome wrote: I'm kinda confused why the UUID is the same from my HD #1 and mmcblk0p2. Maybe because of the copying over data process?
If you copied the data from your SD card to the USB device using "dd", then it would have copied the UUID with it.
It isn't good to have two partitions with the same UUID on a system. It can get very confusing and you could get the wrong one mounted.
I suggest you change the one you're not using in fstab and cmdline.txt. Assuming that is the one on /dev/mmcblk0p2, you could change it with

Code: Select all

sudo tune2fs -U random /dev/mmcblk0p2
That will generate a new random UUID.

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

Re: UUID vs /dev/sdx path

Fri Mar 20, 2015 8:48 am

Those UUIDs come from the RPF's Raspbian image. They're not unique because that's what I've got on my Raspbian images. Using tune2fs works for ext4. To do it for FAT partitions you need to muck about with dd and a hex editor.
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

cyberfantome
Posts: 29
Joined: Thu Apr 17, 2014 8:18 pm

Re: UUID vs /dev/sdx path

Fri Mar 20, 2015 2:31 pm

Is there a preferred way of copying mmcblk0p2 to sda1 other than DD to avoid this? If not, do I do this command after I've booted and running off my HDD or after I copy but before I reboot to use the HDD?
rpdom wrote:
cyberfantome wrote: I'm kinda confused why the UUID is the same from my HD #1 and mmcblk0p2. Maybe because of the copying over data process?
If you copied the data from your SD card to the USB device using "dd", then it would have copied the UUID with it.
It isn't good to have two partitions with the same UUID on a system. It can get very confusing and you could get the wrong one mounted.
I suggest you change the one you're not using in fstab and cmdline.txt. Assuming that is the one on /dev/mmcblk0p2, you could change it with

Code: Select all

sudo tune2fs -U random /dev/mmcblk0p2
That will generate a new random UUID.

cyberfantome
Posts: 29
Joined: Thu Apr 17, 2014 8:18 pm

Re: UUID vs /dev/sdx path

Fri Mar 20, 2015 3:54 pm

Ran the command after:

Code: Select all

sudo dd if=/dev/mmcblk0p2 of=/dev/sda1 bs=32M conv=noerror,sync
sudo e2fsck -f /dev/sda1
sudo resize2fs /dev/sda1
Then ran sudo sync and sudo shutdown -r now.
Works! Everything has a unique UUID. Thank you to both of you.

Return to “Troubleshooting”