# LUKS + LVM2 - /usr not mounting

## Wizumwalt

I'm doing an LVM2 + LUKS install and when I boot my system. Here is the error I'm seeing when I boot. Note that the root fs does mount.

```

>> Scanning for and activating Volume Groups

6 logical volume(s) in volume group "vg1" now active

Enter passphrase for /dev/vg1/root:

>> LUKS device /dev/vg1/root opened

>> Determining root device ...

>> Mounting /dev/mapper/root as root ...

>> Using mount -t ext4 -o ro

>> Mounting /dev/mapper/crypt-usr as /usr: mount -t ext4 -o noatime,ro /dev/mapper/crypt-usr /newroot/usr

mount: mounting /dev/mapper/crypt-user on /newroot/usr failed: No such file or directory

!! Unable to mount /dev/mapper/crypt-usr for /usr

>> Booting (initramfs)

INIT: version 2.88 booting

```

And here is the contents of /dev/vg1 ...

```

dev

  `- vg1 

      |- home -> /dev/mapper/vg1-home

      |- opt -> /dev/mapper/vg1-opt

      |- root -> /dev/mapper/vg1-root

      |- tmp -> /dev/mapper/vg1-tmp

      |- usr -> /dev/mapper/vg1-usr

      `- var -> /dev/mapper/vg1-var

```

... and in /dev/mapper ...

```

dev

  `- mapper 

      |- root

      |- vg1-home

      |- vg1-opt

      |- vg1-root

      |- vg1-tmp

      |- vg1-usr

      `- vg1-var

```

So I compare the above with the contents of the same directories after booting with a livecd (after mounting and chroot'ing over) ...

```

dev

  `- mapper 

      |- crypt-home -> ../dm-7

      |- crypt-opt -> ../dm-10

      |- crypt-root -> ../dm-6

      |- crypt-tmp -> ../dm-11

      |- crypt-usr -> ../dm-8

      |- crypt-var -> ../dm-9

      |- vg1-home -> ../dm-1

      |- vg1-opt -> ../dm-4

      |- vg1-root -> ../dm-0

      |- vg1-tmp -> ../dm-5

      |- vg1-usr -> ../dm-2

      `- vg1-var -> ../dm-3

```

dir listing of /dev/vg1 also in livecd:

```

dev

  `- mapper 

      |- vg1-home -> ../dm-1

      |- vg1-opt -> ../dm-4

      |- vg1-root -> ../dm-0

      |- vg1-tmp -> ../dm-5

      |- vg1-usr -> ../dm-2

      `- vg1-var -> ../dm-3

```

It would seem I'm missing the symbolic links in the /dev/mapper directory. And I'm wondering how those links ( --> ../dm-N) get created. 

I do have the folling device files in /dev.

```

dev

  |- dm0

  |- dm1

  |- dm2

  |- dm3

  |- dm4

  |- dm5

  |- dm6

  |- ...

```

Here's /etc/fstab

```

/dev/sda1              /boot    ext2    noauto,noatime 1 2

/dev/sda2              none     swap    sw             0 0

/dev/mapper/crypt-root /        ext2    noauto,noatime 1 2

/dev/mapper/crypt-home /home    ext4    noatime       0 0

/dev/mapper/crypt-usr  /usr     ext4    noatime       0 1

/dev/mapper/crypt-var  /var     ext4    noatime       0 1

/dev/mapper/crypt-opt  /opt     ext4    noatime       0 1

/dev/mapper/crypt-tmp  /tmp     ext4    noatime       0 1

```

And /etc/conf.d/dmcrypt

```

swap=swap

source='/dev/sda2'

target=crypt-home

source='/dev/mapper/crypt-home'

target=crypt-usr

source='/dev/mapper/crypt-usr'

target=crypt-var

source='/dev/mapper/crypt-var'

target=crypt-opt

source='/dev/mapper/crypt-opt'

target=crypt-tmp

source='/dev/mapper/crypt-tmp'

```

Also, I'm using genkernels initramfs (3.8.13).

Any ideas much appreciated.

----------

## grey_dot

I've had a similiar problem, although my system mounts /usr after exiting initrd. If your system doesnt run systemd, which requires /usr premounted, you could remove usrmount from initrd and mount it with fstab. Also try adding lvm to boot runlevel, since udev sometimes doesnt create symlinks for lvm nodes.

p.s. why did you create a separate luks container for each lvm volume? It's usually done the other way around - a single luks container with lvm inside. Just interested.

----------

## LoTeK

Might be of little help, but why do you use genkernel?

I have a similar set up with a very simple initramfs and no problems:

```
#!/bin/busybox sh

rescue_shell () {

   echo "something went wrong... dropping you in a shell.."

   busybox --install -s

   exec /bin/sh

}

mount -t proc none /proc

mount -t sysfs none /sys

mount -t devtmpfs none /dev

# quiet kernel

echo 0 > /proc/sys/kernel/printk

# enter password

/sbin/cryptsetup -T 3 luksOpen /dev/sda1 cypher

# enable kernel messages

echo 1 > /proc/sys/kernel/printk

# activate lvm

/sbin/lvm.static vgscan --mknodes

/sbin/lvm.static vgchange -a y

mount -o ro /dev/mapper/vg-root /mnt/root || rescue_shell

# clean up

umount /proc

umount /sys

umount /dev

exec switch_root /mnt/root /sbin/init

```

----------

## Wizumwalt

 *grey_dot wrote:*   

> I've had a similiar problem, although my system mounts /usr after exiting initrd. If your system doesnt run systemd, which requires /usr premounted, you could remove usrmount from initrd and mount it with fstab. Also try adding lvm to boot runlevel, since udev sometimes doesnt create symlinks for lvm nodes.
> 
> p.s. why did you create a separate luks container for each lvm volume? It's usually done the other way around - a single luks container with lvm inside. Just interested.

 

I'm not running systemd.I do have /usr in fstab, though its obviously not working. And I do have LVM in the boot runlevel.

About the container, not sure. Mainly because I was following some tutorials and didn't quite understand it for myself. I'll look at it.

----------

## Wizumwalt

 *LoTeK wrote:*   

> Might be of little help, but why do you use genkernel?
> 
> 

 

I use genkernel just to have an initramfs built for me. Guess I'll try rolling my own and use something similar to yours.

----------

## Wizumwalt

Still can't see what I'm doing wrong. What I did was create a small partition for boot, a separate partition for swap and another for the physical LVM. Then I encrypted the volumes. Then I opened the containers and formatted with a filesystem.

# fdisk -l /dev/sda

```

/dev/sda1   *   2048   133119   65536      83   Linux

/dev/sda2     133120   2181119   1024000      82   Linux swap / Solaris

/dev/sda3    2181120 156301487   77060184   8e   Linux LVM

```

# vgscan

```

VG   #PV   #LV   #SN   Attr   VSize   VFree

vg1   1   6   0   wz--n--   73.49g   1.49g

```

# lvscan

```

ACTIVE      '/dev/vg1/root' [10.00 GiB] inherit

ACTIVE      '/dev/vg1/home' [20.00 GiB] inherit

ACTIVE      '/dev/vg1/usr'  [20.00 GiB] inherit

ACTIVE      '/dev/vg1/var'  [10.00 GiB] inherit

ACTIVE      '/dev/vg1/opt'  [10.00 GiB] inherit

ACTIVE      '/dev/vg1/tmp'  [2.00 GiB] inherit

```

And after mounting all this form a livecd and chroot'ing over, I ran genkernel to get an initramfs (vers 3.8.13-gentoo). I've compiled manually as well and used only the initramfs from genkernel as well. Either way, I hear this initramfs should work fine for this.

/boot/grub/grub.conf 

```

title Gentoo Linux 3.8.13

root (hd0,0)

kernel /boot/kernel-genkernel-x86_64-3.8.13-gentoo root=/dev/ram0 crypt_root=/dev/vg1/root rootfstype=ext4 init=/linux dolvm

initrd /boot/initramfs-genkernel-x86_64-3.8.13-gentoo

```

But I think I still have something wrong with either my fstab or dmcrypt.

/etc/fstab

```

/dev/sda1      /boot    ext2    noauto,noatime 1 2

/dev/sda2      none     swap    sw             0 0

/dev/vg1/root   /        ext2    noauto,noatime 1 2

/dev/vg1/home   /home    ext4    noatime       0 0

/dev/vg1/usr   /usr     ext4    noatime       0 1

/dev/vg1/var   /var     ext4    noatime       0 1

/dev/vg1/opt   /opt     ext4    noatime       0 1

/dev/vg1/tmp   /tmp     ext4    noatime       0 1 

```

/etc/conf.d/dmcrypt

```

swap=swap

source='/dev/sda2'

target=home

source='/dev/mapper/vg1-home'

target=usr

source='/dev/mapper/vg1-usr'

target=var

source='/dev/mapper/vg1-var'

target=opt

source='/dev/mapper/vg1-opt'

target=tmp

source='/dev/mapper/vg1-tmp'

```

And here is the boot error I keep getting.

```

>> Scanning for and activating Volume Groups

6 logical volume(s) in volume group "vg1" now active

Enter passphrase for /dev/vg1/root:

>> LUKS device /dev/vg1/root opened

>> Determining root device ...

>> Mounting /dev/mapper/root as root ...

>> Using mount -t ext4 -o ro

>> Mounting /dev/mapper/crypt-usr as /usr: mount -t ext4 -o noatime,ro /dev/mapper/crypt-usr /newroot/usr

mount: mounting /dev/mapper/crypt-user on /newroot/usr failed: No such file or directory

!! Unable to mount /dev/mapper/crypt-usr for /usr

>> Booting (initramfs)

INIT: version 2.88 booting 

```

----------

## piewie

you could try to use the UUID to prevent / exclude a /dev/mapper/vg1-usr or /dev/vg1/usr lvm naming problem

/etc/fstab:

UUID=xxxxxxxx-0000-aaa-yyyy-1111111111 /usr       ext4           noatime,user_xattr,rw   0 1

----------

## Wizumwalt

Let me ask this. Should the initramfs generated by genkernel, is it setup to handle volume groups and whatnot the way I have configured? It certainly doesn't seem to mount my /usr, but should it?

----------

## piewie

Normally 

```
genkernel --lvm --oldconfig --luks --menuconfig all
```

 should do the job. But from what I have read around here, is that it is probably not that trivial with a separated /usr. Perhaps some additional binaries are necessary for initramfs.

 *Quote:*   

> >> Mounting /dev/mapper/crypt-usr as /usr: mount -t ext4 -o noatime,ro /dev/mapper/crypt-usr /newroot/usr
> 
> mount: mounting /dev/mapper/crypt-user on /newroot/usr failed: No such file or directory
> 
> !! Unable to mount /dev/mapper/crypt-usr for /usr 

  looks not consistent to me, because of crypt-usr and crypt-user.

----------

