Create block device link to target /dev/mapper

0

Setting up a Full Disk Encryption on Ubuntu derived distro's is easy, because Ubuntu's installer simply provides access to all available partitions on all available disks from within the partitining part of the installer, this includes averything from /dev/mapper. The pre/post - setup parts can be done via a terminal.

This is sadly not the case for the majority of distro installers. Some, like Fedora, tries to provide automated features within the installer, sadly it does not work properly. Others are much more limited by not including anything from /dev/mappper and some not even allowing more than one disk to be used.

I tried installing Solus Linux to day, which turned out to be yet another distro with a limited partition setup. It only allows one disk to be used when selecting mount points manually and these partitions does not include /dev/mapper devices which in turn means no encrypted or LVM volumes.

So if I choose to use "/dev/sda", I can only use "/dev/sdaX" block files for mount point selection. If one of these is an DMC/LVM, the LV's is not included.

If I where to create a small additional partition on "sda" like "/dev/sdaY", is there a way to link that block device file to another device file in /dev/mapper? For example

/dev/sdaY -> /dev/mapper/lv-system

Kind of like "mount --bind" for folders. Or some other way to trick these limited installers into using a different device file?

Daniel B

Posted 2018-03-09T21:49:58.277

Reputation: 103

Answers

1

Two approaches. First, you can try just ln -s /dev/mapper/lv-system /dev/sdaY. This may or may not fool the installer. If it doesn't, try the second one:

You can create another device node that points to the same mapped device. To do this, first do ls -l /dev/mapper/lv-system. You'll see that it's itself a symlink to /dev/dm-0 (but possibly a number other than 0). Now, do ls -l /dev/dm-0 (replacing the 0 with your number), and you'll get output like this:

brw-rw---- 1 root disk 253, 0 Mar 4 18:12 /dev/dm-0

The important parts of that are the b at the beginning and the 253, 0 in the middle. Run mknod /dev/sdaY b 253 0 (filling in what you got), and you'll have created a device node that points to the same mapped device as /dev/mapper/lv-system. This still doesn't perfectly replicate a hard drive, so there's a chance it will fail as well.

Joseph Sible-Reinstate Monica

Posted 2018-03-09T21:49:58.277

Reputation: 1 420

Yes this does not work. The installer is properly reading the partitioning table, which is why I wanted to link an existing device file (dummy partition) to another. That way it would be registered in the table and yet be redirected to another device. – Daniel B – 2018-03-10T07:41:09.137

What if you rm the existing device file, then follow these steps to make the new file have the same name? – Joseph Sible-Reinstate Monica – 2018-03-10T14:32:08.123

Well it half worked. I could use the partition now in the installer, but it crashed for some reason during format. Properly because of mismatch in the information since some information is taken from the file system of the device, while other information is taken from /sys/block. F.eks the size said 10G (Original partition) while remaining space said 260G (Linked partition). But it seams to be the right path, so this has given me something to play around with. – Daniel B – 2018-03-10T20:26:18.097