Bug 1012118

Summary: grub2-mkconfig won't add encrypted root partition to grub.cfg's 30_os-prober section
Product: [Fedora] Fedora Reporter: Dean Nelson <dnelson>
Component: grub2Assignee: Peter Jones <pjones>
Status: CLOSED WONTFIX QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 20CC: bcl, dennis, ilmostro7, mads, pjones
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-03-28 13:17:56 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Dean Nelson 2013-09-25 18:34:58 UTC
Description of problem:

On my laptop I've got two encrypted / root partitions. One has f18 installed and the other has f19 installed. Running 'grub2-mkconfig -o /boot/grub2/grub.cfg' on the f19 kernel fails to add a menuentry for the f18 kernel to grub.cfg's 30_os-prober section.

f18's /boot is on sda1 and its / root is on sda2.
f19's /boot is on sda5 and its / root is on sda6.
Both / root partitions are encrypted (but they're not LVM partitions).
Partitions sda7 and sda8 are another /boot and / root which are currently unused. There is a shared swap partition on sda3 and a shared fs on sda9.

Before running grub2-mkconfig I did the following...

[root@teal ~]# blkid
/dev/sda1: UUID="d7829903-f49c-442f-b042-1eb9c00a1f4f" TYPE="ext4" 
/dev/sda2: UUID="42766e70-9c38-4660-885d-d233bb69fe30" TYPE="crypto_LUKS" 
/dev/sda3: UUID="6ab885f5-6189-4652-a3ba-c72d0733b4b7" TYPE="swap" 
/dev/sda5: UUID="cc8bf5fe-3f41-4dc7-a227-706a805464d1" TYPE="ext4" 
/dev/sda6: UUID="663c9b60-9053-4330-845e-5d1e52108b10" TYPE="crypto_LUKS" 
/dev/sda7: UUID="79b66197-f6c6-4545-87ce-545a114d1f44" TYPE="ext4" 
/dev/sda8: UUID="bc7fa838-4418-47e6-8370-084b379ffcf7" TYPE="ext4" 
/dev/sda9: UUID="88768e27-4fef-4d2f-bde9-46dcb42fcdc0" TYPE="ext4" 
/dev/mapper/luks-663c9b60-9053-4330-845e-5d1e52108b10: UUID="f2de7132-1eae-4800-96b8-f25c6cdd347b" TYPE="ext4" 
[root@teal ~]# ls

[root@teal ~]# cryptsetup luksOpen /dev/sda2 luks-42766e70-9c38-4660-885d-d233bb69fe30
Enter passphrase for /dev/sda2: 
[root@teal ~]#

[root@teal ~]#  parted -l
Model: ATA TOSHIBA MK5061GS (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type      File system     Flags
 1      1049kB  263MB   262MB   primary   ext4            boot
 2      263MB   46.5GB  46.2GB  primary
 3      46.5GB  63.3GB  16.8GB  primary   linux-swap(v1)
 4      63.3GB  500GB   437GB   extended
 5      63.3GB  63.5GB  262MB   logical   ext4
 6      63.5GB  110GB   46.2GB  logical
 7      110GB   110GB   262MB   logical   ext4
 8      110GB   156GB   46.2GB  logical   ext4
 9      156GB   500GB   344GB   logical   ext4


Model: Linux device-mapper (crypt) (dm)
Disk /dev/mapper/luks-42766e70-9c38-4660-885d-d233bb69fe30: 46.2GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags: 

Number  Start  End     Size    File system  Flags
 1      0.00B  46.2GB  46.2GB  ext4


Model: Linux device-mapper (crypt) (dm)
Disk /dev/mapper/luks-663c9b60-9053-4330-845e-5d1e52108b10: 46.2GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags: 

Number  Start  End     Size    File system  Flags
 1      0.00B  46.2GB  46.2GB  ext4


[root@teal ~]#

[root@teal ~]# ls /mnt/dev-sda2/
[root@teal ~]# mount /dev/mapper/luks-42766e70-9c38-4660-885d-d233bb69fe30 /mnt/dev-sda2
[root@teal ~]# ls /mnt/dev-sda2/
bin  boot  dev  etc  home  lib  lib64  lost+found  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
[root@teal ~]#

[root@teal ~]# grub2-mkconfig -o /boot/grub2/grub.cfg 
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.11.1-200.fc19.x86_64
Found initrd image: /boot/initramfs-3.11.1-200.fc19.x86_64.img
Found linux image: /boot/vmlinuz-3.10.11-200.fc19.x86_64
Found initrd image: /boot/initramfs-3.10.11-200.fc19.x86_64.img
Found linux image: /boot/vmlinuz-3.10.10-200.fc19.x86_64
Found initrd image: /boot/initramfs-3.10.10-200.fc19.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-b9b2e08f850f48d8aa3a6e636ab49aa0
Found initrd image: /boot/initramfs-0-rescue-b9b2e08f850f48d8aa3a6e636ab49aa0.img
done
[root@teal ~]#

And looking at grub.cfg shows an empty 30_os-prober section.

This worked when I installed f18 on this system and still had f17 installed on another partition. Both had encrypted / root partitions, but f17's was also an LVM partition as well.

On my desktop system, I've got a similar setup and both f18 and f19 installed. But neither of the / root partitions are encrypted (and neither are LVM). But on my desktop, running 'grub2-mkconfig -o /boot/grub2/grub.cfg' on the f19 kernel does add a menuentry for f18 in grub.cfg's 30_os-prober section.


How reproducible:
Always fails.


Steps to Reproduce:
See above.


Actual results:
f18 does not get a menuentry in f19's grub.cfg.


Expected results:
f18 should have a menuentry in f19's grub.cfg..

Comment 1 Dean Nelson 2014-02-21 18:00:09 UTC
I installed f20 on my laptop, with /boot on /dev/sda7 and / root on /dev/sda8. A grub2-mkconfig fails to see f18 and f19 installed on sda1,sda2 and sda5,sda6 respectively, as can be seen in the following...


[root@teal ~]# cryptsetup luksOpen /dev/sda6 luks-663c9b60-9053-4330-845e-5d1e52108b10
Enter passphrase for /dev/sda6:
[root@teal ~]#

[root@teal ~]# cryptsetup luksOpen /dev/sda2 luks-42766e70-9c38-4660-885d-d233bb69fe30
Enter passphrase for /dev/sda2:
[root@teal ~]#

[root@teal ~]# ls -l /dev/mapper
total 0
crw-------. 1 root root 10, 236 Feb 21 10:47 control
lrwxrwxrwx. 1 root root       7 Feb 21 10:47 luks-23126b66-f017-4e30-b917-5610253f9f25 -> ../dm-0
lrwxrwxrwx. 1 root root       7 Feb 21 10:53 luks-42766e70-9c38-4660-885d-d233bb69fe30 -> ../dm-2
lrwxrwxrwx. 1 root root       7 Feb 21 10:52 luks-663c9b60-9053-4330-845e-5d1e52108b10 -> ../dm-1
[root@teal ~]#

[root@teal ~]# blkid
/dev/sda1: UUID="d7829903-f49c-442f-b042-1eb9c00a1f4f" TYPE="ext4" PARTUUID="00044410-01"
/dev/sda2: UUID="42766e70-9c38-4660-885d-d233bb69fe30" TYPE="crypto_LUKS" PARTUUID="00044410-02"
/dev/sda3: UUID="6ab885f5-6189-4652-a3ba-c72d0733b4b7" TYPE="swap" PARTUUID="00044410-03"
/dev/sda5: UUID="cc8bf5fe-3f41-4dc7-a227-706a805464d1" TYPE="ext4" PARTUUID="00044410-05"
/dev/sda6: UUID="663c9b60-9053-4330-845e-5d1e52108b10" TYPE="crypto_LUKS" PARTUUID="00044410-06"
/dev/sda7: UUID="9f88aef1-f397-4072-bf06-257498026b7c" TYPE="ext4" PARTUUID="00044410-07"
/dev/sda8: UUID="23126b66-f017-4e30-b917-5610253f9f25" TYPE="crypto_LUKS" PARTUUID="00044410-08"
/dev/sda9: UUID="88768e27-4fef-4d2f-bde9-46dcb42fcdc0" TYPE="ext4" PARTUUID="00044410-09"
/dev/mapper/luks-23126b66-f017-4e30-b917-5610253f9f25: UUID="7aff4f74-ea26-48b7-a9e4-dc6b160dafcf" TYPE="ext4"
/dev/mapper/luks-663c9b60-9053-4330-845e-5d1e52108b10: UUID="f2de7132-1eae-4800-96b8-f25c6cdd347b" TYPE="ext4"
/dev/mapper/luks-42766e70-9c38-4660-885d-d233bb69fe30: UUID="6e7d995e-fff5-4fc3-ae9a-c9fdf68eb28f" TYPE="ext4"
[root@teal ~]#

[root@teal ~]# mount /dev/mapper/luks-42766e70-9c38-4660-885d-d233bb69fe30 /mnt/dev-sda2
[root@teal ~]# mount /dev/mapper/luks-663c9b60-9053-4330-845e-5d1e52108b10 /mnt/dev-sda6

[root@teal ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.13.3-201.fc20.x86_64
Found initrd image: /boot/initramfs-3.13.3-201.fc20.x86_64.img
Found linux image: /boot/vmlinuz-3.12.9-301.fc20.x86_64
Found initrd image: /boot/initramfs-3.12.9-301.fc20.x86_64.img
Found linux image: /boot/vmlinuz-3.11.10-301.fc20.x86_64
Found initrd image: /boot/initramfs-3.11.10-301.fc20.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-13d4311fe6004f7ebb11013311d16288
Found initrd image: /boot/initramfs-0-rescue-13d4311fe6004f7ebb11013311d16288.img
done
[root@teal ~]#

[root@teal mnt]# parted -l
Model: ATA TOSHIBA MK5061GS (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End     Size    Type      File system     Flags
 1      1049kB  263MB   262MB   primary   ext4            boot
 2      263MB   46.5GB  46.2GB  primary
 3      46.5GB  63.3GB  16.8GB  primary   linux-swap(v1)
 4      63.3GB  500GB   437GB   extended
 5      63.3GB  63.5GB  262MB   logical   ext4
 6      63.5GB  110GB   46.2GB  logical
 7      110GB   110GB   262MB   logical   ext4
 8      110GB   156GB   46.2GB  logical
 9      156GB   500GB   344GB   logical   ext4


Model: Linux device-mapper (crypt) (dm)
Disk /dev/mapper/luks-42766e70-9c38-4660-885d-d233bb69fe30: 46.2GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:

Number  Start  End     Size    File system  Flags
 1      0.00B  46.2GB  46.2GB  ext4


Model: Linux device-mapper (crypt) (dm)
Disk /dev/mapper/luks-663c9b60-9053-4330-845e-5d1e52108b10: 46.2GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:

Number  Start  End     Size    File system  Flags
 1      0.00B  46.2GB  46.2GB  ext4


Model: Linux device-mapper (crypt) (dm)
Disk /dev/mapper/luks-23126b66-f017-4e30-b917-5610253f9f25: 46.2GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:

Number  Start  End     Size    File system  Flags
 1      0.00B  46.2GB  46.2GB  ext4


[root@teal ~]#

Comment 2 Mads Kiilerich 2014-02-22 13:45:37 UTC
The grub os-prober functionality for creating 'deep links' to other linuxes is conceptually broken anyway. It will only work for simple configurations.

Instead see https://www.happyassassin.net/2014/01/08/how-to-do-manual-multi-boot-configuration-with-fedora/

You could perhaps work with upstream os-prober and grub to make it create configfile entries instead ... and detect your luks partitions.

Comment 3 Dean Nelson 2014-03-28 13:17:56 UTC
(In reply to Mads Kiilerich from comment #2)
> The grub os-prober functionality for creating 'deep links' to other linuxes
> is conceptually broken anyway. It will only work for simple configurations.
> 
> Instead see
> https://www.happyassassin.net/2014/01/08/how-to-do-manual-multi-boot-
> configuration-with-fedora/

Thanks for the info, I went with using configfile, and that works very well.

In fact, it seems superior to what os-prober provides, in that if one has yum updated f19 resulting in a new kernel. And say that the MBR is written by doing a grub2-mkconfig on f20, one needs to restart into f20 and run grub2-mkconfig there, and then restart yet again into f19, in order to select the latest f19 kernel to boot into. Whereas, with configfile, that additional restart is not needed. (I should caveat this by saying, this is according to my very limited understanding of grub2.)


> You could perhaps work with upstream os-prober and grub to make it create
> configfile entries instead ... and detect your luks partitions.

This seems like a better approach for os-prober to take. If I can find the time, I just might do what you suggest.

Thanks again. I'm closing this BZ as WONTFIX, as in there is a simple a simple and better way of dealing with the reported issue.