Speed up LVM-activation
authorPeter Hjalmarsson <xake@rymdraket.net>
Sun, 30 Jan 2011 21:48:54 +0000 (22:48 +0100)
committerSebastian Pipping <sebastian@pipping.org>
Mon, 31 Jan 2011 11:40:26 +0000 (12:40 +0100)
Change vgscan and vgchange so they are done in one go.
Faster since less work for the lvm command.
vgscan is still needed for some cases like dmcrypt where
/etc/lvm/cache is created, but not updated with the unlocked devices.

defaults/initrd.scripts
defaults/linuxrc

index 9a5e812258d835e45848609ebb628792e4fcd922..30d1a98f6def2eb3c09671e13bdf669a9e21bab9 100755 (executable)
@@ -632,17 +632,22 @@ startVolumes() {
 
        if [ "${USE_LVM_NORMAL}" = '1' ]
        then
-               if [ -e '/bin/vgscan' -a -e '/bin/vgchange' ]
+               if [ -e '/bin/lvm' ]
                then
                        for dev in ${RAID_DEVICES}
                        do
                                setup_md_device "${dev}"
                        done
 
-                       good_msg "Scanning for Volume Groups"
-                       /bin/vgscan --ignorelockingfailure --mknodes 2>/dev/null
-                       good_msg "Activating Volume Groups"
-                       /bin/vgchange -ay --sysinit 2>/dev/null
+                       # This is needed for /bin/lvm to accept the following logic
+                       lvm_commands="#! /bin/lvm"
+                       # If there is a cahe, update it. Unbreak at least dmcrypt
+                       [ -d /etc/lvm/cache ] && lvm_commands="$lvm_commands \nvgscan"
+                       # To activate volumegroups on all devices in the cache
+                       lvm_commands="$lvm_commands \nvgchange -ay --sysinit"
+                       # And finally execute it all (/proc/... needed if lvm is compiled without readline)
+                       good_msg "Scanning for and activating Volume Groups"
+                       printf "%b\n" "$lvm_commands" | /bin/lvm /proc/self/fd/0
 
                        # Disable EVMS since lvm is activated and they dont work together.
                        if [ "${USE_EVMS_NORMAL}" = '1' ]
index 0083fce1eda17ab0e835f6b6874acd4d20911ed1..ecfb546ad9fa6079fcdb65f2ad84ced5d36114e9 100755 (executable)
@@ -31,12 +31,6 @@ then
        [ -e /linuxrc ] && rm /linuxrc
 fi
 
-if [ -e /bin/lvm ]
-then
-       [ -e /bin/vgscan   ] || ln -s /bin/lvm /bin/vgscan
-       [ -e /bin/vgchange ] || ln -s /bin/lvm /bin/vgchange
-fi
-
 quiet_kmsg
 
 CMDLINE=`cat /proc/cmdline`