incorrectly assumes /dev/mapper/ -> LVM

Bug #413345 reported by komputes
22
This bug affects 4 people
Affects Status Importance Assigned to Milestone
grub2 (Ubuntu)
Expired
Medium
Unassigned
Nominated for Lucid by lirel
os-prober (Ubuntu)
Invalid
Undecided
Unassigned
Nominated for Lucid by lirel

Bug Description

After installing GRUB2/Ubuntu 9.10 on a LUKS encrypted partition (using the alternate CD), I can no longer boot into my other partition.

I have a computer with one drive and multiple partitions. To simplify the drive layout it I have included the following attempt at a diagram/explanation:

==
/dev/sda1 [ /boot ]
/dev/sda2 [ Extended container START
-- /dev/sda8 [ / - Ubuntu 9.04]
-- /dev/sda9 [ blank ]
-- /dev/sda10 [ swap ]
/dev/sda2 Extended container STOP]
==

As you can see, I have a separate /boot partition which holds GRUB and the various kernel images (initrd/vmlinuz). As long as I was using GRUB 0.97-29, I did not have any problems.

Now this is what I did to mess it up:

1) I booted from the Ubuntu 9.10 Alpha alternate (text-install) CD

2) Using the debian system installer, I set up /dev/sda9 to be LVM-over-encrypted_volume. This device will be mounted to /

3) Using the debian system installer, I set up /dev/sda10 to be LVM-over-encrypted_volume. This device will be used as encrypted swap

4) I selected the existing /dev/sda1 ( /boot ) to be mounted as /boot.

5) Once the devices set up, the installer started by installing GRUB. It detected that a legacy GRUB was on /dev/sda1 and asked me if I wanted to write over it with GRUB2 (1.96). A dialog with an empty line (which should have a command in it) showed up. The dialog presented the following message:

==
[!] Configuring grub-pc
The following linux command line was extracted from the kopt parameter in GRUB Legacy's menu.lst. Please verify that is is correct and modify it if necessary.

[ ]
<Go Back> <Continue>
==

Afterwards, the installation went through, and I was able to reboot into my new Ubuntu 9.10 alpha installation. The problem happened when I rebooted and attempted to go into my old 9.04 installation on /dev/sda1. It seems that when GRUB2 generated grub.cfg from the legacy menu.lst, it did not copy UUID information properly into the new syntax. The GRUB legacy script assumes that because I set up a LVM, that now all devices are on the LVM managed, when I don't think that they are.

The layout after the Ubuntu 9.10 alpha installation looks like this:

==
/dev/sda1 [ /boot ]
/dev/sda2 [ Extended container START
-- /dev/sda8 [ / - Ubuntu 9.04]
-- /dev/sda9 [ crypt-luks ]
--- /dev/mapper/cryptdisk-karmic
-- /dev/sda10 [ crypt-luks ]
--- /dev/mapper/sda10_crypt
/dev/sda2 Extended container STOP]
==

I cannot boot into Ubuntu 9.04 which is the problem I would like to resolve. When I select a kernel from Ubuntu 9.04, I just get a blinking underscore in the top left corner. Here is a line from the backed up legacy menu.lst followed by that same line in the new grub.cfg after being imported:

menu.lst
==
title Ubuntu 9.04, kernel 2.6.28-13-generic
uuid 1768a7ec-e0ce-8fa4-814b-2e628de7c2b2
kernel /vmlinuz-2.6.28-13-generic root=UUID=e1b20064-8204-4150-be5e-83bd537defc8 ro quiet splash vga=773
initrd /initrd.img-2.6.28-13-generic
quiet
==

grub.cfg
==
menuentry "Ubuntu, Linux 2.6.28-13-generic" {
 set root=(hd0,1)
 search --no-floppy --fs-uuid --set 1768a7ec-e0ce-8fa4-814b-2e628de7c2b2
 linux /vmlinuz-2.6.28-13-generic root=/dev/mapper/cryptdisk-karmic ro quiet splash
 initrd /initrd.img-2.6.28-13-generic
}
==

This bug was created so that hopefully, the detection and generation of grub.cfg from legacy menu.lst does not mess up like this. Help to allow me to boot into 9.04 would also be appreciated. I hope that I have provide enough information to diagnose the issue.

Tags: lucid
Revision history for this message
komputes (komputes) wrote :

To get it to work, I had to get the UUID's by running "sudo blkid" and then I placed them in grub.cfg like so:

[code]menuentry "Ubuntu, Linux 2.6.28-13-generic" {
        set root=(hd0,1)
        search --no-floppy --fs-uuid --set $UUID_OF_PARTITION_WITH_/BOOT
        linux /vmlinuz-2.6.28-13-generic root=UUID=$UUID_OF_PARTITION_WITH_/ quiet splash
        initrd /initrd.img-2.6.28-13-generic
}[/code]

GRUB developers should know that the "Legacy -> GRUB2" process messes up the configuration file (by assuming all partitions are LVM managed) when done this way.

My worry is that when installing new kernels in 9.04, will grub.cfg be updated automatically or do I need to boot into 9.10 every time and run upgrade-from-grub-legacy?

If I have to run upgrade-from-grub-legacy, will it put the actual UUIDs or will it still assume these are LVM managed partitions and incorrectly produce grub.cfg again?

summary: - After installing Ubuntu 9.10 and GRUB2, I can no longer boot into my
- other partition
+ Ubuntu 9.10 Alternate Installer - GRUB2 incorrectly assumes all
+ partitions are LVM managed when writing grub.cfg
komputes (komputes)
description: updated
Revision history for this message
komputes (komputes) wrote : Re: Ubuntu 9.10 Alternate Installer - GRUB2 incorrectly assumes all partitions are LVM managed when writing grub.cfg

Every time a new kernel is installed in karmic, the entire grub.cfg is regenerated, making that my changes do not count. Because of that, I cannot boot easily into Jaunty, because the karmic's GRUB keeps thinking that the Jaunty partition is LVM managed.

As well I would recommend that the following lines in grub.cfg be commented out as they block me from getting to the GRUB menu:
### BEGIN /etc/grub.d/30_os-prober ###
if [ ${timeout} != -1 ]; then
  if keystatus; then
    if keystatus --shift; then
      set timeout=-1
    else
      set timeout=0
    fi
  else
    if sleep --interruptible 3 ; then
      set timeout=0
    fi
  fi
fi
### END /etc/grub.d/30_os-prober ###

Revision history for this message
komputes (komputes) wrote :

Also, every time a new kernel is installed in karmic, I need to modify the grub.cfg to the following to be able to boot into Jaunty:
==
menuentry "Ubuntu, Linux 2.6.28-13-generic" {
 set root=(hd0,1)
 search --no-floppy --fs-uuid --set 1768a7ec-e0ce-8fa4-814b-2e628de7c2b2
 linux /vmlinuz-2.6.28-13-generic root=UUID=e1b20064-8204-4150-be5e-83bd537defc8 ro quiet splash
 initrd /initrd.img-2.6.28-13-generic
}
==

-OR-

==
menuentry "Ubuntu, Linux 2.6.28-13-generic" {
 set root=(hd0,1)
 search --no-floppy --fs-uuid --set 1768a7ec-e0ce-8fa4-814b-2e628de7c2b2
 linux /vmlinuz-2.6.28-13-generic root=/dev/sda8 ro quiet splash
 initrd /initrd.img-2.6.28-13-generic
}
==

How can I get GRUB to stop using /dev/mapper/cryptdisk-karmic as the root of the entries that are supposed to point to the Jaunty partition?

Revision history for this message
Felix Zielcke (fzielcke) wrote :

