[blfs-book] [BLFS Trac] #3557: LVM (vgchange) hang & missing /dev/mapper/ entries during initramfs startup

BLFS Trac trac at linuxfromscratch.org
Tue Sep 4 09:20:14 PDT 2012


#3557: LVM (vgchange) hang & missing /dev/mapper/ entries during initramfs startup
--------------------+-------------------------------------------------------
 Reporter:  igmac   |       Owner:  blfs-book@…                                                        
     Type:  defect  |      Status:  new                                                                
 Priority:  high    |   Milestone:  current                                                            
Component:  BOOK    |     Version:  SVN                                                                
 Severity:  major   |    Keywords:  LVM, LVM boot, LVM root, initrd, initrd.img, initramfs, mkinitramfs
--------------------+-------------------------------------------------------
 Summary:

 1. vgchange for mkinitramfs (init.in) needs --noudevsync switch.

 2. /etc/rc.d/init.d/udev needs udevadm trigger --action=change
 --type=devices

 == /usr/share/mkinitramfs/init.in ==

 Refer:
 [http://www.linuxfromscratch.org/blfs/view/svn/postlfs/initramfs.html]

 The generated /usr/share/mkinitramfs/init.in has the following line near
 the bottom (about 5 lines up) shortly before doing switch_root:


 {{{
 if [ -x /sbin/vgchange ] ; then /sbin/vgchange -a y > /dev/null ; fi
 }}}


 I found that this worked fine in some initial tests of an LVM root and LVM
 swap partition (with boot on the root LVM).  I would see the  message:

 2 logical volume(s) in volume group "xx" now active

 However, after creating a more extensive LVM structure, where for example
 /, /boot, swap, /root, /usr, /usr/src, /opt, /var, /var/log and /tmp were
 created, then it would hang on this line.  Specifically, vgchange never
 exited.

 It did output '10 logical volume(s) .... now active' and it did activate
 the volumes. I changed it to 'vgchange -ay &' and added a short rootdelay
 to give it some time to settle.

 After booting the vgchange process was still running, though not using a
 measurable amount of CPU.  It never exited in some 10 minutes of system
 usage on the test machine.

 Digging thorough various similar bug reports on other systems it led me to
 suspect a udev synchronisation issue.  Adding --noudevsync fixed it for
 me.  I would like to recommend modifying the relevant line in
 /usr/share/mkinitramfs/init.in to read:

 {{{
 if [ -x /sbin/vgchange ]; then /sbin/vgchange --noudevsync -ay >
 /dev/null; fi
 }}}


 == Missing LVM volumes in /dev/mapper/ ==

 However after fixing the problem above it failed after switch_root because
 the /dev/mapper/xx-yyyy entries were missing though they had previously
 existed after the first initramfs vgchange -ay. (I seem to remember
 finding they went missing after killing udevd just prior to switch_root)

 I found the message [http://archives.linuxfromscratch.org/mail-archives
 /lfs-support/2012-January/042134.html] and adding the suggested line into
 the udevadm trigger section fixed the problem:

 original code:
 {{{
 # Start the udev daemon to continually watch for, and act on,
 # uevents
 /lib/udev/udevd --daemon

 # Now traverse /sys in order to "coldplug" devices that have
 # already been discovered
 /sbin/udevadm trigger --action=add --type=subsystems
 /sbin/udevadm trigger --action=add --type=devices

 # Now wait for udevd to process the uevents we triggered
 /sbin/udevadm settle

 # If any LVM based partitions are on the system, ensure they
 # are activated so they can be used.
 if [ -x /sbin/vgchange ]; then /sbin/vgchange -a y >/dev/null; fi
 }}}

 add this:

 {{{
 /sbin/udevadm trigger --action=change --type=devices
 }}}

 resulting /etc/rc.d/init.d/udev section:

 {{{
 # Now traverse /sys in order to "coldplug" devices that have
 # already been discovered
 /sbin/udevadm trigger --action=add --type=subsystems
 /sbin/udevadm trigger --action=add --type=devices
 /sbin/udevadm trigger --action=change --type=devices

 # Now wait for udevd to process the uevents we triggered
 /sbin/udevadm settle
 }}}

 PS: udevadm trigger --action defaults to 'change' according to the manual,
 so --action could be left out if you're feeling concise.

 PPS: I flagged it as high priority, major severity as LVM root & boot via
 initrd is a no go without it.  Feel free to adjust if that is incorrect or
 simply bad form.

-- 
Ticket URL: <http://wiki.linuxfromscratch.org/blfs/ticket/3557>
BLFS Trac <http://wiki.linuxfromscratch.org/blfs>
Beyond Linux From Scratch



More information about the blfs-book mailing list