Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
lvm2 & cryptsetup static libs
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
UX.MAN
n00b
n00b


Joined: 09 Mar 2013
Posts: 72

PostPosted: Sat Mar 01, 2014 2:10 am    Post subject: lvm2 & cryptsetup static libs Reply with quote

Hi,

I need to build an initramfs with lvm2 & cryptsetup statically linked. I noticed the recent removal of static and static-libs flags from these packages, so I'm trying to figure out how am I gonna do this initramfs without these flags.
What can I do about it?
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54237
Location: 56N 3W

PostPosted: Sat Mar 01, 2014 10:15 am    Post subject: Reply with quote

UX.MAN,

Build them dynamically, run lddtree on the resulting binaries and include all the required libs in the initrd along with the linker
e.g.

Code:
$ lddtree /sbin/lvm
/sbin/lvm (interpreter => /lib64/ld-linux-x86-64.so.2)
    libdl.so.2 => /lib64/libdl.so.2
    libblkid.so.1 => /lib64/libblkid.so.1
        libuuid.so.1 => /lib64/libuuid.so.1
    libdevmapper-event.so.1.02 => /lib64/libdevmapper-event.so.1.02
    libdevmapper.so.1.02 => /lib64/libdevmapper.so.1.02
        libpthread.so.0 => /lib64/libpthread.so.0
    libreadline.so.6 => /lib64/libreadline.so.6
        libncurses.so.5 => /lib64/libncurses.so.5
    libc.so.6 => /lib64/libc.so.6

_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Tractor Girl
Apprentice
Apprentice


Joined: 16 May 2013
Posts: 159

PostPosted: Sat Mar 01, 2014 1:55 pm    Post subject: Reply with quote

You don't need to build them statically for this setup - genkernel will build fully working initramfs just fine.
Just emerge genkernel with "cryptsetup", and run:
Code:
genkernel --lvm --luks --install initramfs
Back to top
View user's profile Send private message
UX.MAN
n00b
n00b


Joined: 09 Mar 2013
Posts: 72

PostPosted: Sat Mar 08, 2014 9:55 pm    Post subject: Reply with quote

I noticed I should do it that way. I was able to copy all of the required libraries and I am able to decrypt my LUKS encrypted disk; but I am having problems with LVM. vgchange is not finding my volume group called "vg", and so it's not able to mount the new root.

Do you know why this could be happening?
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54237
Location: 56N 3W

PostPosted: Sat Mar 08, 2014 10:37 pm    Post subject: Reply with quote

UX.MAN,

Did you build lvm with USE=static ?
If so you need lvm.static in your initrd.
lvm and all its libs should work too but I've not tested that.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Tractor Girl
Apprentice
Apprentice


Joined: 16 May 2013
Posts: 159

PostPosted: Sun Mar 09, 2014 4:51 pm    Post subject: Reply with quote

Here's my (non-static) setup.
Back to top
View user's profile Send private message
frostschutz
Advocate
Advocate


Joined: 22 Feb 2005
Posts: 2977
Location: Germany

PostPosted: Sun Mar 09, 2014 7:06 pm    Post subject: Re: lvm2 & cryptsetup static libs Reply with quote

UX.MAN wrote:
I noticed the recent removal of static and static-libs flags from these packages


the flags work fine for me
Back to top
View user's profile Send private message
UX.MAN
n00b
n00b


Joined: 09 Mar 2013
Posts: 72

PostPosted: Sun Mar 09, 2014 8:57 pm    Post subject: Reply with quote

@frostschutz, the flags are off when you choose the gnome/systemd profile. I moved back to gnome profile and those flags are back on. I was able to build lvm and cryptsetup statically linked and it works. I'm now having a problem with the exec switch_root when running from BusyBox; my init will drop me directly to an sh session, and when I try to switch_root it's coming back with a kernel panic. I have no idea of what is going on, but I can barely see a message from BusyBox explaining how to use switch_root.

This is my init:

Code:

#!/bin/busybox sh

mount -t proc none /proc
mount -t sysfs none /sys
mount -t devtmpfs none /dev

cryptsetup luksOpen /dev/sda2 enc
lvm vgscan --mknodes
lvm vgchange -ay

mount -o ro /dev/vg/root /mnt/root

umount /proc /sys /dev

exec switch_root /mnt/root /sbin/init
Back to top
View user's profile Send private message
frostschutz
Advocate
Advocate


Joined: 22 Feb 2005
Posts: 2977
Location: Germany

PostPosted: Sun Mar 09, 2014 11:44 pm    Post subject: Reply with quote

If you're using systemd, I think you have to exec something other than sbin/init, but I'm not sure as I've never used systemd myself.
Back to top
View user's profile Send private message
UX.MAN
n00b
n00b