The problem is not that it assumes that everything is `LVM managed', but just that os-prober uses the wrong root= parameter for your jaunty kernel

Changed in grub (Ubuntu):
status: New → Invalid
affects: grub2 (Ubuntu) → os-prober (Ubuntu)
summary: - Ubuntu 9.10 Alternate Installer - GRUB2 incorrectly assumes all
- partitions are LVM managed when writing grub.cfg
+ os-prober uses wrong root= kernel parameter for jaunty
Revision history for this message
komputes (komputes) wrote : Re: os-prober uses wrong root= kernel parameter for jaunty

@Felix Zielcke
How can that be if os-prober is not installed?

komputes@karmic:~$ sudo os-prober
sudo: os-prober: command not found
komputes@karmic:~$ sudo -s
root@karmic:~# os-prober
The program 'os-prober' is currently not installed. You can install it by typing:
apt-get install os-prober
os-prober: command not found

Changed in grub (Ubuntu):
status: Invalid → New
Revision history for this message
Colin Watson (cjwatson) wrote :

I agree, this clearly isn't an os-prober problem.

You can get to the menu by holding Shift at boot; or, with recent versions of the grub2 packages, any failed boot of Ubuntu will cause the menu to be automatically shown on the next boot.

affects: grub (Ubuntu) → grub2 (Ubuntu)
Changed in os-prober (Ubuntu):
status: New → Invalid
Revision history for this message
Colin Watson (cjwatson) wrote :

Here's the broken code (possibly other similar bits elsewhere):

int
grub_util_get_dev_abstraction (const char *os_dev UNUSED)
{
#ifdef __linux__
  /* Check for LVM. */
  if (!strncmp (os_dev, "/dev/mapper/", 12))
    return GRUB_DEV_ABSTRACTION_LVM;

  /* Check for RAID. */
  if (!strncmp (os_dev, "/dev/md", 7))
    return GRUB_DEV_ABSTRACTION_RAID;
#endif

  /* No abstraction found. */
  return GRUB_DEV_ABSTRACTION_NONE;
}

summary: - os-prober uses wrong root= kernel parameter for jaunty
+ incorrectly assumes /dev/mapper/ -> LVM
Changed in grub2 (Ubuntu):
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
komputes (komputes) wrote :

Hi Colin, Thank you for triaging this bug. If anything else is needed from me, please let me know. I hope this can be fixed before the karmic alt/server ISO release.

Revision history for this message
HankB (hbarta) wrote :

I think I have experienced another facet of this bug. I had Jaunty installed in /dev/sda with a separate /boot partition. When I installed Karmic on another partition (also on /dev/sda) and *not* using the /boot partition for Karmic, the resulting grub.cfg created entries for Jaunty that ignored the separate /boot partition. In other words, In other words, it produced:

menuentry "Ubuntu 9.04, kernel 2.6.28-15-generic (on /dev/sda6)" {
        insmod ext2
        set root=(hd0,6)
        search --no-floppy --fs-uuid --set 7f69072f-cea2-4ec3-bde9-81dd16744034
        linux /boot/vmlinuz-2.6.28-15-generic root=UUID=7f69072f-cea2-4ec3-bde9-81dd16744034 ro quiet splash
        initrd /boot/initrd.img-2.6.28-15-generic
}

when it should have been:

menuentry "Ubuntu 9.04, kernel 2.6.28-15-generic (on /dev/sda6)" {
        insmod ext2
        set root=(hd0,6)
        search --no-floppy --fs-uuid --set 9bdeb391-8fd9-48b1-9316-c4a00b7fa7a2
        linux /vmlinuz-2.6.28-15-generic root=UUID=7f69072f-cea2-4ec3-bde9-81dd16744034 ro quiet splash
        initrd /initrd.img-2.6.28-15-generic
}

Annotated results from 'blkid'

root@cypress:/media/disk/boot/grub# blkid
/dev/sda1: UUID="5C0CDB8F0CDB6296" LABEL="SERVICEV003" TYPE="ntfs"
/dev/sda2: UUID="C4F8DDE6F8DDD730" LABEL="SW_Preload" TYPE="ntfs"
/dev/sda3: UUID="DE62E0C562E0A38D" LABEL="Lenovo" TYPE="ntfs"
/dev/sda5: UUID="9bdeb391-8fd9-48b1-9316-c4a00b7fa7a2" TYPE="ext3" <<<<<<<<<<<< Jaunty /boot
/dev/sda6: UUID="7f69072f-cea2-4ec3-bde9-81dd16744034" TYPE="ext3" <<<<<<<<<<<< Jaunty /
/dev/sda7: TYPE="swap" UUID="a8b4289b-34b4-4c92-a7b9-c0bd7f253cff"
/dev/sda8: UUID="e186fa4e-a98c-49b9-b491-2205628c1f75" TYPE="ext3" SEC_TYPE="ext2" <<<<<<<< (shared /home)
/dev/sda9: UUID="836c9f55-820b-4760-b2cb-81af5b6fedfe" TYPE="ext4" <<<<<<<<<<<< Karmic /
root@cypress:/media/disk/boot/grub#

This was on the Karmic beta Desktop CD as of 2009-10-06. Following work around (which will require manual editing of grub.cfg every time I run 'update-grub on Karmic) I installed grub-pc on Jaunty and found that it did appear to produce grub.cfg compliant with a separate /boot partition when run from that installation. I'm not certain that the Jaunty grub.cfg is correct for Jaunty (which does not use the /boot partition.) It produced the entry:

menuentry "Ubuntu, Linux 2.6.31-12-generic (on /dev/sda9)" {
        set root=(hd0,9)
        linux /boot/vmlinuz-2.6.31-12-generic root=UUID=836c9f55-820b-4760-b2cb-81af5b6fedfe ro quiet splash
        initrd /boot/initrd.img-2.6.31-12-generic
}

If that uses the search line for Jaunty it will not find the kernel or initial RAM disk as those are not in the /boot partition.

Revision history for this message
lirel (m8r-lcodw5) wrote :

The same happens if the former jackalope-install used sda1 for grub and kernels and lvm /dev/mapper/ubuntu-jackalope for root.
it just assumes that all old systems boot from the new /dev/mapper/ubuntu-lucid even if it corrctly guesses the labels.

here are some lines from grub.cfg:
...
### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Ubuntu, with Linux 2.6.32-16-generic (on /dev/mapper/ubuntu-jackalope)" {
        insmod ext2
        set root='(hd0,1)'
        search --no-floppy --fs-uuid --set 720da49e-1432-4601-9e1f-ac3335f1fa5e
        linux /vmlinuz-2.6.32-16-generic root=/dev/mapper/ubuntu-lynx ro quiet splash
        initrd /initrd.img-2.6.32-16-generic
}
...
menuentry "Ubuntu, with Linux 2.6.28-18-generic (on /dev/mapper/ubuntu-jackalope)" {
        insmod ext2
        set root='(hd0,1)'
        search --no-floppy --fs-uuid --set 720da49e-1432-4601-9e1f-ac3335f1fa5e
        linux /vmlinuz-2.6.28-18-generic root=/dev/mapper/ubuntu-lynx ro quiet splash
        initrd /initrd.img-2.6.28-18-generic
}
...

lirel (m8r-lcodw5)
tags: added: lucid
Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

This release of Ubuntu is no longer receiving maintenance updates. If this is still an issue on a maintained version of Ubuntu please let us know.

Changed in grub2 (Ubuntu):
status: Triaged → Incomplete
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for grub2 (Ubuntu) because there has been no activity for 60 days.]

Changed in grub2 (Ubuntu):
status: Incomplete → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.