Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] Problem booting by LABEL or UUID
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
Tony0945
Advocate
Advocate


Joined: 25 Jul 2006
Posts: 3046
Location: Illinois, USA

PostPosted: Tue Feb 19, 2019 6:52 pm    Post subject: [SOLVED] Problem booting by LABEL or UUID Reply with quote

Following NeddySeagoon's suggestion in thread https://forums.gentoo.org/viewtopic-p-8311114.html#8311114 I switched /etc/fstab to LABEL/UUID and removed my dead/dying drive which had been /dev/sdb. However, upon reboot I had a kernel panic, so I switched the boot drive back to partition loading. I experimented with both partition 1 and partition 2 as labels, each separately and the only combo that boots - both as /dev/sdaX. If the root partition is by label I get a kernel panic, "can't find hd(0,0)". If I specify the EFI partition by label or UUID, I get different errors that fail to boot.

I am booting UEFI with reFind, no command line embedded in the kernel.
Code:
 ~ # cat /etc/fstab
# /etc/fstab: static file system information.
#
# noatime turns off atimes for increased performance (atimes normally aren't
# needed); notail increases performance of ReiserFS (at the expense of storage
# efficiency).  It's safe to drop the noatime options if you want and to
# switch between notail / tail freely.
#
# The root filesystem should have a pass number of either 0 or 1.
# All other filesystems should have a pass number of 0 or greater than 1.
#
# See the manpage fstab(5) for more information.
#

# <fs>         <mountpoint>   <type>      <opts>      <dump/pass>

# NOTE: If your BOOT partition is ReiserFS, add the notail option to opts.
#LABEL=CT250MX_EFI   /boot/efi   vfat      auto,noatime   1 2
#LABEL=CT250MX_PART2   /      ext4      defaults,noatime  0 1
#UUID=FBA3-4B271   /boot/efi   vfat      auto,noatime   1 2
/dev/sda1   /boot/efi   vfat      auto,noatime   1 2
/dev/sda2   /      ext4      defaults,noatime  0 1
LABEL=WD5001_PART2   /video      ext4      nofail,auto,relatime  0 1
#/swapfile   swap            swap            defaults        0 0
#/dev/sdb3   swap      swap      defaults   0 0
/dev/cdrom   /mnt/cdrom   auto      noauto,user,ro   0 0
#/dev/fd0   /mnt/floppy   auto      noauto,user   0 0
tmpfs      /var/tmp/portage    tmpfs       nofail,noatime,nr_inodes=1M,size=9G    0 0

