# Unable to mount LVM on LUKS volume

## algae enthusiast

Hi, I'm new to this and I'm trying to set up encryption on the partition of my ssd I'm installing on.  I eventually decided to encrypt the partition with a detached LUKS header on a usb drive, then add an LVM layer on top of that for additional flexibility.  This seemed to be going okay and I was at the point of figuring out how to set up an initramfs when I ran out of time to work on it a few weeks ago.

Now that I'm looking at it again I can't mount the root filesystem for some reason even though as far as I can remember I'm doing things the same way as when it was working.  I boot from the live install thing, open the luks volume with "cryptsetup open --header [path to header] /dev/sda3 crypt" then try to mount with "mount /dev/vg/root /mnt/gentoo" and get this:

NTFS signature is missing.

Failed to mount '/dev/mapper/vg-root': Invalid argument

The device '/dev/mapper/vg-root' doesn't seem to have a valid NTFS.

Maybe the wrong device is used? Or the whole disk instead of a partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?

The volume isn't even formatted with NTFS, it's ext4, so I'm really confused.  Does anyone know what I'm doing wrong or what could have changed in the last few weeks to mess things up?

----------

## russK

algae enthusiast,

Just a few suggestions ...

I assume the cryptsetup open worked?

I've only ever used "cryptsetup luksOpen", not "cryptsetup open" as in your post.

After the open, regarding LVM, does the output of commands, pvs, vgs, and lvs look correct?

Then in your mount command, did you try with the '-t ext4' option?

HTH

----------

## algae enthusiast

Thank you for the suggestions.  The cryptsetup open seems to be working, it doesn't say that it failed or anything.

I tried it with "cryptsetup luksOpen" this time and got the same results.

I'm not 100% sure what the output of those commands should look like but I've copied it here:

```

# pvs

WARNING: Failed to connect to lvmetad. Falling back to device scanning.

/dev/sdc: open failed: no medium found

PV                      VG      Fmt     Attr    PSize   PFree

/dev/mapper/crypt       vg      lvm2    a--     <74.49g    0

# vgs

vgs

WARNING: Failed to connect to lvmetad. Falling back to device scanning.

/dev/sdc: open failed: no medium found

VG      #PV     #LV     #SN     Attr    VSize   VFree

vg      1       2       0       wz--n-  <74.49g    0

# lvs

WARNING: Failed to connect to lvmetad. Falling back to device scanning.

/dev/sdc: open failed: No medium found

LV      VG      Attr            LSize   Pool    Origin  Data%   Meta%   Move    Log     Cpy%Sync        Convert

root    vg      -wi-a-----      <66.49g

swap    vg      -wi-a-----      8.00g

```

The volumes at least are listed which seems to suggest that the encrypted volume opened properly?

Not sure where the "/dev/sdc: open failed" thing is coming from but since I'm not trying to do anything with sdc I wouldn't think it would be an issue.

With "-t ext4" I get:

```
mount: /mnt/gentoo: wrong fs type, bad option, bad superblock on /dev/mapper/vg-root, missing codepage or helper program, or other error.
```

Doesn't exactly narrow it down much

[Moderator edit: added [code] tags to preserve output layout. -Hu]

----------

## Hu

LVM tools probe all plausible devices.  You have a device node sdc that it tries to check, then it fails.  This is harmless, aside from the confusing error message.  sdc probably represents an optical drive with no CD mounted, or possibly a USB reader with no USB storage in it.

What is the output of file -s /dev/mapper/vg-* ; ls -l /dev/mapper/ ?

----------

## algae enthusiast

Okay that makes sense, I thought it might be something like that.

Here's the output

```
# file -s /dev/mapper/vg-*; ls -l /dev/mapper/

/dev/mapper/vg-root: symbolic link to ../dm-2

/dev/mapper/vg-swap: symbolic link to ../dm-1

total 0

crw------- 1 root root 10, 236 Oct 13 01:06 control

lrwxrwxrwx 1 root root       7 Oct 13 01:08 crypt -> ../dm-0

lrwxrwxrwx 1 root root       7 Oct 13 01:09 vg-root -> ../dm-2

lrwxrwxrwx 1 root root       7 Oct 13 01:08 vg-swap -> ../dm-1
```

----------

## Hu

Strange.  I expected those to be device nodes, not symlinks to them.  Use file -s -L /dev/mapper/vg-* ; ls -lL /dev/mapper/ instead, so that the symlinks are dereferenced.

----------

## russK

Note, mine looks very similar with the links to paths like ../dm-n.  And then when I use the file commands Hu suggests, it is able to deduce the filesystem types in most cases.

algae enthusiast,

It will be interesting to see if 'file -s -L /dev/mapper/vg-*' is able to tell if there is an ext4 filesystem.  But I'm afraid it won't because if it could, the mount command should have worked.  This makes me wonder if something happened before the initial mount at /mnt/gentoo before extracting the stage3 and chroot.

By the way, pvs, vgs, and lvs are LVM tools to display the status of your volumes.  During your install, you probably used pvcreate, vgcreate, and lvcreate.  The pvs, vgs, and lvs command outputs look right for the setup you described.

Cheers

----------

## algae enthusiast

Yeah for root it just says "data"

```
# file -s -L /dev/mapper/vg-*; ls -lL /dev/mapper/

/dev/mapper/vg-root: data

/dev/mapper/vg-swap: Linux/i386 swap file (new style), version 1 (4K pages), size 2097151 pages, no label, UUID=2c994452-7257-43cf-9490-6ac8216d9ca7

total 0

crw------- 1 root root  10, 236 Oct 13 20:34 control

brw-rw---- 1 root disk 252,   0 Oct 13 20:38 crypt

brw-rw---- 1 root disk 252,   2 Oct 13 20:40 vg-root

brw-rw---- 1 root disk 252,   1 Oct 13 20:38 vg-swap
```

If something happened before the initial mount, is there any reason I wouldn't have had this problem until now?  I'm not 100% sure since it was a while ago but I thought I remembered rebooting and mounting everything multiple times while setting other things up without any issues.

Maybe I should just delete the volume group and start over?  I have a tar backup of most of the root filesystem with config files and some additional stuff I installed so I wouldn't lose that much progress, but I would feel better if I at least knew what went wrong so I could avoid the same thing happening again.

One thing I thought of:  since this is on my laptop where I'm currently dual booting with Mac OS, is it possible something running while that was booted could have modified the other side of the drive in a way that messed up the ext4 metadata or whatever?  I obviously know basically nothing about how LVM works or anything so idk what specifically that would have to involve.

----------

## Hu

Since LUKS still mounts, the LVM volume group is detected, and the swap device inside LVM is found, almost everything seems to be in order.  The most likely explanations all involve user error, such as making the filesystem on the wrong device, or writing garbage data over the filesystem header later.  Unfortunately, without any logs, it will be hard to discover much more.  If you're curious, you could try dumping the first few kilobytes of vg-root and looking for traces of an ext filesystem.

Since LUKS is involved, I think it pretty unlikely that Mac OS can be blamed here.  If it had made a bad write to the disk, the damage should be far worse than you seem to have encountered.  Most likely, either the LUKS volume would fail to open or, if it did open, the contents would be severely corrupted.  Neither of those has happened.

----------

## algae enthusiast

Yeah I guess that makes sense.  How would I go about looking for traces of the filesystem?  Are there any resources you'd recommend with information about how to do that?

Anyway thank you both for the help

----------

