0

I have an external SSD drive, with a Linux installation on partition 1, the EFI boot is partition 2.

There is also a second Linux installation on partition 3, that I never use.

Then there are two partition for two different live systems on ext4 partitions: 4 and 5.

Grub search grub.cfg on the first partition, then search for custom.cfg and custom2.cfg still on the same partition, in the directory /boot/grub/.

custom.cfg have a menu entry that set the root partition to hd1,gpt4.

custom2.cfg have a menu entry that set the root partition to hd1,gpt5.

The problem is when I try to boot custom2.cfg menu entry, it boots the live system on hd1,gpt4 instead of hd1,gpt5.

Here is the /etc/grub.d/41_custom that create the end of grub.cfg:

#!/bin/sh
cat <<EOF

search --no-floppy --fs-uuid --set=prefix1 --hint-bios=hd1,gpt1 --hint-efi=hd1,gpt1 --hint-baremetal=ahci1,gpt1  4787b339-ad49-4744-8d9a-9f0e95b78af2

if [ -f  \${config_directory}/custom.cfg ]; then
  source \${config_directory}/custom.cfg
elif [ -z "\${config_directory}" -a -f  \$prefix1/custom.cfg ]; then
  source \$prefix1/custom.cfg
fi
if [ -f  \${config_directory}/custom2.cfg ]; then
  source \${config_directory}/custom2.cfg
elif [ -z "\${config_directory}" -a -f  \$prefix1/custom2.cfg ]; then
  source \$prefix1/custom2.cfg
fi
EOF

here is custom.cfg:

# Live boot
menuentry "Live system (amd64) toram sda4" {
    search.fs_uuid 7f492729-d71b-4811-80e1-13a9e7943cf6 root hd1,gpt4
    linux   /live/vmlinuz toram=filesystem.squashfs boot=live components quiet 
    initrd  /live/initrd.img
}

here is custom2.cfg:

# Live boot
menuentry "Live system (amd64) toram sda5" {
    search.fs_uuid be7cf5ce-ac26-41ee-bf26-3c1f10f0521a root hd1,gpt5
    linux   /live/vmlinuz toram=filesystem.squashfs boot=live modprobe.blacklist=nouveau components quiet
    initrd  /live/initrd.img
}

I tried, in the boot menu, to edit these entries by pressing e, and it shows the correct entries.

Also, the result of blkid command:

/dev/sdb1: LABEL="LINUX1" UUID="4787b339-ad49-4744-8d9a-9f0e95b78af2" BLOCK_SIZE="4096" TYPE="ext4" PARTLABEL="LINUX1" PARTUUID="b43aa19d-ad07-4fe9-ba0c-dec43cb11e79"
/dev/sdb2: UUID="4C68-92D0" BLOCK_SIZE="512" TYPE="vfat" PARTUUID="ea5e7013-fe47-49c1-a2f7-abd1cb9b790f"
/dev/sdb3: LABEL="LINUX2" UUID="5afc0ee0-ac59-4c59-985f-2ab8107a0d82" BLOCK_SIZE="4096" TYPE="ext4" PARTLABEL="LINUX2" PARTUUID="035360f4-7634-4d24-8900-0f9ada81c709"
/dev/sdb4: LABEL="LIVE" UUID="7f492729-d71b-4811-80e1-13a9e7943cf6" BLOCK_SIZE="4096" TYPE="ext4" PARTLABEL="LIVE" PARTUUID="a7b77431-a1b8-487d-80d2-8ef09b7add0f"
/dev/loop0: TYPE="squashfs"
/dev/sdb5: LABEL="LIVE2" UUID="be7cf5ce-ac26-41ee-bf26-3c1f10f0521a" BLOCK_SIZE="4096" TYPE="ext4" PARTLABEL="LIVE2" PARTUUID="d77ffe57-e841-4890-938c-6d1997a96332"
/dev/sda: PTUUID="a6f73218-8327-45b9-981c-bae22eeb475c" PTTYPE="gpt"

So I wonder why grub boots hd1,gpt4 instead of hd1,gpt5 ?

1
  • I use grub2's loop mount to boot ISO directly. But my entry for hd1 does not work when I plug in an external drive. I have t manually change entry as I boot to hd2. Or create different entries. I prefer just to add entries directly into 40_custom or have one entry in 40_custom that refers to a custom.cfg or ESP grub. examples from cavfan ubuntuforums.org/… Using 40_custom & Custom menu help.ubuntu.com/community/Grub2/CustomMenus
    – oldfred
    Commented Mar 7 at 2:55

1 Answer 1

0

Grub was searching the kernel and initrd on the good partition. But the initrd was searching for a live system on the drives, and stops on the first it has read.

So the initrd of the live system was always loading the filesystem.squashfs found on /dev/sdb4.

The problem is solved with a kernel parameter specifying the live system partition:

live-media=/dev/sdb4

for my first live system, and:

live-media=/dev/sdb5

for my second live system.

The systems are on sdb, because they are installed on an external usb drive.

My grub entries for the live systems look like:

menuentry "sdb4 Live system (amd64) toram" {
    search.fs_uuid 7f492729-d71b-4811-80e1-13a9e7943cf6 root hd1,gpt4
    linux /live/vmlinuz live-media=/dev/sdb4 toram=filesystem.squashfs boot=live components quiet 
    initrd /live/initrd.img
}

menuentry "sdb5 Live system (amd64) toram" {
    search.fs_uuid be7cf5ce-ac26-41ee-bf26-3c1f10f0521a root hd1,gpt5
    linux /live/vmlinuz live-media=/dev/sdb5 toram=filesystem.squashfs boot=live components quiet 
    initrd /live/initrd.img
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .