Bug#459632: initramfs-tools: Unable to detect LVM correctly if root device does not match /dev/mapper/*

2008-01-08 Thread Jerome Vizcaino
Ok sorry about that, the thing is redhat name scheme didn't mean a thing to 
me so I figured the bug has not been reported already.

Here is the solution I've tested :

First patch set : hook-functions and mkinitramfs are modified in order to 
detect the symlink between /dev/vg/lv - /dev/mapper/vg-lv and include the 
required lvm script in the ramdisk.

Second patch set : lvm and lvm2 scripts do a little bit more tests before 
giving up on lvm activation. If the device does not look like a /dev/mapper/* 
file it converts the root from /dev/vg/lv to /dev/mapper/vg-lv. If things 
looks ok, tests activation with vgchange -t (test mode). If things are ok, 
activates the volume group the usual way.

I've tested this solution using a /dev/lvm/root entry in mtab and 
root=/dev/lvm/root in kernel command line and it's working.

I think the changes should not break anything else. I'm sure you will give my 
small work a check.

Thank you.

Jerome

On Monday 07 January 2008, you wrote:
 On Mon, Jan 07, 2008 at 07:42:49PM +0100, Jerome Vizcaino wrote:
  The thing is, when detecting the root filesystem device, the script
  should check if the device is a link and if so, check if the target is of
  the form /dev/mapper/*
 
  Changing the root filesystem to /dev/mapper/lvm-root solved the problem
  (after I wasted about an hour).

 duplicate bug report explained in many other already,
 check out for rh lvm naming scheme and propose a solution.

 closing as no usefull info.


--- /usr/share/initramfs-tools/hook-functions.orig	2008-01-07 23:40:30.0 +0100
+++ /usr/share/initramfs-tools/hook-functions	2008-01-07 23:46:50.0 +0100
@@ -223,7 +223,10 @@
 
 	# findout root block device + fstype
 	eval $(mount | awk '/ \/ / {print root= $1 \nFSTYPE= $5; exit}')
-
+	
+	# If root device is a link, get the real device instead
+	[ -h $root ]  [ -h $root ]  root=$(readlink $root)
+	
 	# find out real rootfs on auto type
 	if [ ${FSTYPE} = auto ]; then
 		eval $(/usr/lib/klibc/bin/fstype ${root})
--- /usr/sbin/mkinitramfs.orig	2008-01-07 23:48:48.0 +0100
+++ /usr/sbin/mkinitramfs	2008-01-07 23:49:34.0 +0100
@@ -258,6 +258,9 @@
 	mv ${DESTDIR}/bin/sh.shared ${DESTDIR}/bin/sh
 	# those root need busybox
 	eval $(mount | awk '/ \/ / {print r_dev= $1; exit}')
+	# root device is a symlink, get the real device
+	[ -h $r_dev ]  r_dev=$(readlink $r_dev)
+
 	if [ ${r_dev#/dev/mapper/} != ${r_dev} ] \
 		|| [ ${r_dev#/dev/md} != ${r_dev} ]; then
 		echo Warning: Busybox is required for successful boot!
--- /usr/share/initramfs-tools/scripts/local-top/lvm2.orig	2008-01-08 00:01:06.0 +0100
+++ /usr/share/initramfs-tools/scripts/local-top/lvm2	2008-01-08 22:00:06.0 +0100
@@ -37,10 +37,32 @@
 		;;
 	esac
 
+	# Make sure root device is not a symlink
+	[ -h $vg ]  vg=$(readlink $vg)
 	# Make sure that we have a d-m path
 	vg=${vg#/dev/mapper/}
 	if [ $vg = $1 ]; then
-		return 1
+		# Convert RedHat name /dev/vg/lv to /dev/mapper/vg-lv
+		vg=$(echo $vg | sed -e 's#\(.*\)/\([^/]*\)/\(.*\)$#\1/mapper/\2-\3#')
+		# Check if it looks valid
+		if [ ${vg#/dev/mapper/} = $vg ]; then
+			return 1;
+		fi
+		# Remove /dev/mapper
+		vg=${vg#/dev/mapper/}
+	   # Split volume group from logical volume.
+		local test_vg=$(echo ${vg} | sed -e 's#\(.*\)\([^-]\)-[^-].*#\1\2#')
+		# Reduce padded --'s to -'s
+		test_vg=$(echo ${test_vg} | sed -e 's#--#-#g')
+		# Test if it's a valid LVM volume group
+		# This does not activate it, if everything is ok
+		# activation will be done later.
+		vgchange -ay -t $test_vg
+		if [ $? -ne 0 ]; then
+			return 1
+		fi
+		# Everything looks fine, vg is in the expected
+		# form for proper script completion
 	fi
 
 	# Make sure that the device includes at least one dash
--- /usr/share/initramfs-tools/scripts/local-top/lvm.orig	2008-01-08 00:01:04.0 +0100
+++ /usr/share/initramfs-tools/scripts/local-top/lvm	2008-01-08 22:00:44.0 +0100
@@ -37,10 +37,32 @@
 		;;
 	esac
 
+	# Make sure root device is not a symlink
+	[ -h $vg ]  vg=$(readlink $vg)
 	# Make sure that we have a d-m path
 	vg=${vg#/dev/mapper/}
 	if [ $vg = $1 ]; then
-		return 1
+		# Convert RedHat name /dev/vg/lv to /dev/mapper/vg-lv
+		vg=$(echo $vg | sed -e 's#\(.*\)/\([^/]*\)/\(.*\)$#\1/mapper/\2-\3#')
+		# Check if it looks valid
+		if [ ${vg#/dev/mapper/} = $vg ]; then
+			return 1;
+		fi
+		# Remove /dev/mapper
+		vg=${vg#/dev/mapper/}
+	   # Split volume group from logical volume.
+		local test_vg=$(echo ${vg} | sed -e 's#\(.*\)\([^-]\)-[^-].*#\1\2#')
+		# Reduce padded --'s to -'s
+		test_vg=$(echo ${test_vg} | sed -e 's#--#-#g')
+		# Test if it's a valid LVM volume group
+		# This does not activate it, if everything is ok
+		# activation will be done later.
+		vgchange -ay -t $test_vg
+		if [ $? -ne 0 ]; then
+			return 1
+		fi
+		# Everything looks fine, vg is in the expected
+		# form for proper script completion
 	fi
 
 	# Make sure that the device includes at least one dash


Bug#459632: initramfs-tools: Unable to detect LVM correctly if root device does not match /dev/mapper/*

2008-01-08 Thread maximilian attems
 + [ -h $vg ]  vg=$(readlink $vg)

this is the most sceptical part i have,
does that symlink exist before vgchange run??

(yes just read, not life tested yet)

-- 
maks



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Bug#459632: initramfs-tools: Unable to detect LVM correctly if root device does not match /dev/mapper/*

2008-01-08 Thread maximilian attems
[ please keep bug report on cc, bounced your message to bts ]

On Tue, Jan 08, 2008 at 10:11:25PM +0100, Jerome Vizcaino wrote:
 Ok sorry about that, the thing is redhat name scheme didn't mean a thing to 
 me so I figured the bug has not been reported already.

hehe, sorry
it is lately a tendency that bugs get reported without research.
after reading your code i'm happy about the code they show.
 
will give it a shoot tomorrow, overworked right now and
on positive test pass it on to the lvm2 hook maintainer
he incorporates the relevant initramfs-tools hooks.

thanks

-- 
maks



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Bug#459632: initramfs-tools: Unable to detect LVM correctly if root device does not match /dev/mapper/*

2008-01-07 Thread Jerome Vizcaino
Package: initramfs-tools
Version: 0.91d
Severity: critical
Justification: breaks the whole system

I've got a LVM setup on top of a raid1 (soft raid). Raid is detected fine but
the LVM was not.

Here is the problem.
LVM has an 'lvm' volume group and a 'root' logical volume.
Udev has two entries for this device :
- /dev/mapper/lvm-root
- /dev/lvm/root

On my first try, I had /dev/lvm/root defined as the mounted root device (in
/etc/mtab). Even if /dev/lvm/root is a symlink to /dev/mapper/lvm-root,
initramfs does not detect it as a LVM volume and therefore does not include 
the scripts in the initrd.

The thing is, when detecting the root filesystem device, the script should 
check if the device is a link and if so, check if the target is of the 
form /dev/mapper/*

Changing the root filesystem to /dev/mapper/lvm-root solved the problem (after 
I wasted about an hour).

-- Package-specific info:
-- /proc/cmdline
root=/dev/mapper/lvm-root ro

-- /proc/filesystems
cramfs
ext3
fuseblk
vfat

-- lsmod
Module  Size  Used by
nls_iso8859_1   4128  0
nls_cp437   5792  0
vfat   12032  0
fat48540  1 vfat
binfmt_misc2  1
ppdev   8676  0
parport_pc 33828  0
lp 10980  0
parport33960  3 ppdev,parport_pc,lp
button  7920  0
ac  5188  0
battery 9988  0
ipv6  236996  438
fuse   41908  3
snd_seq_dummy   3748  0
snd_seq_oss29408  0
snd_seq_midi8160  0
snd_rawmidi22624  1 snd_seq_midi
snd_seq_midi_event  6880  2 snd_seq_oss,snd_seq_midi
snd_seq46320  6
snd_seq_dummy,snd_seq_oss,snd_seq_midi,snd_seq_midi_event
snd_seq_device  7692  5
snd_seq_dummy,snd_seq_oss,snd_seq_midi,snd_rawmidi,snd_seq
sidewinder 11744  0
ns558   4704  0
gameport   14984  2 sidewinder,ns558
w83627hf   22964  0
w83781d26700  0
hwmon_vid   2944  2 w83627hf,w83781d
eeprom  7024  0
i2c_isa 4192  0
cryptoloop  2912  0
loop   16932  1 cryptoloop
nvidia   6215760  24
ath_rate_sample11808  1
tsdev   7968  0
ath_pci88384  0
snd_intel8x0   32124  1
wlan  183620  3 ath_rate_sample,ath_pci
snd_ac97_codec 92836  1 snd_intel8x0
ath_hal   191504  3 ath_rate_sample,ath_pci
ac97_bus2272  1 snd_ac97_codec
snd_pcm_oss39200  0
snd_mixer_oss  15424  1 snd_pcm_oss
snd_pcm72324  3 snd_intel8x0,snd_ac97_codec,snd_pcm_oss
psmouse36016  0
pcspkr  3104  0
snd_timer  21028  2 snd_seq,snd_pcm
serio_raw   6692  0
i2c_i8018656  0
iTCO_wdt9924  0
rtc12856  0
snd48324  12
snd_seq_oss,snd_rawmidi,snd_seq,snd_seq_device,snd_intel8x0,snd_ac97_codec,
snd_pcm_oss,snd_mixer_oss,snd_pcm,snd_timer
soundcore   7520  1 snd
snd_page_alloc 10056  2 snd_intel8x0,snd_pcm
i2c_core   23552  5 w83781d,eeprom,i2c_isa,nvidia,i2c_i801
shpchp 31060  0
pci_hotplug29184  1 shpchp
intel_agp  23188  1
agpgart31912  2 nvidia,intel_agp
vdev   9312  3
ext3  121288  4
jbd55336  1 ext3
mbcache 8260  1 ext3
dm_mirror  20928  0
dm_snapshot16900  0
dm_mod 52160  9 dm_mirror,dm_snapshot
raid1  22336  2
md_mod 73588  5 raid1
sg 32668  0
sr_mod 16516  0
cdrom  32832  1 sr_mod
ide_disk   16512  3
usb_storage76608  0
generic 4836  0 [permanent]
piix8868  0 [permanent]
ide_core  113764  4 ide_disk,usb_storage,generic,piix
ata_piix   13348  0
skge   38096  0
ata_generic 7556  0
ehci_hcd   30796  0
uhci_hcd   22960  0
floppy 54884  0
usbcore   125416  4 usb_storage,ehci_hcd,uhci_hcd
sd_mod 27136  6
thermal13416  0
processor  31176  1 thermal
fan 4836  0
sata_sx4   12388  0
sata_via   11460  0
sata_promise   12228  5
libata115984  5
ata_piix,ata_generic,sata_sx4,sata_via,sata_promise
scsi_mod  136620  5 sg,sr_mod,usb_storage,sd_mod,libata

-- /etc/kernel-img.conf
# Kernel Image management overrides
# See kernel-img.conf(5) for details
do_symlinks = no
do_initrd = Yes
postinst_hook = /usr/sbin/update-grub
postrm_hook