# Root/Swap over LVM2 over LUKS

## thienvu

I've partitioned my system hard disk like this:

```
/dev/sda1: /boot

/dev/sda2: LUKS partition

```

The /boot partition is unencrypted. I then:

```
cryptsetup --key-size 256 luksFormat /dev/sda2

cryptsetup luksOpen /dev/sda2 luks

pvcreate /dev/mapper/luks

vgcreate system /dev/mapper/luks

vgscan

vgchange -a y system

lvcreate -L 4G -n swap system    # /dev/mapper/system-swap

lvcreate -L 100G -n root system  # /dev/mapper/system-root

```

I then installed my system according to the Gentoo handbook.

On my kernel command line, I have dolvm and crypt_root=/dev/sda2 real_root=/dev/mapper/system-root.

What looks like happens on the initrd created by genkernel is that LVM runs before the cryptsetup which is backwards from what I need. I need to luksOpen the encrypted volume and then vgscan and vgchange can run to correctly mount the filesystems.

Any ideas on how to make this work? It seems like I just need to tweak the initrd to re-order the initialization events, but there's little documentation on how to do that.

----------

## truc

you should make your own initramfs, it's really easy now that the gentoo wiki has some valuable information on this.  :Smile: 

----------

## hpeters

 *thienvu wrote:*   

> I've partitioned my system hard disk like this:
> 
> ```
> /dev/sda1: /boot
> 
> ...

 

What options did you use with genkernel when you created the initrd ?

I'm using genkernel version 3.4.10.904 to create the "initrd" with the following options and it works fine.

genkernel --disklabel --luks --lvm --no-ramdisk-modules ramdisk

The only other thing I have done is modify the /etc/init.d dmcrypt and lvm scripts to start dmcrypt before lvm. But that should have no effect on what the initrd is doing.

Harley

----------

## oRDeX

Strange....what are the parameters that you pass to the kernel at the boot?

----------

