Incorrect multipath device names in /etc/fstab
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
partman-target (Ubuntu) |
Incomplete
|
Undecided
|
Unassigned |
Bug Description
Problem:
-------
The multipath installation inserts incorrect device names on /etc/fstab.
The multipath partitions have different device names during the installation
and on the installed system (specifically, the disk-partition separator).
During installation: /dev/mapper/
On installed system: /dev/mapper/
Impact:
------
The multipath partitions in /etc/fstab are not mountable/usable -- any partition
that is not specified by UUID (at least swap).
The system only boots because the root partition is specified by UUID, thus
not using the entry in /etc/fstab.
The swap partition is not made effective as swap.
This is the /etc/fstab from installation:
~ # grep mapper /target/etc/fstab
/dev/mapper/
/dev/mapper/
And this is the environment in the installed system.
$ grep mapper /etc/fstab
/dev/mapper/
/dev/mapper/
$ ls -1 /dev/mapper
control
mpath0
mpath0-part1
mpath0-part2
mpath0-part3
$ mount | grep ' / '
/dev/mapper/
$ grep root=UUID /proc/cmdline
BOOT_IMAGE=
$ cat /proc/swaps
Filename Type Size Used Priority
$
Cause:
-----
The multipath block devices are created/named by different programs on
installation and installed system, and each one uses a different disk-partition separator.
During installation: libparted (via parted-server)
On installed system: kpartx (via udev rules)
On libparted, The 'p' separator is hard-coded in these functions:
[libparted/
_dm_add_
if (asprintf (&vol_name, "%sp%d", dev_name, part->num) == -1)
_device_
snprintf (result, result_len, "%sp%d", devpath, num);
On kpartx udev rules, the '-part' separator is used:
[/lib/udev/
ENV{DM_
RUN+=
Solution proposal:
-----------------
Ideally, one side or another should be 'fixed' (either libparted or kpartx rules).
I wrote this contained work-around (patch attached) to a partman's finish.d/ trigger,
standing between each side, as I'm not sure of the fallout of either change.
It intercepts and changes the multipath device names inserted in /etc/fstab.
It patches '/lib/partman/
has a 'case' including '/dev/mapper', so it seemed an appropriate place.
The change is /in/ the addfstab() function, because the specified device must
actually exist until it's called, as 'mapdevfs $dev' is an argument.
With it applied, this is the new /etc/fstab during installation:
~ # grep mapper /target/etc/fstab
/dev/mapper/
/dev/mapper/
And on the installed system, the swap is available/
$ grep mapper /etc/fstab
/dev/mapper/
/dev/mapper/
$ mount | grep ' / '
/dev/mapper/
$ cat /proc/swaps
Filename Type Size Used Priority
/dev/mapper/
Steps to reproduce:
------------------
You can use qemu/kvm if you don't have multipath hardware handy, just specify
2 drives with the same serial number. This is an example for ppc64el, easily
changeable for amd64 (change qemu-system & -M)
$ qemu-img create -f qcow2 vivid-multipath
$ qemu-system-ppc64 -M pseries \
-enable-kvm \
-nographic -nodefaults \
-monitor stdio -serial pty \
-m 2G \
-net nic -net user \
-drive file=vivid-
-drive file=vivid-
-kernel netboot/vmlinux \
-initrd netboot/initrd.gz \
-append 'disk-detect/
Note: to boot the installed system, remove the -kernel/
if the system takes long to boot in the initrd, use the 'debug' option
in the kernel command line (current work-around for another problem).
Adding an observation..
It's sligthly confusing to try to think of how/where fixing this generally..
Many pieces in the installer query libparted (parted-server) for a list of partitions (open_dialog PARTITIONS),
and libparted always return 'p' as disk-partition separator.
So, it won't work to just adjust the kpartx commands in /lib/partman/ commit. d/31partition_ multipath
to remove the block devices with 'p' separator and add them with '-part', e.g.,:
# update partition mappings
- kpartx -d -p -part $(cat device)
+ kpartx -d -p p $(cat device)
kpartx -a -p -part $(cat device)
because the filesystem formatting will fail immediately later, as they query parted for the block device names.
In the other hand, there are many places in /lib/partman/ lib/base. sh that assume that '-part' is the separator, formatted, which is a bug caused by the different separators).
so just leaving the 'p' from libparted actually hits other failures (for example, disks/partitions that are part of a multipath device are visible for being partitioned/