LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 11-05-2014, 01:50 PM   #1
MEC75
LQ Newbie
 
Registered: Jul 2008
Posts: 15

Rep: Reputation: 0
Question custom kernel initrd for LVM on LUKS


Hi,

My configuration:
/dev/sda1 /dev/sda2 Windows partitions
/dev/sda3 /boot (ext2)
/dev/sda4 luks
inside luks LVM is used:
/dev/mapper/cryptvg-root
/dev/mapper/cryptvg-home
/dev/mapper/cryptvg-swap

system: Slackware 14.0, kernel 3.2.29 with initrd

The whole configuration was before without luks/LVM. Everything was on backup, partitions deleted and converted to LUKS/LVM, copied back from backup.
Everything works like before with kernel 3.2.29 (original one from Slackware) with the initrd made following the Readme from Slackware.
However, before I was using kernel 3.16.0 which worked fine too without any initrd. Now I need an initrd for the luks/LVM part, but I can't get it to work.
The initrd for 3.16.0 was made the same way like for 3.2.29, it boots and asks for the luks password. But after that it says it can't find /dev/mapper/cryptvg-root and mount it at /mnt and gives me a prompt.
There I see /dev/mapper/lukssda4 is created, however using lvm doesn't detect anything.
Do I miss something to be included in the initrd to have lvm work? Or any other ideas what could be the problem here?
 
Old 11-06-2014, 12:18 AM   #2
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,858

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
Well, what was your mkinitrd command line?
 
Old 11-06-2014, 02:39 PM   #3
MEC75
LQ Newbie
 
Registered: Jul 2008
Posts: 15

Original Poster
Rep: Reputation: 0
For 3.2.29:
mkinitrd -c -k 3.2.29 -m ext4 -f ext4 -r /dev/mapper/cryptvg-root -C /dev/sda4 -L

and for 3.16.0:
mkinitrd -c -k 3.16.0 -f ext4 -r /dev/mapper/cryptvg-root -m ext4 -C /dev/sda4 -L -o /boot/initrd-3.16.0.gz


looking to initrd-tree for both, I can't see any difference. Both have the same modules included. Maybe something compiled into the kernel not as module is missing?

As I said, using 3.16.0 with the above initrd, I can put in the password, /dev/mapper/lukssda4 is created, lvm is in the initrd - but scanning for any volume doesn't find anything (lvm pvscan, lvm lvscan, lvm vgscan all report nothing found).

Last edited by MEC75; 11-06-2014 at 03:41 PM.
 
Old 11-06-2014, 07:26 PM   #4
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,858

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
Assuming that you are able to boot into your 3.16.0 system somehow, what is the output of
Code:
/usr/share/mkinitrd/mkinitrd_command_generator.sh
when run as root? (If that's how you generated the command in the first place, there's no reason to run it again just for me. )
 
Old 11-06-2014, 09:42 PM   #5
MEC75
LQ Newbie
 
Registered: Jul 2008
Posts: 15

Original Poster
Rep: Reputation: 0
No, unfortunately I can't boot 3.16.0 - /root and /home are within the luks partition.

I haven't run mkinitrd_command_generator.sh on 3.16 before, only on 3.2.29 to see what it says but which was identical to the above command line I posted, which was originally taken from README_CRYPT.TXT which came with Slackware14.0 .


Since "cryptsetup luksOpen" works I assume that this part is fine. Also /dev/mapper/lukssda4 (or whatever is used with cryptsetup) is generated so dev-mapper should be ok too. Seems to me something LVM related is missing in the kernel since it can't find any volumes.
Do you know what is needed in the kernel to have LVM working? ("device-mapper support" and "crypt target support" are compiled in)
 
Old 11-07-2014, 09:17 AM   #6
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,858

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
According to the diff of the two, there isn't a major difference between the 14.0 and 14.1 versions of mkinitrd_command_generator.sh; nothing that would impact LUKS use.

