How to include veritysetup in initramfs
Issue description
On my qemu arm32 setup with Linux Kernel 4.14 and a simple busybox initramfs setup, I am trying to prepare environment so that I can include "veritysetup" inside initramfs and then execute veritysetup command from initramfs shell, before mounting the real root.
For this reason, I need a static build for cryptsetup. Is there already a pre-built version of static cryptsetup/veritysetup available for arm-linux-gnueabi ? If somebody have built it already please share a copy.
I was trying to build it from source but I am facing build issues on my Ubuntu 16.04 machine.
Steps for reproducing the issue
$ git clone https://gitlab.com/cryptsetup/cryptsetup.git $ ./configure --host=arm-linux-gnueabi --enable-static-cryptsetup --enable-static DEVMAPPER_CFLAGS="-I../lvm_usr/usr/include/" DEVMAPPER_LIBS="-L../lvm_usr/usr/lib/ -ldevmapper" $ make
Build Logs:
/CRYPT/cryptsetup$ make make all-recursive make[1]: Entering directory '/local/mnt/workspace/PINTU/OSS/CRYPT/cryptsetup' Making all in po make[2]: Entering directory '/local/mnt/workspace/PINTU/OSS/CRYPT/cryptsetup/po' make[2]: Nothing to be done for 'all'. make[2]: Leaving directory '/local/mnt/workspace/PINTU/OSS/CRYPT/cryptsetup/po' Making all in tests make[2]: Entering directory '/local/mnt/workspace/PINTU/OSS/CRYPT/cryptsetup/tests' make all-am make[3]: Entering directory '/local/mnt/workspace/PINTU/OSS/CRYPT/cryptsetup/tests' make[3]: Nothing to be done for 'all-am'. make[3]: Leaving directory '/local/mnt/workspace/PINTU/OSS/CRYPT/cryptsetup/tests' make[2]: Leaving directory '/local/mnt/workspace/PINTU/OSS/CRYPT/cryptsetup/tests' make[2]: Entering directory '/local/mnt/workspace/PINTU/OSS/CRYPT/cryptsetup' CCLD cryptsetup.static ./.libs/libcryptsetup.a(libcryptsetup_la-luks2_token.o): In function `crypt_token_load_external': /local/mnt/workspace/PINTU/OSS/CRYPT/cryptsetup/lib/luks2/luks2_token.c:158: warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/bin/ld: cannot find -ldevmapper /usr/bin/ld: cannot find -ludev collect2: error: ld returned 1 exit status Makefile:1663: recipe for target 'cryptsetup.static' failed make[2]: *** [cryptsetup.static] Error 1 make[2]: Leaving directory '/local/mnt/workspace/PINTU/OSS/CRYPT/cryptsetup' Makefile:2507: recipe for target 'all-recursive' failed make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory '/local/mnt/workspace/PINTU/OSS/CRYPT/cryptsetup' Makefile:1169: recipe for target 'all' failed make: *** [all] Error 2
I tried to build lvm2 also from source but that was also giving build errors. So, I got the pre-built lvm from someone and trying to include here.
$ ls ../lvm_usr/usr/lib/ device-mapper/ libdevmapper-event-lvm2snapshot.so libdevmapper-event.so liblvm2app.so.2.2 pkgconfig/ libdevmapper-event-lvm2mirror.so libdevmapper-event-lvm2.so libdevmapper-event.so.1.02 liblvm2cmd.so libdevmapper-event-lvm2raid.so libdevmapper-event-lvm2.so.2.02 liblvm2app.so liblvm2cmd.so.2.02
But it looks like libdevmapper is missing from here.
Additional info
I am using Ubuntu 16.04 and using the arm32 cross-compiler : arm-linux-gnueabi
LVM source: git clone https://github.com/lvmteam/lvm2.git
configure: WARNING: You should install latest cache_check vsn 0.7.0 to use lvm2 cache metadata format 2 configure: WARNING: Unrecognized 'vdoformat' tool is REQUIRED for VDO logical volume creation!
[CC] dmsetup.static
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libselinux.a(seusers.o): In function getseuserbyname': (.text+0x574): warning: Using 'getgrouplist' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libselinux.a(seusers.o): In function
getseuserbyname':
(.text+0x546): warning: Using 'getgrnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libselinux.a(seusers.o): In function getseuserbyname': (.text+0x433): warning: Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libselinux.a(label_file.o): In function
closef':
(.text+0x136): undefined reference to pcre_free' /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libselinux.a(label_file.o): In function
closef':
(.text+0x13f): undefined reference to pcre_free_study' /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libselinux.a(label_file.o): In function
compile_regex.isra.5':
(.text+0x270): undefined reference to pcre_compile' /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libselinux.a(label_file.o): In function
compile_regex.isra.5':
(.text+0x293): undefined reference to pcre_study' /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libselinux.a(label_file.o): In function
lookup':
(.text+0x4dd): undefined reference to pcre_exec' /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libselinux.a(label_file.o): In function
lookup':
(.text+0x546): undefined reference to pcre_exec' /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libselinux.a(label_file.o): In function
process_file':
(.text+0x7e7): undefined reference to pcre_version' /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libselinux.a(label_file.o): In function
process_file':
(.text+0x812): undefined reference to `pcre_version'
collect2: error: ld returned 1 exit status
Makefile:65: recipe for target 'dmsetup.static' failed
make[2]: *** [dmsetup.static] Error 1
make[2]: Leaving directory '/local/mnt/workspace/PINTU/OSS/CRYPT/lvm2/libdm/dm-tools'
../libdm/make.tmpl:315: recipe for target 'dm-tools.device-mapper' failed
make[1]: *** [dm-tools.device-mapper] Error 2
make[1]: Leaving directory '/local/mnt/workspace/PINTU/OSS/CRYPT/lvm2/libdm'
make.tmpl:353: recipe for target 'libdm' failed
make: *** [libdm] Error 2
Debug log
Compilation fail logs for both cryptsetup and lvm2 is shown above.
If additional information is required please let me know. I just need to static version of arm32 cryptsetup which I can execute from initramfs shell.
Or, let me know how to copy these exec/libs directly to initramfs so that we can run it.
Thanks, Pintu