GNU bug report logs -
#41143
[PATCH 1/2] Add 'lvm-device-mapping'
Previous Next
Reported by: tsmish <tsymsh <at> gmail.com>
Date: Sat, 9 May 2020 01:13:01 UTC
Severity: normal
Tags: patch
Done: Ludovic Courtès <ludo <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Hi,
In LVM one volume group usually haves more than one logical volume, so
target need to be a list. Just setting target to list in config doesn't
work because that field is actually used for checking when (and whether
at all) the device needs to be mounted. Because we still need to support
using a string as target, we need to handle two situations: target is a
string and target is list of strings. Patch converts plain string target
to single element list and proceeds with assuming a list. grep by
mapped-device-target revealed two uses in gnu/system.scm and one in
gnu/services/base.scm. First two checked if any filesystems used a
device, so I replaced plain string comparison with comparison with every
element of list and returning true if any of them matched. Last one used
target for building service name for shepherd, so I replaced plain
target with concatenation of every target that mapped device has.
Moving on to second patch. Basically to mount LVM you need to activate
volume group(s) with command "vgchange -ay". It worked fine with
non-root mounts, but when it got moved in initrd it crashed. Quick look
around found that while /dev/dm-X devices were being created,
/dev/mapper/ nodes were not. Looking at man pages (and internet) "vgscan
--mknodes" looked like what I wanted (there is also dmsetup mknodes, but
basically first just calls it). After adding it, boot with root on LVM
started working, so I left it. Also I check that targets actually exist,
so you get crash in a bit more appropriate place. This check should
probably be moved to somewhere else, but I haven't found better solution.
Looking at
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/logical_volume_manager_administration/udev_device_manager
10-dm.rules looks like what creates /dev/mapper nodes in normal systems,
so probably more proper solution will be to add udevd to initrd, but I
don't know how to run daemons in initrd properly. dracut also creates
file /etc/lvm/lvm.conf, which doesn't seem to be very important, but I
probably should look closer to it. Also both dracut and LVM add
"--ignorelockingfailure" flag to vgchange, which I forgot and will
change in future patches.
There seems to be close to no resources about mounting LVM in initrd, so
I'm adding code from other initrd generators:
Dracut:
https://github.com/dracutdevs/dracut/blob/master/modules.d/90lvm/lvm_scan.sh
LVM:
https://github.com/lvmteam/lvm2/blob/master/scripts/lvm2create_initrd/lvm2create_initrd
This bug report was last modified 4 years and 176 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.