If you are using the generic kernel, it has all that is needed to get LVM up and running. (I'm booting Slackware61 14.1 with / mounted on a logical volume.)

When you get the prompt, what you see after running
Code:
/sbin/vgchange -ay --ignorelockingfailure
/sbin/udevadm settle --timeout=10
/sbin/pvscan
 
Old 11-07-2014, 10:42 AM   #7
MEC75
LQ Newbie
 
Registered: Jul 2008
Posts: 15

Original Poster
Rep: Reputation: 0
Yes, with the generic 3.2.29 which comes with Slackware everything works fine.
I was also able to boot into 3.16 creating a minimal USB based root-file system based on the current system but with the 3.16 kernel and the initrd for 3.16 (but without unlocking luks in initrd since it's not used for /). Once booted to 3.16 from USB, I can use cryptsetup, vgscan --mknodes, vgchange -ay, then chroot to the original / on the LUKS/LVM and then using mkinitrd_command_generator.sh. The line returned is basically the same I used only includes some additional USB modules.
So I'm a bit puzzled now. Seems the kernel itself has everything in there otherwise I couldn't open the LVM after the USB boot, but using the initrd alone for unlocking lvm doesn't work.

Here the output of the commands you asked for after the emergency prompt when try to boot 3.16.0 with initrd and / on luks/lvm:

vgchange: "No volume goups found"
vgscan: "No volume groups found"
udevadm: No output
/sbin/pvscan: doesn't exist
lvm pvscan: "No matching physical volumes found"


in comparison from a running system:
vgchange: "3 logical volume(s) in volume group "cryptvg" now active"
vgscan: "Found volume group "cryptvg" using metadata type lvm2"
udevadm: no output
pvscan:
PV /dev/mapper/lukssda4 VG cryptvg lvm2 [417.63 GiB / 0 free]
Total: 1 [417.63 GiB] / in use: 1 [417.63 GiB] / in no VG: 0 [0 ]

Last edited by MEC75; 11-07-2014 at 12:53 PM.
 
Old 11-07-2014, 04:22 PM   #8
gegechris99
Senior Member
 
Registered: Oct 2005
Location: France
Distribution: Slackware 15.0 64bit
Posts: 1,160
Blog Entries: 5

Rep: Reputation: 392Reputation: 392Reputation: 392Reputation: 392
Hello MEC75,

As you mention that you use a custom kernel, did you compile it with the following configuration (taken from README_CRYPT.TXT)?
Quote:
A note on custom kernels
------------------------

If you want to compile your own custom kernel to work with LUKS encrypted
partitions, you need to enable at least the following two options in your
kernel configuration:

Multiple devices driver support (RAID and LVM) --->
<*> Device mapper support
<*> Crypt target support

This is equivalent to the following options in your .config file:

CONFIG_BLK_DEV_DM=y
CONFIG_DM_CRYPT=y

Do not compile these as module! They are required in your kernel
.
 
Old 11-07-2014, 08:52 PM   #9
MEC75
LQ Newbie
 
Registered: Jul 2008
Posts: 15

Original Poster
Rep: Reputation: 0
Hi gegechris99,

Yes, that's in the kernel.
 
Old 11-07-2014, 11:10 PM   #10
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,858

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
Quote:
Originally Posted by MEC75 View Post
Yes, with the generic 3.2.29 which comes with Slackware everything works fine.
I was also able to boot into 3.16 creating a minimal USB based root-file system based on the current system but with the 3.16 kernel and the initrd for 3.16 (but without unlocking luks in initrd since it's not used for /). Once booted to 3.16 from USB, I can use cryptsetup, vgscan --mknodes, vgchange -ay, then chroot to the original / on the LUKS/LVM and then using mkinitrd_command_generator.sh. The line returned is basically the same I used only includes some additional USB modules.
Yeah, the usb modules placed into the initrd are slightly different between 14.0 and 14.1. Like you, I don't think that's an important difference.

Quote:
So I'm a bit puzzled now. Seems the kernel itself has everything in there otherwise I couldn't open the LVM after the USB boot, but using the initrd alone for unlocking lvm doesn't work.

Here the output of the commands you asked for after the emergency prompt when try to boot 3.16.0 with initrd and / on luks/lvm:

vgchange: "No volume goups found"
vgscan: "No volume groups found"
udevadm: No output
/sbin/pvscan: doesn't exist
Sorry about that. I see that you figured out the workaround immediately.
Quote:
lvm pvscan: "No matching physical volumes found"


in comparison from a running system:
vgchange: "3 logical volume(s) in volume group "cryptvg" now active"
vgscan: "Found volume group "cryptvg" using metadata type lvm2"
udevadm: no output
pvscan:
PV /dev/mapper/lukssda4 VG cryptvg lvm2 [417.63 GiB / 0 free]
Total: 1 [417.63 GiB] / in use: 1 [417.63 GiB] / in no VG: 0 [0 ]
When you are at the emergency prompt, what does
Code:
dmsetup targets
print out? I'm looking at http://unix.stackexchange.com/questi...t-at-boot-time for hints.
 
Old 11-07-2014, 11:11 PM   #11
STDOUBT
Member
 
Registered: May 2010
Location: Stumptown
Distribution: Slackware64
Posts: 583

Rep: Reputation: 242Reputation: 242Reputation: 242
Quote:
Originally Posted by MEC75 View Post
Everything was on backup, partitions deleted and converted to LUKS/LVM, copied back from backup.
I guess I'm a bit lost.
MEC75, under which kernel were you able to return your backed up stuff to the newly created LUKS/LVM partition(s)? Wouldn't that mean it did work at one point?
Also, it seems to me, if vgscan is saying "No volume groups found", then I'd believe it.
Are you super-sure you didn't skip a step someplace? I have been using this method for a long time now, and every so often upon recreating it (for a new install for example) I goof up.
I'm really interested in playing with a new kernel just for "fun" and :cough:Libre:cough:, and I have never been able to get this right without the stock kernel.

Sorry if I just muddied the waters...

Last edited by STDOUBT; 11-07-2014 at 11:17 PM. Reason: brainfart
 
Old 11-08-2014, 01:51 PM   #12
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,858

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
How did you build your new kernel?

Did you use the Slackware kernel configuration as a base?
 
Old 11-08-2014, 03:17 PM   #13
mostlyharmless
Senior Member
 
Registered: Jan 2008
Distribution: Arch/Manjaro, might try Slackware again
Posts: 1,851
Blog Entries: 14

Rep: Reputation: 284Reputation: 284Reputation: 284
I can verify that kernel 3.16.2 runs LUKS and LVM in a very similiar setup, albeit I started with Slackware 14.1 not 14.0, although I did have 14.0 prior with the same setup as well. I followed the directions at http://alien.slackbook.org/dokuwiki/...kernelbuilding to copy the configuration and build the kernel. Here is my mkinitrd:
Code:
mkinitrd -c -k 3.16.2 -f ext4 -r /dev/cryptvg/root -m usb-storage:xhci-hcd:usbhid:hid_generic:mbcache:jbd2:ext4:ext2:vfat:pci-stub:hid:usbhid -C /dev/sda3:/dev/sdb1 -L -u -o /boot/initrd-3.16.2.gz -K UUID=1567-EC70:/keyfile
Though you probably don't need all that. I use a USB key to hold the keyfile, and there are two separate LUKS/LVM disks. Don't know if that helps much.
 
Old 11-09-2014, 09:09 PM   #14
MEC75
LQ Newbie
 
Registered: Jul 2008
Posts: 15

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Richard Cranium View Post
When you are at the emergency prompt, what does
Code:
dmsetup targets
print out? I'm looking at http://unix.stackexchange.com/questi...t-at-boot-time for hints.
When I do this it says:
Code:
mirror        v1.13.2
crypt         v1.13.0
striped       v1.5.1
linear        v1.2.1
error         v1.2.0

@STDOUBT: I'm sure I skipped no step to have a working LUKS/LVM working, because it works - only not with 3.16.
I had a long time ago a Slackware 14.0 installation with the default 3.2.29 kernel and switched to the most resent kernel at this time and later to 3.16.0. At this time it was just 2 partions, one for / and one for /home. All self compiled kernels have always been made via "make oldconfig" and then going through all items using "make menuconfig" and removing everything not needed for my system. Some days ago I decided to switch to only one LUKS partition (+a small boot) and using LVM inside for / and /home. Everything was backed up to USB, new installation started via original install DVD which uses 3.2.29 and where LUKS/LVM was working and setup, then after a minimal installation copied everything back from USB, chroot to /mnt, edit /etc/lilo.conf, created initrd for 3.2.29, install lilo to MBR, reboot. After that the system with 3.2.29 was working and booting. Then I did the same mkinitrd (see in previous comments) for 3.16.0, reconfigured lilo, run lilo, rebooted. But then after I can put in the password for LUKS, it says it can't mount /dev/mapper/cryptvg-root under /mnt, because no LVM volume is found - which doesn't mean it is not there, because with 3.2.29 the system boots. (and dm-crypt and LVM support is compiled into the kernel, not as module).


@mostlyharmless: Yes, since I don't need USB to boot the default install on the internal HD, I don't think it's needed. But just to try, I used your line and there is no change in what happens (except that more modules get loaded at startup time).
Do you know what's "mbcache" for?

The interesting thing is that if I boot this 3.16.0 kernel from an external device (/ not on LUKS/LVM, I made a USB disk bootable with the backup of / of the system to have the exact same installation except that the root-filesystem is on a physical partition) then I can later after login as root open the LUKS on the internal disk and then the LVM partitions. So something seems to be missing in the initrd or something compiled as module should be in the kernel (or vice versa?).

Last edited by MEC75; 11-09-2014 at 09:20 PM.
 
Old 11-10-2014, 02:46 PM   #15
MEC75
LQ Newbie
 
Registered: Jul 2008
Posts: 15

Original Poster
Rep: Reputation: 0
Thumbs up

Just to give you an update:

What I did before was using "gmake oldconfig" for 3.16.0 based on 3.2.29 and removing all not needed things from the kernel, keep only what's needed for my system. This was at a time when all / and /home was on physical partitions and all worked well. dm-crypt support and device-mapper were already compiled into the kernel. After switching to LUKS/LVM, the system stayed the same, only adding an initrd to 3.2.29 (which was still there from the original installation a long time ago and used as emergency system while testing new kernels) and to 3.16.0 - using the same command for both initrds.
Result: It was working instantly fro 3.2.29 but not for 3.16.0 and I tried to look through the different options using "gmake menuconfig" to get it to work - no success at all.

Since it has to work and it also works booting the same compiled kernel from USB and after login as root opening then the internal LUKS/LVM device, something was missing but I had no idea what.
Since I couldn't find it so far, I used another approach: Start from a clean 3.16.0 source tree, using gmake oldconfig based on 3.2.29 - and don't do anything else, only create a initrd after compiling and installing and reinstallation of lilo. That works!


So now, I will try to remove all modules not needed in 3.16.0 for my system and when I have a minimal configuration based on that, I can compare it with the previous one to see what was missing for having LVM working. (right now there is much too much in there and a diff of both configuration is not useful at all for that reason)

Last edited by MEC75; 11-10-2014 at 05:19 PM.
 
  


Reply

Tags
luks, lvm, problem



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to set up custom boot backgrounds from boot to login with LVM and LUKS? spudzy Linux - Software 1 10-09-2014 09:03 AM
[SOLVED] Initrd for kernel 3.8.11 and encrypted luks root partition in current Phorize Slackware 8 06-15-2013 09:04 AM
[SOLVED] Custom Kernel requirements for LVM+LUKS? TommyC7 Slackware 5 06-05-2012 12:42 PM
13.1 install LIBATA switch, LUKS, LVM, initrd, and lots of disks Z038 Slackware - Installation 1 07-05-2010 04:28 PM
slackware64 lvm/luks and mkinitrd for custom kernel chopp Slackware 19 08-25-2009 02:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 07:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration