linux-lvm.redhat.com archive mirror
 help / color / mirror / Atom feed
* [linux-lvm] Update to lvm2create_initrd
@ 2006-11-11 11:18 Douglas Mayle
  2006-11-14 17:02 ` Alasdair G Kergon
  0 siblings, 1 reply; 7+ messages in thread
From: Douglas Mayle @ 2006-11-11 11:18 UTC (permalink / raw)
  To: LVM

[-- Attachment #1: Type: text/plain, Size: 326 bytes --]

I've made an update to the lvm2create_initrd script that fixes some  
problems with ldd output that were never addressed in the first  
version (e.g. libraries linked with a static path).

I also check for binaries in the path, rather than hardcoding their  
location, and I've added support for the Gentoo style of MAKEDEV.


[-- Attachment #2: lvm2create_initrd.patch --]
[-- Type: application/octet-stream, Size: 1292 bytes --]

--- lvm2create_initrd.orig	2006-11-10 21:32:53.000000000 +0100
+++ lvm2create_initrd	2006-11-10 21:35:42.000000000 +0100
@@ -52,7 +52,7 @@
 DEVRAM=/tmp/initrd.$$
 
 # set defaults
-BINFILES=${BINFILES:-"/lib/lvm-200/lvm /bin/bash /bin/busybox /sbin/pivot_root"}
+BINFILES=${BINFILES:-"`which lvm` `which bash` `which busybox` `which pivot_root`"}
 BASICDEVICES=${BASICDEVICES:-"std consoleonly fd"}
 BLOCKDEVICES=${BLOCKDEVICES:-"md hda hdb hdc hdd sda sdb sdc sdd"}
 MAKEDEV=${MAKEDEV:-"debian"}
@@ -269,7 +269,7 @@
 # Figure out which shared libraries we actually need in our initrd
 echo "$cmd -- finding required shared libraries"
 verbose "BINFILES: `echo $BINFILES`"
-LIBFILES=`ldd $BINFILES 2>/dev/null | awk '{if (/=>/) { print $3 }}' | sort -u`
+LIBFILES=`ldd $BINFILES 2>/dev/null |grep -v linux-gate |grep -v : | awk '{if (/=>/) { print $3 } else if (/\//) { print $1 }}' | sort -u`
 if [ $? -ne 0 ]; then
    echo "$cmd -- ERROR figuring out needed shared libraries"
    exit 1
@@ -356,6 +356,10 @@
     (cd $TMPMNT/dev; /dev/MAKEDEV $OPT_Q -d $TMPMNT/dev -m 2)
     RETCODE=$?
     ;;
+gentoo)
+    (cd $TMPMNT/dev; /usr/sbin/MAKEDEV $OPT_Q $BASICDEVICES $BLOCKDEVICES)
+    RETCODE=$?
+    ;;
 *)
     echo "$cmd -- ERROR: $MAKEDEV is not a known MAKEDEV style."
     RETCODE=1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [linux-lvm] Update to lvm2create_initrd
  2006-11-11 11:18 [linux-lvm] Update to lvm2create_initrd Douglas Mayle
@ 2006-11-14 17:02 ` Alasdair G Kergon
  2006-11-14 17:49   ` Douglas Mayle
  0 siblings, 1 reply; 7+ messages in thread
From: Alasdair G Kergon @ 2006-11-14 17:02 UTC (permalink / raw)
  To: Douglas Mayle; +Cc: Jeff Layton, LVM

On Sat, Nov 11, 2006 at 12:18:39PM +0100, Douglas Mayle wrote:
> I've made an update to the lvm2create_initrd script that fixes some  
> problems with ldd output that were never addressed in the first  
> version (e.g. libraries linked with a static path).
 
> I also check for binaries in the path, rather than hardcoding their  
> location, and I've added support for the Gentoo style of MAKEDEV.


Please update the changelog.

Can someone confirm the updated script also still works on Debian?


-BINFILES=${BINFILES:-"/lib/lvm-200/lvm /bin/bash /bin/busybox /sbin/pivot_root"}
+BINFILES=${BINFILES:-"`which lvm` `which bash` `which busybox` `which pivot_root`"}

Will 'which lvm' always give the same answer as before on Debian,
or, if not, does it matter?


-LIBFILES=`ldd $BINFILES 2>/dev/null | awk '{if (/=>/) { print $3 }}' | sort -u`
+LIBFILES=`ldd $BINFILES 2>/dev/null |grep -v linux-gate |grep -v : | awk '{if (/=>/) { print $3 } else if (/\//) { print $1 }}' | sort -u`

This needs a comment explaining what's going on (e.g. include sample 
output in the comment).  What's special about linux-gate?
And why not combine the two greps?  -E (linux-gate|:)

Alasdair
-- 
agk@redhat.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [linux-lvm] Update to lvm2create_initrd
  2006-11-14 17:02 ` Alasdair G Kergon
@ 2006-11-14 17:49   ` Douglas Mayle
  2006-11-20 19:37     ` Douglas Mayle
  0 siblings, 1 reply; 7+ messages in thread
From: Douglas Mayle @ 2006-11-14 17:49 UTC (permalink / raw)
  To: Alasdair G Kergon; +Cc: Jeff Layton, LVM

[-- Attachment #1: Type: text/plain, Size: 927 bytes --]

On Tue, Nov 14, 2006 at 05:02:47PM +0000, Alasdair G Kergon wrote:
> Please update the changelog.
> 
> Can someone confirm the updated script also still works on Debian?
> 
> 
> -BINFILES=${BINFILES:-"/lib/lvm-200/lvm /bin/bash /bin/busybox /sbin/pivot_root"}
> +BINFILES=${BINFILES:-"`which lvm` `which bash` `which busybox` `which pivot_root`"}
> 
> Will 'which lvm' always give the same answer as before on Debian,
> or, if not, does it matter?
> 
> 
> -LIBFILES=`ldd $BINFILES 2>/dev/null | awk '{if (/=>/) { print $3 }}' | sort -u`
> +LIBFILES=`ldd $BINFILES 2>/dev/null |grep -v linux-gate |grep -v : | awk '{if (/=>/) { print $3 } else if (/\//) { print $1 }}' | sort -u`
> 
> This needs a comment explaining what's going on (e.g. include sample 
> output in the comment).  What's special about linux-gate?
> And why not combine the two greps?  -E (linux-gate|:)
> 
> Alasdair
> -- 
> agk@redhat.com
Done

Douglas Mayle

[-- Attachment #2: lvm2create_initrd.patch --]
[-- Type: text/plain, Size: 3025 bytes --]

--- lvm2create_initrd.orig	2006-11-14 18:26:08.000000000 +0100
+++ lvm2create_initrd	2006-11-14 18:47:11.000000000 +0100
@@ -29,6 +29,8 @@
 #               PATH entries to /sbin/init shell script so chroot works without /usr mounted. Remove
 #               mkdir /initrd so we don't cause problems if root filesystem is corrupted. -- Jeff Layton
 # 15/05/2004	initial support for modules, create lvm.conf from lvm dumpconfig, other cleanups -- Jeff Layton
+# 14/11/2006	Update handling of ldd output to handle hardcoded library links and virtual dll linux-gate.
+#		Add support for Gentoo-style MAKEDEV. Remove hardcoded BINUTILS paths -- Douglas Mayle
 #
 # Copyright Miguel Cabeca, Jeffrey Layton, 2004
 #
@@ -52,7 +54,7 @@
 DEVRAM=/tmp/initrd.$$
 
 # set defaults
-BINFILES=${BINFILES:-"/lib/lvm-200/lvm /bin/bash /bin/busybox /sbin/pivot_root"}
+BINFILES=${BINFILES:-"`which lvm` `which bash` `which busybox` `which pivot_root`"}
 BASICDEVICES=${BASICDEVICES:-"std consoleonly fd"}
 BLOCKDEVICES=${BLOCKDEVICES:-"md hda hdb hdc hdd sda sdb sdc sdd"}
 MAKEDEV=${MAKEDEV:-"debian"}
@@ -269,7 +271,27 @@
 # Figure out which shared libraries we actually need in our initrd
 echo "$cmd -- finding required shared libraries"
 verbose "BINFILES: `echo $BINFILES`"
-LIBFILES=`ldd $BINFILES 2>/dev/null | awk '{if (/=>/) { print $3 }}' | sort -u`
+
+# We need to strip certain lines from ldd output.  This is the full output of an example ldd:
+#lvmhost~ # ldd /sbin/lvm /bin/bash
+#/sbin/lvm:
+#        not a dynamic executable
+#/bin/bash:
+#        linux-gate.so.1 =>  (0xbfffe000)
+#        libncurses.so.5 => /lib/libncurses.so.5 (0xb7ee3000)
+#        libdl.so.2 => /lib/libdl.so.2 (0xb7edf000)
+#        libc.so.6 => /lib/libc.so.6 (0xb7dc1000)
+#        /lib/ld-linux.so.2 (0xb7f28000)
+#
+# 1) Lines with a ":" contain the name of the original binary we're examining, and so are unnecessary.
+#    We need to strip them because they contain "/", and can be confused with links with a hardcoded path.
+# 2) The linux-gate library is a virtual dll that does not exist on disk, but is instead loaded automatically
+#    into the process space, and can't be copied to the ramdisk
+#
+# After these lines have been stripped, we're interested in the lines remaining if they
+# 1) Contain "=>" because they are pathless links, and the value following the token is the path on the disk
+# 2) Contain "/" because it's a link with a hardcoded path, and so we're interested in the link itself.
+LIBFILES=`ldd $BINFILES 2>/dev/null |grep -v -E \(linux-gate\|:\) | awk '{if (/=>/) { print $3 } else if (/\//) { print $1 }}' | sort -u`
 if [ $? -ne 0 ]; then
    echo "$cmd -- ERROR figuring out needed shared libraries"
    exit 1
@@ -356,6 +378,10 @@
     (cd $TMPMNT/dev; /dev/MAKEDEV $OPT_Q -d $TMPMNT/dev -m 2)
     RETCODE=$?
     ;;
+gentoo)
+    (cd $TMPMNT/dev; /usr/sbin/MAKEDEV $OPT_Q $BASICDEVICES $BLOCKDEVICES)
+    RETCODE=$?
+    ;;
 *)
     echo "$cmd -- ERROR: $MAKEDEV is not a known MAKEDEV style."
     RETCODE=1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [linux-lvm] Update to lvm2create_initrd
  2006-11-14 17:49   ` Douglas Mayle
@ 2006-11-20 19:37     ` Douglas Mayle
  2006-11-21 22:39       ` Alasdair G Kergon
  0 siblings, 1 reply; 7+ messages in thread
From: Douglas Mayle @ 2006-11-20 19:37 UTC (permalink / raw)
  To: LVM general discussion and development; +Cc: Jeff Layton, Alasdair G Kergon

[-- Attachment #1: Type: text/plain, Size: 487 bytes --]

To follow up, I've made the requested changes to my patch.  I was  
wondering if the changes are sufficient, or there needs to be more  
work?  If so, please let me know.
I'd really like to see this get committed, as I often see people  
having all sorts of problems generating lvm2 initrd images, and they  
perform all sorts of hacks just to get it working.  These couple of  
lines make all that extra work unnecessary, and the script shouldn't  
be changed for older distributions.


[-- Attachment #2: lvm2create_initrd.patch --]
[-- Type: text/plain, Size: 3025 bytes --]

--- lvm2create_initrd.orig	2006-11-14 18:26:08.000000000 +0100
+++ lvm2create_initrd	2006-11-14 18:47:11.000000000 +0100
@@ -29,6 +29,8 @@
 #               PATH entries to /sbin/init shell script so chroot works without /usr mounted. Remove
 #               mkdir /initrd so we don't cause problems if root filesystem is corrupted. -- Jeff Layton
 # 15/05/2004	initial support for modules, create lvm.conf from lvm dumpconfig, other cleanups -- Jeff Layton
+# 14/11/2006	Update handling of ldd output to handle hardcoded library links and virtual dll linux-gate.
+#		Add support for Gentoo-style MAKEDEV. Remove hardcoded BINUTILS paths -- Douglas Mayle
 #
 # Copyright Miguel Cabeca, Jeffrey Layton, 2004
 #
@@ -52,7 +54,7 @@
 DEVRAM=/tmp/initrd.$$
 
 # set defaults
-BINFILES=${BINFILES:-"/lib/lvm-200/lvm /bin/bash /bin/busybox /sbin/pivot_root"}
+BINFILES=${BINFILES:-"`which lvm` `which bash` `which busybox` `which pivot_root`"}
 BASICDEVICES=${BASICDEVICES:-"std consoleonly fd"}
 BLOCKDEVICES=${BLOCKDEVICES:-"md hda hdb hdc hdd sda sdb sdc sdd"}
 MAKEDEV=${MAKEDEV:-"debian"}
@@ -269,7 +271,27 @@
 # Figure out which shared libraries we actually need in our initrd
 echo "$cmd -- finding required shared libraries"
 verbose "BINFILES: `echo $BINFILES`"
-LIBFILES=`ldd $BINFILES 2>/dev/null | awk '{if (/=>/) { print $3 }}' | sort -u`
+
+# We need to strip certain lines from ldd output.  This is the full output of an example ldd:
+#lvmhost~ # ldd /sbin/lvm /bin/bash
+#/sbin/lvm:
+#        not a dynamic executable
+#/bin/bash:
+#        linux-gate.so.1 =>  (0xbfffe000)
+#        libncurses.so.5 => /lib/libncurses.so.5 (0xb7ee3000)
+#        libdl.so.2 => /lib/libdl.so.2 (0xb7edf000)
+#        libc.so.6 => /lib/libc.so.6 (0xb7dc1000)
+#        /lib/ld-linux.so.2 (0xb7f28000)
+#
+# 1) Lines with a ":" contain the name of the original binary we're examining, and so are unnecessary.
+#    We need to strip them because they contain "/", and can be confused with links with a hardcoded path.
+# 2) The linux-gate library is a virtual dll that does not exist on disk, but is instead loaded automatically
+#    into the process space, and can't be copied to the ramdisk
+#
+# After these lines have been stripped, we're interested in the lines remaining if they
+# 1) Contain "=>" because they are pathless links, and the value following the token is the path on the disk
+# 2) Contain "/" because it's a link with a hardcoded path, and so we're interested in the link itself.
+LIBFILES=`ldd $BINFILES 2>/dev/null |grep -v -E \(linux-gate\|:\) | awk '{if (/=>/) { print $3 } else if (/\//) { print $1 }}' | sort -u`
 if [ $? -ne 0 ]; then
    echo "$cmd -- ERROR figuring out needed shared libraries"
    exit 1
@@ -356,6 +378,10 @@
     (cd $TMPMNT/dev; /dev/MAKEDEV $OPT_Q -d $TMPMNT/dev -m 2)
     RETCODE=$?
     ;;
+gentoo)
+    (cd $TMPMNT/dev; /usr/sbin/MAKEDEV $OPT_Q $BASICDEVICES $BLOCKDEVICES)
+    RETCODE=$?
+    ;;
 *)
     echo "$cmd -- ERROR: $MAKEDEV is not a known MAKEDEV style."
     RETCODE=1

[-- Attachment #3: Type: text/plain, Size: 1 bytes --]



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [linux-lvm] Update to lvm2create_initrd
  2006-11-20 19:37     ` Douglas Mayle
@ 2006-11-21 22:39       ` Alasdair G Kergon
  2006-11-21 22:44         ` Alasdair G Kergon
  0 siblings, 1 reply; 7+ messages in thread
From: Alasdair G Kergon @ 2006-11-21 22:39 UTC (permalink / raw)
  To: Douglas Mayle; +Cc: Jeff Layton, LVM general discussion and development

On Mon, Nov 20, 2006 at 08:37:11PM +0100, Douglas Mayle wrote:
> I'd really like to see this get committed, 

Well I was waiting for confirmation from someone using Debian that the changes
don't break anything.  But I think I've waited long enough now so I'll just
commit it, and if anything does break we'll fix it later.

Alasdair
-- 
agk@redhat.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [linux-lvm] Update to lvm2create_initrd
  2006-11-21 22:39       ` Alasdair G Kergon
@ 2006-11-21 22:44         ` Alasdair G Kergon
  2006-11-26 15:11           ` Jeff Layton
  0 siblings, 1 reply; 7+ messages in thread
From: Alasdair G Kergon @ 2006-11-21 22:44 UTC (permalink / raw)
  To: Douglas Mayle, LVM general discussion and development,
	Jeff Layton

On Tue, Nov 21, 2006 at 10:39:19PM +0000, Alasdair G Kergon wrote:
> Well I was waiting for confirmation from someone using Debian that the changes
> don't break anything.  But I think I've waited long enough now so I'll just
> commit it, and if anything does break we'll fix it later.
 
See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=324162 :-)

Reported over a year ago.

Alasdair
-- 
agk@redhat.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [linux-lvm] Update to lvm2create_initrd
  2006-11-21 22:44         ` Alasdair G Kergon
@ 2006-11-26 15:11           ` Jeff Layton
  0 siblings, 0 replies; 7+ messages in thread
From: Jeff Layton @ 2006-11-26 15:11 UTC (permalink / raw)
  To: Douglas Mayle, LVM general discussion and development,
	Jeff Layton

Alasdair G Kergon wrote:
> On Tue, Nov 21, 2006 at 10:39:19PM +0000, Alasdair G Kergon wrote:
>> Well I was waiting for confirmation from someone using Debian that the changes
>> don't break anything.  But I think I've waited long enough now so I'll just
>> commit it, and if anything does break we'll fix it later.
>  
> See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=324162 :-)
> 
> Reported over a year ago.
> 
> Alasdair

Sorry I haven't chimed in sooner. This patch seems reasonable to me. I 
haven't used this script for some time as I don't have any Debian 
machines at the moment. Doug, you're welcome to take over maintainership 
of it if you're willing :-)

-- Jeff

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-11-26 15:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-11 11:18 [linux-lvm] Update to lvm2create_initrd Douglas Mayle
2006-11-14 17:02 ` Alasdair G Kergon
2006-11-14 17:49   ` Douglas Mayle
2006-11-20 19:37     ` Douglas Mayle
2006-11-21 22:39       ` Alasdair G Kergon
2006-11-21 22:44         ` Alasdair G Kergon
2006-11-26 15:11           ` Jeff Layton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).