Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-44705

os-prober generates broken snippets for alternate root file systems

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Undefined Undefined
    • rhel-9.5
    • rhel-8.10, rhel-9.4
    • os-prober
    • None
    • os-prober-1.77-11.el9
    • None
    • Moderate
    • ZStream
    • rhel-sst-desktop-firmware-bootloaders
    • ssg_display
    • 3
    • False
    • Hide

      None

      Show
      None
    • None
    • Red Hat Enterprise Linux
    • None
    • Approved Blocker
    • None
    • None
    • None

      What were you trying to do that didn't work?

      A customer is creating a copy of his root file system as a backup file system in case root file system doesn't boot, as a LVM volume: rhel-root --> backup-root
      He then updates the copy to fix /etc/fstab and /etc/default/grub to select the expected root file system (i.e. so that rd.lvm.lv=rhel/root becomes rd.lvm.lv=backup/root, etc.).

      When rebuilding the Grub menu using grub2-mkconfig, os-prober executes and provides wrong snippets, since the last column root=xxx provides a DM mapper reference, which is volatile, e.g. with adding set -x in /usr/libexec/linux-boot-probes/mounted/90fallback:

      + cat
      + '[' 'xRed Hat Enterprise Linux 9.4 (Plow) (on /dev/mapper/backup-root)' = xb5af1fc93c0a4c7eae36e167138931d5-5.14.0-427.13.1.el9_4.x86_64 ']'
      + '[' 'xPrevious Linux versions>Red Hat Enterprise Linux 9.4 (Plow) (on /dev/mapper/backup-root)' = xb5af1fc93c0a4c7eae36e167138931d5-5.14.0-427.13.1.el9_4.x86_64 ']'
      + for LINUX in ${LINUXPROBED}
      ++ echo /dev/mapper/backup-root:/dev/vda1::/boot/vmlinuz-5.14.0-427.13.1.el9_4.x86_64:/boot/initramfs-5.14.0-427.13.1.el9_4.x86_64.img:root=/dev/dm-2
      ++ cut -d : -f 1
      + LROOT=/dev/mapper/backup-root
      ++ echo /dev/mapper/backup-root:/dev/vda1::/boot/vmlinuz-5.14.0-427.13.1.el9_4.x86_64:/boot/initramfs-5.14.0-427.13.1.el9_4.x86_64.img:root=/dev/dm-2
      ++ cut -d : -f 2
      + LBOOT=/dev/vda1
      ++ echo /dev/mapper/backup-root:/dev/vda1::/boot/vmlinuz-5.14.0-427.13.1.el9_4.x86_64:/boot/initramfs-5.14.0-427.13.1.el9_4.x86_64.img:root=/dev/dm-2
      ++ cut -d : -f 3
      ++ tr '^' ' '
      + LLABEL=
      ++ echo /dev/mapper/backup-root:/dev/vda1::/boot/vmlinuz-5.14.0-427.13.1.el9_4.x86_64:/boot/initramfs-5.14.0-427.13.1.el9_4.x86_64.img:root=/dev/dm-2
      ++ cut -d : -f 4
      + LKERNEL=/boot/vmlinuz-5.14.0-427.13.1.el9_4.x86_64
      ++ echo /dev/mapper/backup-root:/dev/vda1::/boot/vmlinuz-5.14.0-427.13.1.el9_4.x86_64:/boot/initramfs-5.14.0-427.13.1.el9_4.x86_64.img:root=/dev/dm-2
      ++ cut -d : -f 5
      + LINITRD=/boot/initramfs-5.14.0-427.13.1.el9_4.x86_64.img
      ++ echo /dev/mapper/backup-root:/dev/vda1::/boot/vmlinuz-5.14.0-427.13.1.el9_4.x86_64:/boot/initramfs-5.14.0-427.13.1.el9_4.x86_64.img:root=/dev/dm-2
      ++ cut -d : -f 6-
      ++ tr '^' ' '
      + LPARAMS=root=/dev/dm-2
      [...]
      

      Customer expectation would have been getting root=/dev/mapper/backup-root instead of root=/dev/dm-2 which is actually mapping to /dev/mapper/rhel-root, the "primary" file system, currently mounted on slash.

      Clearly os-prober doesn't work anymore, I don't know if we can fix this or if it falls into unsupported scenarios, since we at Red Hat consider that having multiple OSes on the same system is not supported and such scenario is kind of similar to having multiple OSes.

      Please provide the package NVR for which bug is seen:

      os-prober-1.74-9.el8.x86_64
      os-prober-1.77-10.el9.x86_64

      How reproducible:

      Always

      Steps to reproduce

      1. Assuming root is currently a LVM volume /dev/rhel/root
      2. Attach a new disk to a VM and format it to host a copy of root file system
        # vgcreate backup /dev/vdb
         # lvcreate -n root -L 10G /dev/backup
         # mkfs.xfs /dev/backup/root
         # mount /dev/backup/root /mnt
         # tar cf - --one-file-system / | tar xf - -C /mnt
         
      3. Fix the copy of the file system to reference the proper volume
        # sed -i -e "s/rhel-root/backup-root/g" -e "s#rhel/root#backup/root#g" /mnt/etc/fstab /mnt/etc/default/grub
      4. Unmount /mnt
      5. Build the Grub menu again
        # grub2-mkconfig -o /tmp/foo

      Expected results

      New "backup" entries with proper kernel command line:

      menuentry 'Red Hat Enterprise Linux 8.9 (Ootpa) (on /dev/mapper/backup-root)' --class red --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-simple-3faed939-9778-4aa4-b9be-edd56e006da4' {
      [...]
      linux /vmlinuz-0-rescue-9d59a9f41c1642b196990576ac8b7846 crashkernel=auto resume=/dev/mapper/rhel-swap rd.lvm.lv=backup/root rd.lvm.lv=rhel/swap console=tty0 console=ttyS0,115200n8
      [...]
      

      Actual results

      Unusual "backup" entries not having kernel parameters (it's a Grub issue) but also a bad reference to root=/dev/dm-X:

      menuentry 'Red Hat Enterprise Linux 8.9 (Ootpa) (on /dev/mapper/backup-root)' --class red --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-simple-3faed939-9778-4aa4-b9be-edd56e006da4' {
      [...]
              linux /vmlinuz-0-rescue-9d59a9f41c1642b196990576ac8b7846 root=/dev/dm-2
      [...]
      

        1. dupdisk.sh
          10 kB
          CDS Expertise
        2. grub-menu-backup-root.png
          61 kB
          Leo Sandoval

              bootloader-eng-team bootloader -eng-team
              rhn-support-rmetrich Renaud Métrich
              bootloader -eng-team bootloader -eng-team
              qe-baseos-daemons qe-baseos-daemons
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Created:
                Updated: