View previous topic :: View next topic |
Author |
Message |
heidar Tux's lil' helper


Joined: 30 Aug 2003 Posts: 135
|
Posted: Sun Jun 10, 2018 6:19 pm Post subject: Genkernel fails when compiling lvm for an initramfs [SOLVED] |
|
|
Hello friends,
I'm installing Gentoo on a fully encrypted hard disk with lvm, so I need an initramfs which supports lvm and luks. I'm using genkernel to try and build an initramfs, however, it fails to compile the lvm step of the initramfs.
Code: |
(chroot) livecd ~ # genkernel --install --no-ramdisk-modules --lvm --luks initramfs
* Gentoo Linux Genkernel; Version 3.4.52.4
* Running with options: --install --no-ramdisk-modules --lvm --luks initramfs
* Using genkernel.conf from /etc/genkernel.conf
* Sourcing arch-specific config.sh from /usr/share/genkernel/arch/x86_64/config.sh ..
* Sourcing arch-specific modules_load from /usr/share/genkernel/arch/x86_64/modules_load ..
* Linux Kernel 4.9.95-gentoo for x86_64...
* .. with config file /usr/share/genkernel/arch/x86_64/generated-config
* busybox: >> Using cache
* initramfs: >> Initializing...
* >> Appending base_layout cpio data...
* >> Appending auxilary cpio data...
* >> Copying keymaps
* >> Appending busybox cpio data...
* >> Appending lvm cpio data...
* LVM: Adding support (compiling binaries)...
* lvm: >> Applying patches...
* - lvm2-2.02.72-no-export-dynamic.patch
* lvm: >> Configuring...
* lvm: >> Compiling...
* ERROR: Failed to compile the "" target...
*
* -- Grepping log... --
*
*DEPS=`echo ../make.tmpl ../VERSION ../Makefile ../include/.symlinks_created | sed -e 's/\\//\\\\\\//g'`; \
*gcc -MM -I. -I../include -DLVM_SHARED_PATH=\"//sbin/lvm\" -DHAVE_CONFIG_H -DDM_IOCTLS -fPIC -fPIC -Wall -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline -Wmissing-noreturn -Wformat-security -Wredundant-decls -Wpointer-arith -O2 -o lvchange.d lvchange.c; \
*sed -i "s/\(.*\)\.o[ :]*/$FILE.o $FILE.d $FILE.pot: $DEPS /g" lvchange.d; \
*[ -s lvchange.d ] || rm -f lvchange.d
*dmeventd.o: In function `_register_for_event':
*dmeventd.c:(.text+0x1bc1): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
*--
*gcc -c -I. -I../include -DHAVE_CONFIG_H -DDM_IOCTLS -fPIC -fPIC -Wall -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline -Wmissing-noreturn -Wformat-security -Wredundant-decls -Wpointer-arith -O2 filters/filter-persistent.c -o filters/filter-persistent.o
*gcc -c -I. -I../include -DHAVE_CONFIG_H -DDM_IOCTLS -fPIC -fPIC -Wall -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline -Wmissing-noreturn -Wformat-security -Wredundant-decls -Wpointer-arith -O2 filters/filter-regex.c -o filters/filter-regex.o
*gcc -c -I. -I../include -DHAVE_CONFIG_H -DDM_IOCTLS -fPIC -fPIC -Wall -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline -Wmissing-noreturn -Wformat-security -Wredundant-decls -Wpointer-arith -O2 filters/filter-sysfs.c -o filters/filter-sysfs.o
*gcc -c -I. -I../include -DHAVE_CONFIG_H -DDM_IOCTLS -fPIC -fPIC -Wall -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline -Wmissing-noreturn -Wformat-security -Wredundant-decls -Wpointer-arith -O2 filters/filter-md.c -o filters/filter-md.o
*filters/filter-sysfs.c: In function ‘_hash_dev’:
*filters/filter-sysfs.c:125:10: warning: implicit declaration of function ‘major’ [-Wimplicit-function-declaration]
* return (major(dev) ^ minor(dev)) & (SET_BUCKETS - 1);
* ^~~~~
*filters/filter-sysfs.c:125:2: warning: nested extern declaration of ‘major’ [-Wnested-externs]
* return (major(dev) ^ minor(dev)) & (SET_BUCKETS - 1);
* ^~~~~~
*filters/filter-sysfs.c:125:23: warning: implicit declaration of function ‘minor’ [-Wimplicit-function-declaration]
* return (major(dev) ^ minor(dev)) & (SET_BUCKETS - 1);
* ^~~~~
*filters/filter-sysfs.c:125:2: warning: nested extern declaration of ‘minor’ [-Wnested-externs]
* return (major(dev) ^ minor(dev)) & (SET_BUCKETS - 1);
* ^~~~~~
*filters/filter-sysfs.c: In function ‘_parse_dev’:
*filters/filter-sysfs.c:176:12: warning: implicit declaration of function ‘makedev’ [-Wimplicit-function-declaration]
* *result = makedev(major, minor);
* ^~~~~~~
*filters/filter-sysfs.c:176:2: warning: nested extern declaration of ‘makedev’ [-Wnested-externs]
*--
*gcc -c -I. -I../include -DLVM_SHARED_PATH=\"//sbin/lvm\" -DHAVE_CONFIG_H -DDM_IOCTLS -fPIC -fPIC -Wall -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline -Wmissing-noreturn -Wformat-security -Wredundant-decls -Wpointer-arith -O2 lvremove.c -o lvremove.o
*gcc -c -I. -I../include -DLVM_SHARED_PATH=\"//sbin/lvm\" -DHAVE_CONFIG_H -DDM_IOCTLS -fPIC -fPIC -Wall -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline -Wmissing-noreturn -Wformat-security -Wredundant-decls -Wpointer-arith -O2 lvrename.c -o lvrename.o
*gcc -c -I. -I../include -DLVM_SHARED_PATH=\"//sbin/lvm\" -DHAVE_CONFIG_H -DDM_IOCTLS -fPIC -fPIC -Wall -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline -Wmissing-noreturn -Wformat-security -Wredundant-decls -Wpointer-arith -O2 lvresize.c -o lvresize.o
*gcc -c -I. -I../include -DLVM_SHARED_PATH=\"//sbin/lvm\" -DHAVE_CONFIG_H -DDM_IOCTLS -fPIC -fPIC -Wall -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline -Wmissing-noreturn -Wformat-security -Wredundant-decls -Wpointer-arith -O2 lvscan.c -o lvscan.o
*lvconvert.c: In function ‘_lvconvert_single’:
*lvconvert.c:1450:10: warning: ‘image_count’ may be used uninitialized in this function [-Wmaybe-uninitialized]
*--
*filter-sysfs.c:(.text+0x31e): undefined reference to `major'
*filter-sysfs.c:(.text+0x32d): undefined reference to `minor'
*../lib/liblvm-internal.a(filter-sysfs.o): In function `_accept_p':
*filter-sysfs.c:(.text+0x4b9): undefined reference to `major'
*filter-sysfs.c:(.text+0x4c6): undefined reference to `minor'
*collect2: error: ld returned 1 exit status
*make[1]: *** [Makefile:135: lvm] Error 1
*make[1]: *** Waiting for unfinished jobs....
*../lib/liblvm-internal.a(sharedlib.o): In function `load_shared_library':
*sharedlib.c:(.text+0x153): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
*--
*filter-sysfs.c:(.text+0x31e): undefined reference to `major'
*filter-sysfs.c:(.text+0x32d): undefined reference to `minor'
*../lib/liblvm-internal.a(filter-sysfs.o): In function `_accept_p':
*filter-sysfs.c:(.text+0x4b9): undefined reference to `major'
*filter-sysfs.c:(.text+0x4c6): undefined reference to `minor'
*collect2: error: ld returned 1 exit status
*make[1]: *** [Makefile:139: lvm.static] Error 1
*make[1]: Leaving directory '/var/tmp/genkernel/32442.6921.31635.14956/LVM2.2.02.88/tools'
*make: *** [make.tmpl:214: tools] Error 2
*--
* Running with options: --install --no-ramdisk-modules --lvm --luks initramfs
* Using genkernel.conf from /etc/genkernel.conf
* Sourcing arch-specific config.sh from /usr/share/genkernel/arch/x86_64/config.sh ..
* Sourcing arch-specific modules_load from /usr/share/genkernel/arch/x86_64/modules_load ..
*
* ERROR: Failed to compile the "" target...
|
I'm not sure what other information is useful to provide here. My Plan B is to just use dracut instead, but I'd prefer to get this working. I haven't been able to find anyone else with a similar problem.
Thanks in advance!
Last edited by heidar on Sun Jun 10, 2018 11:01 pm; edited 1 time in total |
|
Back to top |
|
 |
khayyam Watchman


Joined: 07 Jun 2012 Posts: 6228 Location: Room 101
|
Posted: Sun Jun 10, 2018 7:41 pm Post subject: |
|
|
heidar ...
lvm2-2.02.88 is now ancient, the oldest in the tree being 2.02.116 ... not that this explains why it doesn't build but it's obviously not using a particularly up-to-date version. My own (non-genkernel) initramfs is using 2.02.103 and the tarball has a timestamp of Feb 2014 ... to give some idea of how old 2.02.88 will be.
I've never used genkernel, but my understanding was that it used system installed packages which require USE=static (in the case of lvm2, cryptsetup, etc). In your case it seems to be building those binaries, rather than use those installed via the package manager, and so I'm either wrong (which is quite possible) or this method has changed.
best ... khay |
|
Back to top |
|
 |
heidar Tux's lil' helper


Joined: 30 Aug 2003 Posts: 135
|
Posted: Sun Jun 10, 2018 8:31 pm Post subject: |
|
|
Hi khay,
Thanks for the response. I've just checked the docs, and seems like you're right. That seems like a much more sensible method of approaching this.
I compiled cryptsetup and lvm with the static use flag enabled and retried building an initramfs with genkernel, only to see it try to build lvm again as before, and failing with the same error.
I checked the genkernel script that builds initramfs and it appears to be hard coded to never use the static system lvm binary. /sbin/lvm.static exists on my system.
Code: |
if false && [ -e '/sbin/lvm.static' ]
|
Source
I'm no bash wizard, but looks like it's hardcoded to build the binary now, despite what the documentation says?
Edit: I modified the script to not include false && anymore and it worked fine. |
|
Back to top |
|
 |
khayyam Watchman


Joined: 07 Jun 2012 Posts: 6228 Location: Room 101
|
Posted: Sun Jun 10, 2018 9:30 pm Post subject: |
|
|
heidar wrote: | Code: | if false && [ -e '/sbin/lvm.static' ] |
|
heidar ... the right side of '&&' will only ever be evaluated if the exit status of the left side is zero, and because 'false' will always return a non-zero exit status, it never will.
Code: | % false ; echo $?
1
% false && echo "I succeeded against all odds!!"
% |
heidar wrote: | I'm no bash wizard, but looks like it's hardcoded to build the binary now, despite what the documentation says? |
I didn't look at the code, I'm a little busy at the moment, but it seems to me that the check for lvm.static would never happen, and so yes, "hardcoded" would be one way of putting it.
I have a similar setup (dmcrypt root with lvm volumes within) and use better-initramfs (pre-built downloads). The advantage is that you don't have to build packages with USE=static (as it uses Aboriginal Linux or Alpine Linux as the 'build' tool), it produces small binaries (as everyting is built against uClibc/musl and not glibc), it doesn't need rebuilt on kernel updates ... perhaps take a look
heidar wrote: | Edit: I modified the script to not include false && anymore and it worked fine. |
oh ... you must have edited just as I hit reply.
best ... khay |
|
Back to top |
|
 |
heidar Tux's lil' helper


Joined: 30 Aug 2003 Posts: 135
|
Posted: Sun Jun 10, 2018 11:05 pm Post subject: |
|
|
I'm going to see if I can talk to the maintainers of genkernel about this before switching to another initramfs solution, better-initramfs sounds like a nice solution though.
If anyone else runs into the same issue and wants a workaround:
1. Build lvm/cryptsetup/whatever else with USE=static
2. Edit the genkernel/gen_initramfs.sh script at line 373 and remove the "false && " from the condition
3. Run the genkernel initramfs build again
Thanks again for the help khay! |
|
Back to top |
|
 |
Vulgar n00b

Joined: 15 Sep 2004 Posts: 38
|
Posted: Wed Jun 13, 2018 2:04 am Post subject: |
|
|
Same issue on new install, Lvm breaks initramfs build.
Did one exactly the same last week, no issue with making an initramfs with lvm.
In my case in the gen_initramfs.sh "false &&" was on lines 345 and 355. Getting rid of both allowed genkernel to complete the initramfs and booted fine. |
|
Back to top |
|
 |
pa4wdh Guru

Joined: 16 Dec 2005 Posts: 323
|
Posted: Tue Aug 07, 2018 7:19 pm Post subject: |
|
|
I just had an issue which i solved with the same workaround.
In my case it's a Xen VM, and it's root is provided via LVM. Genkernel compiled everything allright but when booting it couldn't activate my volume group. Since i don't have any modules (everything i need is compiled into the kernel), i could boot with the old initramfs and it worked as expected.
It turned out it now used busybox's lvm implementation, and with the workaround here it used the official lvm2 static binary and everything worked again. _________________ The gentoo way of bringing peace to the world:
USE="-war" emerge --newuse @world
Free as in Freedom is not limited to software only:
Music: http://www.jamendo.com
Recipes: http://www.opensourcefood.com |
|
Back to top |
|
 |
|