Joined: 09 Mar 2013
Posts: 72

PostPosted: Mon Mar 10, 2014 12:10 am    Post subject: Reply with quote

As I said, I was on the systemd's profile, but I switched back to the OpenRC (default) profile. So, I'm now on the OpenRC profile, /sbin/init is totally valid, but still getting a kernel panic when BusyBox tries to execute init.
Back to top
View user's profile Send private message
UX.MAN
n00b
n00b


Joined: 09 Mar 2013
Posts: 72

PostPosted: Mon Mar 10, 2014 5:55 pm    Post subject: Reply with quote

@Tractor Girl
Your configuration works like a charm! I will start using the genkernel initramfs image from now on; it saves a lot of time and effort. Thanks for helping me on this!
Back to top
View user's profile Send private message
Tractor Girl
Apprentice
Apprentice


Joined: 16 May 2013
Posts: 159

PostPosted: Tue Mar 11, 2014 12:03 am    Post subject: Reply with quote

Glad I could help :)
Back to top
View user's profile Send private message
SamuliSuominen
Retired Dev
Retired Dev


Joined: 30 Sep 2005
Posts: 2133
Location: Finland

PostPosted: Tue Mar 11, 2014 7:47 am    Post subject: Re: lvm2 & cryptsetup static libs Reply with quote

UX.MAN wrote:
Hi,

I need to build an initramfs with lvm2 & cryptsetup statically linked. I noticed the recent removal of static and static-libs flags from these packages, so I'm trying to figure out how am I gonna do this initramfs without these flags.
What can I do about it?


While your setup doesn't need USE="static static-libs", and you should in fact be copying the required libraries to the initramfs like pointed out in this thread earlier, I'd just like to add you are wrong and the flags have not been removed:

Code:

[ebuild     U  ] sys-fs/cryptsetup-1.6.4 [1.6.3] USE="gcrypt nls python udev -kernel -nettle -openssl -reencrypt -static -static-libs -urandom" PYTHON_SINGLE_TARGET="python2_7 -python2_6" PYTHON_TARGETS="python2_7 -python2_6" 1,057 kB
[ebuild   R    ]  sys-fs/lvm2-2.02.105-r2  USE="readline thin udev -clvm -cman -device-mapper-only -lvm1 -lvm2create_initrd (-selinux) -static -static-libs" 0 kB
Back to top
View user's profile Send private message
UX.MAN
n00b
n00b


Joined: 09 Mar 2013
Posts: 72

PostPosted: Wed Mar 12, 2014 1:35 pm    Post subject: Reply with quote

I think the flags where removed from the gnome/systemd profile, somehow. I can't check right now, but I'm quite sure those flags where disabled on that profile; am I incorrect? I will try it as soon as I reach home.
Now that you bring this up, I would like to ask you about my init script. It's failing to switch_root when I try with my custom script; after
Code:
exec switch_root /mnt/root /sbin/init
is executed, BusyBox is coming back with a message explaining how to use s[/code]witch_root. I have no clue as per why this is happening, but I suspect that I'm missing something in the initramfs.
Back to top
View user's profile Send private message
SamuliSuominen
Retired Dev
Retired Dev


Joined: 30 Sep 2005
Posts: 2133
Location: Finland

PostPosted: Wed Mar 12, 2014 1:45 pm    Post subject: Reply with quote

UX.MAN wrote:
I think the flags where removed from the gnome/systemd profile


nod, sys-apps/systemd doesn't have USE="static-libs" to compile 'libudev.a' static archive for building cryptsetup and lvm2, therefore the profile masks the flags
makes sense


Last edited by SamuliSuominen on Wed Mar 12, 2014 3:06 pm; edited 1 time in total
Back to top
View user's profile Send private message
UX.MAN
n00b
n00b


Joined: 09 Mar 2013
Posts: 72

PostPosted: Wed Mar 12, 2014 1:56 pm    Post subject: Reply with quote

Well, that would make sense. As you may have noticed, I am not pointing out that the init script is trying to run systemd as it's replacing init, but rather running OpenRC. So I will leave systemd apart for a moment and work on OpenRC; it is likely that the switch_root command is, somehow, unable to find the new init or it is not capable of parsing it. Did you ever come across this issue? Do you think this is a syntax issue?
Back to top
View user's profile Send private message
puchu
n00b
n00b


Joined: 15 Feb 2005
Posts: 15

PostPosted: Mon Aug 25, 2014 11:55 pm    Post subject: Reply with quote

you could also just create a shell in your init script and type in the commands on the cmd line and see why it breaks

busybox --install -s
exec setsid sh -c 'exec sh </dev/tty1 >/dev/tty1 2>&1'
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum