Bug#574863: grub-pc: grub-probe unable to find mapping for /boot on LVM with a snapshot LV

Vaidyanathan Srinivasan svaidy at gmail.com
Sun Mar 21 18:55:59 UTC 2010


Package: grub-pc
Version: 1.98-1
Severity: important
Tags: d-i patch upstream



-- Package-specific info:

*********************** BEGIN /proc/mounts
/dev/mapper/sagarikavg-sidux / reiserfs rw,noatime 0 0
/dev/mapper/sagarikavg-svwork /home/sv ext4 rw,noatime,barrier=1,data=ordered 0 0
/dev/mapper/sagarikavg-photoslv /home/photos reiserfs rw,noatime 0 0
/dev/mapper/sagarikavg-videos /home/videos reiserfs rw,noatime 0 0
/dev/mapper/sagarikavg-audiolv /home/audios reiserfs rw,noatime 0 0
/dev/sdb1 /mnt vfat rw,relatime,fmask=0022,dmask=0022,codepage=cp437,iocharset=utf8,shortname=mixed,utf8,errors=remount-ro 0 0
*********************** END /proc/mounts

*********************** BEGIN /boot/grub/device.map
(hd0)	/dev/sda
(hd1)	/dev/sdb
*********************** END /boot/grub/device.map

*********************** BEGIN /boot/grub/grub.cfg
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by /usr/sbin/grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
insmod lvm
if [ -s $prefix/grubenv ]; then
  load_env
fi
set default="0"
if [ ${prev_saved_entry} ]; then
  set saved_entry=${prev_saved_entry}
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z ${boot_once} ]; then
    saved_entry=${chosen}
    save_env saved_entry
  fi
}
insmod lvm
insmod reiserfs
set root='(sagarikavg-sidux)'
search --no-floppy --fs-uuid --set 5bb8940f-c54d-436a-86c6-f1eaf627f89d
if loadfont /usr/share/grub/unicode.pf2 ; then
  set gfxmode=640x480
  insmod gfxterm
  insmod vbe
  if terminal_output gfxterm ; then true ; else
    # For backward compatibility with versions of terminal.mod that don't
    # understand terminal_output
    terminal gfxterm
  fi
fi
insmod lvm
insmod reiserfs
set root='(sagarikavg-sidux)'
search --no-floppy --fs-uuid --set 5bb8940f-c54d-436a-86c6-f1eaf627f89d
set locale_dir=($root)/boot/grub/locale
set lang=en
insmod gettext
set timeout=5
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=cyan/blue
set menu_color_highlight=white/blue
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_linux ###
menuentry "Debian GNU/Linux, with Linux 2.6.33-1.slh.3-sidux-amd64" --class debian --class gnu-linux --class gnu --class os {
	insmod lvm
	insmod reiserfs
	set root='(sagarikavg-sidux)'
	search --no-floppy --fs-uuid --set 5bb8940f-c54d-436a-86c6-f1eaf627f89d
	echo	Loading Linux 2.6.33-1.slh.3-sidux-amd64 ...
	linux	/boot/vmlinuz-2.6.33-1.slh.3-sidux-amd64 root=/dev/mapper/sagarikavg-sidux ro quiet quiet
	echo	Loading initial ramdisk ...
	initrd	/boot/initrd.img-2.6.33-1.slh.3-sidux-amd64
}
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_memtest86+ ###
menuentry "Memory test (memtest86+)" {
	insmod lvm
	insmod reiserfs
	set root='(sagarikavg-sidux)'
	search --no-floppy --fs-uuid --set 5bb8940f-c54d-436a-86c6-f1eaf627f89d
	multiboot	/boot/memtest86+_multiboot.bin
}
menuentry "Memory test (memtest86+, serial console 115200)" {
	insmod lvm
	insmod reiserfs
	set root='(sagarikavg-sidux)'
	search --no-floppy --fs-uuid --set 5bb8940f-c54d-436a-86c6-f1eaf627f89d
	multiboot	/boot/memtest86+_multiboot.bin console=ttyS0,115200n8
}
### END /etc/grub.d/20_memtest86+ ###

### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Debian GNU/Linux, with Linux 2.6.32-2.slh.4-sidux-amd64 (on /dev/mapper/sagarikavg-sidux2)" {
	insmod lvm
	insmod ext2
	set root='(sagarikavg-sidux2)'
	search --no-floppy --fs-uuid --set 98e7755e-d101-479a-b13c-d8eb807fa383
	linux /boot/vmlinuz-2.6.32-2.slh.4-sidux-amd64 root=/dev/mapper/sagarikavg-sidux2 ro vga=791 quiet
	initrd /boot/initrd.img-2.6.32-2.slh.4-sidux-amd64
}
menuentry "Debian GNU/Linux, with Linux 2.6.32-2.slh.4-sidux-amd64 (recovery mode) (on /dev/mapper/sagarikavg-sidux2)" {
	insmod lvm
	insmod ext2
	set root='(sagarikavg-sidux2)'
	search --no-floppy --fs-uuid --set 98e7755e-d101-479a-b13c-d8eb807fa383
	linux /boot/vmlinuz-2.6.32-2.slh.4-sidux-amd64 root=/dev/mapper/sagarikavg-sidux2 ro single vga=791
	initrd /boot/initrd.img-2.6.32-2.slh.4-sidux-amd64
}
menuentry "Debian GNU/Linux, with Linux 2.6.31-rc4-sv (on /dev/mapper/sagarikavg-squeeze2)" {
	insmod lvm
	insmod ext2
	set root='(sagarikavg-squeeze2)'
	search --no-floppy --fs-uuid --set 78f67108-7883-4a8e-8289-63c40f938610
	linux /boot/vmlinuz-2.6.31-rc4-sv root=/dev/mapper/sagarikavg-squeeze2 ro quiet
	initrd /boot/initrd.img-2.6.31-rc4-sv
}
menuentry "Debian GNU/Linux, with Linux 2.6.31-rc4-sv (recovery mode) (on /dev/mapper/sagarikavg-squeeze2)" {
	insmod lvm
	insmod ext2
	set root='(sagarikavg-squeeze2)'
	search --no-floppy --fs-uuid --set 78f67108-7883-4a8e-8289-63c40f938610
	linux /boot/vmlinuz-2.6.31-rc4-sv root=/dev/mapper/sagarikavg-squeeze2 ro single quiet
	initrd /boot/initrd.img-2.6.31-rc4-sv
}
menuentry "Debian GNU/Linux, with Linux 2.6.30-2-amd64 (on /dev/mapper/sagarikavg-squeeze2)" {
	insmod lvm
	insmod ext2
	set root='(sagarikavg-squeeze2)'
	search --no-floppy --fs-uuid --set 78f67108-7883-4a8e-8289-63c40f938610
	linux /boot/vmlinuz-2.6.30-2-amd64 root=/dev/mapper/sagarikavg-squeeze2 ro quiet
	initrd /boot/initrd.img-2.6.30-2-amd64
}
menuentry "Debian GNU/Linux, with Linux 2.6.30-2-amd64 (recovery mode) (on /dev/mapper/sagarikavg-squeeze2)" {
	insmod lvm
	insmod ext2
	set root='(sagarikavg-squeeze2)'
	search --no-floppy --fs-uuid --set 78f67108-7883-4a8e-8289-63c40f938610
	linux /boot/vmlinuz-2.6.30-2-amd64 root=/dev/mapper/sagarikavg-squeeze2 ro single quiet
	initrd /boot/initrd.img-2.6.30-2-amd64
}
menuentry "Debian GNU/Linux, with Linux 2.6.30-1-amd64 (on /dev/mapper/sagarikavg-squeeze2)" {
	insmod lvm
	insmod ext2
	set root='(sagarikavg-squeeze2)'
	search --no-floppy --fs-uuid --set 78f67108-7883-4a8e-8289-63c40f938610
	linux /boot/vmlinuz-2.6.30-1-amd64 root=/dev/mapper/sagarikavg-squeeze2 ro quiet
	initrd /boot/initrd.img-2.6.30-1-amd64
}
menuentry "Debian GNU/Linux, with Linux 2.6.30-1-amd64 (recovery mode) (on /dev/mapper/sagarikavg-squeeze2)" {
	insmod lvm
	insmod ext2
	set root='(sagarikavg-squeeze2)'
	search --no-floppy --fs-uuid --set 78f67108-7883-4a8e-8289-63c40f938610
	linux /boot/vmlinuz-2.6.30-1-amd64 root=/dev/mapper/sagarikavg-squeeze2 ro single quiet
	initrd /boot/initrd.img-2.6.30-1-amd64
}
menuentry "Debian GNU/Linux, linux 2.6.30-1-amd64 (on /dev/mapper/sagarikavg-squeezylv)" {
	insmod lvm
	insmod ext2
	set root='(sagarikavg-squeezylv)'
	search --no-floppy --fs-uuid --set 2a542bbf-2ef1-4a6b-a155-6c71106b767b
	linux /boot/vmlinuz-2.6.30-1-amd64 root=/dev/mapper/sagarikavg-squeezylv ro quiet
	initrd /boot/initrd.img-2.6.30-1-amd64
}
menuentry "Debian GNU/Linux, linux 2.6.30-1-amd64 (recovery mode) (on /dev/mapper/sagarikavg-squeezylv)" {
	insmod lvm
	insmod ext2
	set root='(sagarikavg-squeezylv)'
	search --no-floppy --fs-uuid --set 2a542bbf-2ef1-4a6b-a155-6c71106b767b
	linux /boot/vmlinuz-2.6.30-1-amd64 root=/dev/mapper/sagarikavg-squeezylv ro single quiet
	initrd /boot/initrd.img-2.6.30-1-amd64
}
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###
*********************** END /boot/grub/grub.cfg

-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.33-1.slh.3-sidux-amd64 (SMP w/4 CPU cores; PREEMPT)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages grub-pc depends on:
ii  debconf [debconf-2.0]         1.5.28     Debian configuration management sy
ii  grub-common                   1.98-1     GRand Unified Bootloader, version 
ii  libc6                         2.10.2-6   Embedded GNU C Library: Shared lib
ii  ucf                           3.0025     Update Configuration File: preserv

grub-pc recommends no packages.

Versions of packages grub-pc suggests:
pn  desktop-base                  <none>     (no description available)

-- debconf information:
  grub2/kfreebsd_cmdline:
* grub2/linux_cmdline: quiet
* grub-pc/chainload_from_menu.lst: false
  grub-pc/kopt_extracted: true
* grub-pc/install_devices: /dev/sda
  grub-pc/postrm_purge_boot_grub: false
  grub2/kfreebsd_cmdline_default: quiet
* grub2/linux_cmdline_default: quiet


------------------------------------------

Problem Description:

Creation of a snapshot logical volume makes grup-pc complete skip the volume
group and makes the system not bootable. (/boot is in an LVM).  The problem is
in the code in lvm.c:grub_lvm_scan_device()

Whenever there is a snapshot logical volume, there is a special LV of 
"type = snapshot" that is created to handle the snapshot operation.

This LV is hidden and is part of the LVM metadata but not listed in lvdisplay.
This special LV will not have the "stripe_count = xxx" property.  The actual
stripe_count will be same as the source LV 'origin = ' property.

However in the code any LV not having a stripe_count property is treated as a
fatal error and control jumps to lvs_segment_fail: and further fail4: and
ultimately skips the entire VG.  None of the LVs are populated in the vg_list
leading to grub-probe failure and further issues that completely breaks grub-pc
installation and updation.

Bug:
root at sagarika:~# grub-probe -t abstraction /
grub-probe: error: no mapping exists for `sagarikavg-sidux'.

With attached fix:
root at sagarika:/root/patch-grub/grub2-1.98# ./grub-probe -t abstraction /
lvm

Signed-off-by: Vaidyanathan Srinivasan <svaidy at gmail.com>
Index: grub2-1.98/disk/lvm.c
===================================================================
--- grub2-1.98.orig/disk/lvm.c	2010-03-22 00:09:03.000000000 +0530
+++ grub2-1.98/disk/lvm.c	2010-03-22 00:11:55.000000000 +0530
@@ -413,7 +413,7 @@
 	  /* And add all the lvs to the volume group. */
 	  while (1)
 	    {
-	      int s;
+	      int s, skip_lv;
 	      struct grub_lvm_lv *lv;
 	      struct grub_lvm_segment *seg;
 
@@ -424,6 +424,7 @@
 		break;
 
 	      lv = grub_malloc (sizeof (*lv));
+	      skip_lv = 0; /*Flag to skip snapshots */
 
 	      q = p;
 	      while (*q != ' ')
@@ -458,6 +459,13 @@
 		  seg->extent_count = grub_lvm_getvalue (&p, "extent_count = ");
 		  if (p == NULL)
 		    goto lvs_segment_fail;
+		  seg->extent_count = grub_lvm_getvalue (&p, "type = ");
+		  if (p == NULL)
+		    goto lvs_segment_fail;
+		  if (!grub_strncmp(p, "\"snapshot\"", 10)) {
+		    skip_lv=1; /* Found a snapshot LV */
+	            break;  
+		  }
 		  seg->stripe_count = grub_lvm_getvalue (&p, "stripe_count = ");
 		  if (p == NULL)
 		    goto lvs_segment_fail;
@@ -530,6 +538,12 @@
 		goto lvs_fail;
 	      p += 3;
 
+	      if (skip_lv) {
+	        grub_free (lv->name);
+	        grub_free (lv);
+		continue;
+	      }
+
 	      lv->number = lv_count++;
 	      lv->vg = vg;
 	      lv->next = vg->lvs;

---

This fix is not complete and sufficient to make grub-pc work in the presence of
lvm snapshots.  There seem to be more issues in the presence of a snapshot LV.
I am hitting a filesystem detection problem right after fixing this issue.
# ./grub-probe  /
../grub-probe: error: unknown filesystem.

Atleast this fix will make grub-probe recognise the VG and discover the LVs.

Please not that _ALL_ these issues disappear once all snapshot LVs are deleted.

I create snapshot LV with the following command:
lvcreate -L 1g -n sidux-snap-10313 -s /dev/sagarikavg/sidux

Thanks for your attention to this problem.  I will post an update when I find
more fixes.

--Vaidy





More information about the Pkg-grub-devel mailing list