Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Installing Gentoo
  • Search

Genkernel fails when compiling lvm for an initramfs [SOLVED]

Having problems with the Gentoo Handbook? If you're still working your way through it, or just need some info before you start your install, this is the place. All other questions go elsewhere.
Post Reply
Advanced search
7 posts • Page 1 of 1
Author
Message
baak6
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 141
Joined: Sat Aug 30, 2003 11:34 pm

Genkernel fails when compiling lvm for an initramfs [SOLVED]

  • Quote

Post by baak6 » Sun Jun 10, 2018 6:19 pm

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: Select all

(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 baak6 on Sun Jun 10, 2018 11:01 pm, edited 1 time in total.
Top
khayyam
Watchman
Watchman
User avatar
Posts: 6227
Joined: Thu Jun 07, 2012 2:45 am
Location: Room 101

  • Quote

Post by khayyam » Sun Jun 10, 2018 7:41 pm

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
Top
baak6
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 141
Joined: Sat Aug 30, 2003 11:34 pm

  • Quote

Post by baak6 » Sun Jun 10, 2018 8:31 pm

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: Select all

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.
Top
khayyam
Watchman
Watchman
User avatar
Posts: 6227
Joined: Thu Jun 07, 2012 2:45 am
Location: Room 101

  • Quote

Post by khayyam » Sun Jun 10, 2018 9:30 pm

[profile]28559[/profile] wrote:

Code: Select all

if false && [ -e '/sbin/lvm.static' ]
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: Select all

% false ; echo $?
1
% false && echo "I succeeded against all odds!!"
%
[profile]28559[/profile] 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
[profile]28559[/profile] 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
Top
baak6
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 141
Joined: Sat Aug 30, 2003 11:34 pm

  • Quote

Post by baak6 » Sun Jun 10, 2018 11:05 pm

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!
Top
Vulgar
n00b
n00b
Posts: 63
Joined: Wed Sep 15, 2004 3:26 pm

  • Quote

Post by Vulgar » Wed Jun 13, 2018 2:04 am

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.
Top
pa4wdh
Veteran
Veteran
Posts: 1015
Joined: Fri Dec 16, 2005 6:55 pm

  • Quote

Post by pa4wdh » Tue Aug 07, 2018 7:19 pm

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

My shared code repository: https://code.pa4wdh.nl.eu.org
Music, Free as in Freedom: https://www.jamendo.com
Top
Post Reply

7 posts • Page 1 of 1

Return to “Installing Gentoo”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic