3

I have a setup with a grub2 bootloader, and the rest of the system on an encrypted partition (LVM-on-LUKS). I have two OSes installed inside of the LUKS container, Kali Sana and Debian 8, as well as a shared swap partition.

This was setup by installing Kali with full disk encryption, and then making room for Debian. The grub install is from Kali.

I am fully aware that it is simply easier to have a second /boot partition for Debian. However, given the way this was setup, there is no room left for the Debian bootloader, and resizing everything to make room will be a pain.

So, here is what I need to do under grub:

  • Mount the encrypted partition (already managed to do this)
  • Start initramfs and the kernel for Debian (This is where there is trouble).

I have done some research on this, and I am attempting to do this by editing the /boot/grub/custom.cfg file. After each edit, I have run sudo grub-mkconfig and sudo update-grub. Then I have restarted to see if it will boot. While it can decrypt the LUKS container, it can't find initramfs or the kernel.

Here is my custom.cfg file. Note: I am fuzzy on what all of this does. It is most likely completely wrong.

menuentry "Debian 8 Jessie"{
  insmod luks
  insmod lvm
  cryptdevice=UUID=ffe7a64d-e552-4db9-b0f3-1e42be118059:cryptolvm
  set root=/dev/Outsider-vg/Outsider-debianroot
  linux /boot/vmlinuz-3.16.0-4-amd64 root=/dev/Outsider-vg/Outsider-debianroot
  initrd /boot/initrd.img-3.16.0-4-amd64
}

Note about the above: cryptdevice=UUID=ffe7a64d-e552-4db9-b0f3-1e42be118059:cryptolvm was originally set root=/dev/sda5. This version of the file fails to decrypt the container. Note that I already know how to get this to work, I was just messing with it to see if changing it would help.

I have been referencing this link for help editing this file.

Basically, I need to know the syntax to point grub at the correct initramfs and vmlinuz files, after the LUKS partition has been decrypted. They are under the logical volume Outsider--debianroot. My only real issue is that I don't know how to do this.

I apologize for being somewhat vague. Part of the problem is that I am not sure what I am looking for. If you do not have an answer, but can direct me to a comprehensive guide to editing custom.cfg, that would also be appreciated. Please let me know if you need more details.

EDIT: Upon further research, here is what I have found:

Basically, I need to give Grub the correct path to a root directory which is on an LVM. After doing some digging around on the file system, I have found two paths which could work: /dev/mapper/volumeGroup-volumeName and /dev/volumeGroup/volumeName. In the case of the above example, they are /dev/mapper/Outsider--vg-Outsider--debianroot and /dev/Outsider-vg/Outsider-debianroot.

I need to know which is the path to the correct root directory, allowing that distro to boot. Either one is right, both need to be used together, or there is a different path which I am missing which I need to use instead. Any ideas?

Furthermore, what is the difference between these two paths? What do they each point to? What is the difference between /dev/mapper/volumeGroup and just /dev/volumeGroup?

EDIT 2: I believe that /dev/volumeGroup/volumeName is the correct path, based off of the end syntax for this tutorial. I will experiment with this and report back.

Note: I will come and clean this up later, when I have solved it.

2
  • If you've solved the problem, add it as an Answer, not as an edit to the post, please.
    – Jeff Schaller
    Mar 26, 2017 at 19:04
  • This question is 4 years old, did you ever solve it?
    – Typewar
    Aug 15, 2021 at 5:34

2 Answers 2

0

You should have something like:

menuentry 'Debian' --class debian --class gnu-linux --class gnu --class os {
  load_video
  set gfxpayload=keep
  insmod gzio
  insmod ext2
  insmod fat
  echo  'Loading Linux ...'
  linux /boot/vmlinuz-3.16.0-4-amd64 cryptdevice=UUID=ffe7a64d-e552-4db9-b0f3-1e42be118059:cryptolvm root=/dev/Outsider-vg/Outsider-debianroot rw
  echo  'Loading initial ramdisk ...'
  initrd /boot/initrd.img-3.16.0-4-amd64
}

But note that insmod part_gpt should already be added in your grub.cfg. lvm and luks are not needed because it is the kernel that will handle it (you need proper kernel hooks), grub only load the linux image.

0

Before Linux had a device-mapper subsystem, back in 2.4.x and older kernel series, there was a Linux LVM version 1. The modern one is version 2.

The LVM v1 used exclusively /dev/vgName/lvName-style paths.

When the device-mapper subsystem and LVM v2 were introduced, the new-style LVM needed to be backwards compatible with the old version, so it maintains the old-style pathnames as symlinks to the real devices.

The current LVM v2 uses the device-mapper, so the "real" devices follow its rules: they will be /dev/dm-<number>. This is easy for low-level device-mapper userspace tools like dmsetup, but inconvenient for humans, so each subsystem (multipathing, software RAID, disk encryption, LVM v2, and others) will also maintain more human-friendly names as symbolic links pointing back to the relevant /dev/dm-* devices. These links will normally be located under /dev/mapper/, although there can be exceptions for backwards compatibility.

As a result, the current LVM device naming scheme uses /dev/mapper/vgName-lvName scheme as the "official" names, although they are usually implemented as symbolic links to /dev/dm-<number> devices. But since the legacy LVMv1-style naming scheme is simple and convenient, it's still maintained too. Since both the official and the legacy scheme are implemented identically as symlinks, there is really no practical difference between them.

The only exception might be within initramfs, where start-up scripts might be designed to handle only one particular form of LVM device names for simplicity. If so, your distribution's documentation should clearly mention it.

(There used to be kernel/udev versions that allowed multiple device nodes a particular major/minor device number combination, but that apparently turned out to be more trouble than it's worth, opening up race conditions and other possibilities for mischief. Modern systems normally create only one actual device node under /dev for each device; any aliases must be symbolic links.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .