How to mount Device Mapper volume at boot or shortly after?

I have a slow LVM Integrity RAID volume that I want to apply Writecache to (Data drive for VM and NAS storage).

With current LVM rules I can do this a couple of ways:

#1 - Manually edit DM table metadata config to add writecaching to the integrity RAID

- this is a little messy but allows mount at boot like any other LVM volume and bypasses the rules manually

- https://github.com/lvmteam/lvm2/issues/92#issuecomment-1281315510

​

#2 - Use dmsetup to add the writecache volume onto the existing Integrity RAID volume (command below)

- this is what LVM would normally do for me but its rules tell it not to (devs say it just needs more testing)

- I believe this requires initram config to mount at boot but this is new to me

​

Either approach gets me the performance figures that I want.

What would I need to do to get method #2 to mount automatically at boot?

​

Here are the commands I'm using below to create the writecache config and mount it manually:

# Create a writecache device mapper virtual node called 10TB_hybridmirror with a 4K blocksize:

dmsetup create 10TB_hybridmirror --table "0 19376463872 writecache s /dev/writecache_vg/10TB_mirror_lv /dev/writecache_vg/100GB_writecachemirror_lv 4096 0"

​

Definitions:

  • Volume Group: writecache_vg
  • Slow Integrity RAID 7K HDD Volume: 10TB_mirror_lv
  • Fast Integrity RAID NVMe Cache Volume: 100GB_writecachemirror_lv
  • Resulting Device Mapper Node: 10TB_hybridmirror

​

Current Environment is Alma Linux 9. Alma, Rocky and Oracle Linux are the distros I have been testing on.

​

Thanks for your help!

​

[Visuals below of planned architecture]

​

​

Option #1

Option #2

Posted Nov 23, 2022, 2:52 AM UTC · edited

109
vredesbyrd66•

try getting the uuid. Look up some fstab examples and add an entry for your volume uuid and the mount point. i dont see why this wouldn't work

1
Forward_HumorOP•

I've been having trouble locating a UUID for this node. It's strange.

If I run dmsetup info --columns I can see a UUID for every other LVM LV but not for this manually created Device Mapper node.

Maybe more is required than just creating the node with dmsetup before it gets a UUID?

Learning lots of new things right now and likely I've missed something simple...

1
vredesbyrd66•

try using this command: blkid

u can also use lvdisplay to see ur uuid

you should see partuuid of each device if you are having trouble locating uuid u can skip it for now and try to do it that way later, using uuid is the best practice for many reasons however you can still use the device name ( its usually discouraged to use the device mapping name since it might change after a reboot) just find another fstab example and try that

1
Forward_HumorOP•

I think there is still more missing here as the device mapper node does not exist after reboot and the dmsetup command has to be run again to create it. Any thoughts on that piece?

1
vredesbyrd66•

not really but i did edit my comment above try getting the uuid using those 2 commands.im not sure as i create my logical volumes using different method

1
Forward_HumorOP•

After creation of the writecache device mapper node, I have also tried importing this into a new Stratis Pool, in hopes it would make this persistent. However it still does not survive a reboot. It looks like I need something else to get the underlying device mapper node to persistently mount at boot before creating the Stratis Pool. On a side note Stratis performance and functionality is pretty awesome.

[Stratis config for reference]

# Create the Stratis pool

stratis pool create pool1 /dev/mapper/10TB_hybridmirror

# Create the Stratis file system

stratis filesystem create pool1 fs1

# Mount the file system

mkdir /mnt/fs1

mount /dev/stratis/pool1/fs1 /mnt/fs1

# Get the block UUID for persistent mounting via fstab below

blkid -p /dev/stratis/pool1/fs1

# Write the file system mount via UUID into fstab

# (with stratisd service dependency mount option)

echo "UUID=f9cafbb7-6188-4ac5-8b94-82124101bb56 /mnt/fs1 xfs x-systemd.requires=stratisd.service 0 0" >> /etc/fstab

1
Forward_HumorOP•

Once I get the details ironed out and some solid testing I will make a new post with the full config for others who want to test. So far this combo creates a super high performance setup on a really reasonable budget. (I just need to learn how to make it re-mount on reboots LOL)

1