Code:
~ # blkid
/dev/sdb1: UUID="5CCD-70BC" TYPE="vfat" PARTUUID="2323cc2b-de1a-493e-809d-0a8bc826cc48"
/dev/sdb2: LABEL="WD5001_PART2" UUID="0f5478cb-b4de-4566-9dde-cbe45ff14c7b" TYPE="ext4" PARTUUID="1397c372-cfc2-4cfd-9dd7-06b81a42ba6d"
/dev/sda1: LABEL_FATBOOT="CT250MX_EFI" LABEL="CT250MX_EFI" UUID="FBA3-4B27" TYPE="vfat" PARTUUID="16438771-d6bb-482a-ad34-a1c04d0363c7"
/dev/sda2: LABEL="CT250MX_PART2" UUID="8e5c906a-dc8d-49d4-952e-1c3d796308f8" TYPE="ext4" PARTUUID="280acabd-75cb-41f6-8322-a428a78bdf2a"
/dev/sr0: UUID="2018-04-02-13-43-43-00" LABEL="sysrcd-5.2.2" TYPE="iso9660"
Code:
~ # mount |grep /dev/sd
/dev/sda2 on / type ext4 (rw,noatime,data=ordered)
/dev/sda1 on /boot/efi type vfat (rw,noatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
/dev/sdb2 on /video type ext4 (rw,relatime,data=ordered)
Code:
 ~ # ls /dev/disk/by-label -l
total 0
lrwxrwxrwx 1 root root 10 Feb 19 12:13 CT250MX_EFI -> ../../sda1
lrwxrwxrwx 1 root root 10 Feb 19 12:13 CT250MX_PART2 -> ../../sda2
lrwxrwxrwx 1 root root 10 Feb 19 12:13 WD5001_PART2 -> ../../sdb2
lrwxrwxrwx 1 root root  9 Feb 19 12:13 sysrcd-5.2.2 -> ../../sr0
I have a second data drive on order, but then I will have two drives by label and the boot drive by /dev/sdaX. I want to go all the way or why bother?

Last edited by Tony0945 on Wed Feb 20, 2019 7:25 pm; edited 1 time in total
Back to top
View user's profile Send private message
Jaglover
Watchman
Watchman


Joined: 29 May 2005
Posts: 7081
Location: Saint Amant, Acadiana

PostPosted: Tue Feb 19, 2019 6:58 pm    Post subject: Reply with quote

To my knowledge you need to use PARTUUID in kernel command line, plain kernel without initrd won't handle Label/UUID. Labels are OK in fstab.
_________________
Please learn how to denote units correctly!
Back to top
View user's profile Send private message
Tony0945
Advocate
Advocate


Joined: 25 Jul 2006
Posts: 3046
Location: Illinois, USA

PostPosted: Tue Feb 19, 2019 7:40 pm    Post subject: Reply with quote

Jaglover wrote:
To my knowledge you need to use PARTUUID in kernel command line, plain kernel without initrd won't handle Label/UUID. Labels are OK in fstab.

fstab is the only place I put Labels/UUID. The kernel command line is blank. On another UEFU machine I built in to the kernel command line parameters including "roofs=/dev/sda2".
I was always amazed that this machine booted at all.
Back to top
View user's profile Send private message
Jaglover
Watchman
Watchman


Joined: 29 May 2005
Posts: 7081
Location: Saint Amant, Acadiana

PostPosted: Tue Feb 19, 2019 7:44 pm    Post subject: Reply with quote

Tony0945,

how could it possibly be blank? If there is no command line built into kernel then the bootloader must pass it.
_________________
Please learn how to denote units correctly!
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 5732

PostPosted: Tue Feb 19, 2019 8:21 pm    Post subject: Reply with quote

You have GPT PARTUUIDs available - it's a good idea to prefer those in fstab over any other option. /dev/disk/by-label is populated by udev, which isn't always an option in early boot.

Your kernel panic is nothing to do with that though, you'll need to figure out how to get refind to pass a correct root= to the kernel. I haven't used it myself, so can't really advise on that.
Back to top
View user's profile Send private message
Tony0945
Advocate
Advocate


Joined: 25 Jul 2006
Posts: 3046
Location: Illinois, USA

PostPosted: Tue Feb 19, 2019 10:52 pm    Post subject: Reply with quote

For this system in question:
Code:
gentoo ~ # cat /proc/cmdline
\boot\vmlinuz-4.14.98-gentoo ro root=/dev/sda2
# zgrep CONFIG_CMDLINE /proc/config.gz
# CONFIG_CMDLINE_PARTITION is not set
# CONFIG_CMDLINE_BOOL is not set

On the system with a command line built into the kernel:
Code:
 $ cat /proc/cmdline
root=/dev/sda2 vga=0x365 net.ifnames=0  \\boot\vmlinuz-4.14.98-gentoo BOOT_IMAGE=/isolinux/rescue64
$ zgrep CONFIG_CMDLINE /proc/config.gz
# CONFIG_CMDLINE_PARTITION is not set
CONFIG_CMDLINE_BOOL=y
CONFIG_CMDLINE="root=/dev/sda2 vga=0x365 net.ifnames=0 "
# CONFIG_CMDLINE_OVERRIDE is not set
Back to top
View user's profile Send private message
Tony0945
Advocate
Advocate


Joined: 25 Jul 2006
Posts: 3046
Location: Illinois, USA

PostPosted: Tue Feb 19, 2019 11:28 pm    Post subject: Reply with quote

BOOT_IMAGE in the prevous post is a red herring. The /boot directory still had grubs self link to /boot/boot. Eliminating that solved that.

If rEFInd can't find a refind_linux.conf file in the directory that holds the kernel, the program looks for a file called /etc/fstab on the partition that holds the kernel. If this standard Linux file is present, rEFInd uses it to identify the root (/) filesystem and creates two sets of Linux kernel boot options: One set launches the kernel normally, but with minimal options, and the other set launches the kernel into single-user mode. This step can get a computer to boot without any rEFInd-specific configuration files, aside from refind.conf in rEFInd's own directory, but only if /boot is not a separate partition. The intent is to facilitate the use of rEFInd as an emergency boot manager or to help users who must install rEFInd from OS X or Windows. Note that rEFInd uses /etc/fstab only if refind_linux.conf is not found.
If rEFInd can't find a refind_linux.conf file or an /etc/fstab file, it tries to identify the Linux root (/) filesystem by looking for a partition with a GUID type code matching that specified for the root (/) filesystem in the Freedesktop.org Discoverable Partitions Specification. These type codes are as yet seldom used, but if and when they become common, they should help a lot for situations similar to those of the preceding case, but when a separate /boot partition is used.

So rEFind actually reads the /etc/fstab file to find the boot partition. When that is "root=/dev/sda2" it passes that to the command line. When that is "LABEL=", the kernel doesn't understand it. It seems that PARTUUID may work. This still doesn't explain what the EFI partition has to be "dev/sdXY" though.
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 5732

PostPosted: Wed Feb 20, 2019 1:02 am    Post subject: Reply with quote

I didn't know rEFInd supported type-UUIDs. It's a long shot but that might be worth setting up too:

fdisk /dev/sda, i (info), 2 (partition 2) should tell you what type it is. The generic "Linux" partition type begins with 0FC63DAF.
You can change it with t2 which brings up a menu; the most appropriate one in this case is "Linux root (x86-64)" (4F68BCE3).

I don't think it's likely to fix it, but the more information you can give to the bootloader, the more chance there is everything'll just work.
Back to top
View user's profile Send private message
Tony0945
Advocate
Advocate


Joined: 25 Jul 2006
Posts: 3046
Location: Illinois, USA

PostPosted: Wed Feb 20, 2019 1:09 am    Post subject: Reply with quote

More about the kernel finding the root:

/usr/src/linux/init/do_mounts.c is interesting.
Code:
/*
 *  Convert a name into device number.  We accept the following variants:
 *
 *  1) <hex_major><hex_minor> device number in hexadecimal represents itself
 *         no leading 0x, for example b302.
 *  2) /dev/nfs represents Root_NFS (0xff)
 *  3) /dev/<disk_name> represents the device number of disk
 *  4) /dev/<disk_name><decimal> represents the device number
 *         of partition - device number of disk plus the partition number
 *  5) /dev/<disk_name>p<decimal> - same as the above, that form is
 *     used when disk name of partitioned disk ends on a digit.
 *  6) PARTUUID=00112233-4455-6677-8899-AABBCCDDEEFF representing the
 *     unique id of a partition if the partition table provides it.
 *     The UUID may be either an EFI/GPT UUID, or refer to an MSDOS
 *     partition using the format SSSSSSSS-PP, where SSSSSSSS is a zero-
 *     filled hex representation of the 32-bit "NT disk signature", and PP
 *     is a zero-filled hex representation of the 1-based partition number.
 *  7) PARTUUID=<UUID>/PARTNROFF=<int> to select a partition in relation to
 *     a partition with a known unique id.
 *  8) <major>:<minor> major and minor number of the device separated by
 *     a colon.
 *
 *  If name doesn't have fall into the categories above, we return (0,0).
 *  block_class is used to check if something is a disk name. If the disk
 *  name contains slashes, the device name has them replaced with
 *  bangs.
 */
Looking at the code, it looks like the label has to be of the form /dev/<something> or PARTUUID=<something>
So UUID= or LABEL= won't work for the kernel, although they obviously work for mounting after/during /bin/init
Back to top
View user's profile Send private message
Tony0945
Advocate
Advocate


Joined: 25 Jul 2006
Posts: 3046
Location: Illinois, USA

PostPosted: Wed Feb 20, 2019 3:29 am    Post subject: Reply with quote

Reading more at the Arch wiki, it seems there are two configuration files.

/boot/efi/EFI/refind/refind.conf is the file that configures refind itself, where it looks for kernels, how the menus are built and such.

/boot/refind_linux.conf configures the linux kernel command line. The first non-comment line is the default, any others are alternates reached by pressing the '+' key.
Each line has two strings. the first is the prompt. the second is the command line.

Code:
 $ cat /boot/refind_linux.conf
"Boot by /dev/sdXY"  "root=/dev/sda2 vga=0x365 net.ifnames=0  "
"Boot by PARTUUID"   "root=PARTUUID="54fee329-ff75-4879-bdbb-93268b470f32 vga=0x365 net.ifnames=0  "


The first works. The second doesn't. (kernel panic, can't find root partition) Have I made a syntax error?
Code:
 # blkid
/dev/sda1: UUID="DDE0-6A03" TYPE="vfat" PARTLABEL="EFI System" PARTUUID="6cc06059-07a5-450a-be59-c954bf6e846b"
/dev/sda2: LABEL="CT500MX_PART2" UUID="677edc9c-7acb-4b5c-be64-4fd1c174cf24" TYPE="ext4" PARTLABEL="Linux filesystem" PARTUUID="54fee329-ff75-4879-bdbb-93268b470f32"
/dev/sdb1: UUID="1aa86f01-1dd2-466a-b19b-57b2539f714e" TYPE="jfs" PARTUUID="06f452e6-01"
/dev/sr0: UUID="2017-07-29-07-50-20-00" LABEL="sysrcd-5.0.3" TYPE="iso9660"
Back to top
View user's profile Send private message
Jaglover
Watchman
Watchman


Joined: 29 May 2005
Posts: 7081
Location: Saint Amant, Acadiana

PostPosted: Wed Feb 20, 2019 4:40 am    Post subject: Reply with quote

PARTUUID="

What about that quotation mark?
_________________
Please learn how to denote units correctly!
Back to top
View user's profile Send private message
Tony0945
Advocate
Advocate


Joined: 25 Jul 2006
Posts: 3046
Location: Illinois, USA

PostPosted: Wed Feb 20, 2019 7:21 pm    Post subject: Reply with quote

Jaglover wrote:
PARTUUID="

What about that quotation mark?
THAT'S IT! Thank You!
I have both systems booting by PARTUUID now. It's unreadable but there is no confusion because I know the partition is on the same drive as refind.

Code:
$ cat /boot/refind_linux.conf
"Boot by PARTUUID"   "root=PARTUUID=54fee329-ff75-4879-bdbb-93268b470f32 vga=0x365 net.ifnames=0  "
"Boot by /dev/sdXn"  "root=/dev/sda2 vga=0x365 net.ifnames=0  "

and all references to dev/sd gone from /etc/fstab. I left /dev/sr0 because there is only one CD-ROM drive.
Code:
tony@MSI ~ $ grep -v ^# /etc/fstab


LABEL=CT500MX_EFI   /boot/efi    vfat      relatime   1 2
LABEL=CT500MX_PART2   /       ext4      relatime   0 1
PARTUUID=06f452e6-01   /video       jfs      auto,relatime   0 1
/dev/sr0      /mnt/cdrom    auto      user,noauto,nofail   0 0
tmpfs                   /var/tmp/portage tmpfs          nr_inodes=1M,size=12G 0 0
devpts                  /dev/pts         devpts         defaults        0 0

gentoo/video   /mnt/samba-gentoo   cifs   noauto,user=guest,password=none,ro   0 0
 

I applied the label to EFI partition with "fatlabel" from the dosfstools package. I left the video drive as PARTUUID because I don't know how to label a jfs, plus I want to replace that with an ext4 partition but I need another 2T or bigger drive to temporarily back it up.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum