Lernstick / root-vanished

Apache License 2.0
0 stars 0 forks source link

Investigate using dm-multipath to gracefully handle root file system removals #7

Open stapelberg opened 8 years ago

stapelberg commented 8 years ago

This is the config file I’ve used:

$ cat /etc/multipath.conf
blacklist_exceptions {
    devnode "/dev/*"
}
defaults {
    no_path_retry queue
}

Then use multipathd add path sdc to make a USB drive available. Mount the corresponding device from /dev/mapper/, unplug the drive, run an ls command or similar, replug, see how it gracefully recovers.

This could be integrated into the initramfs transparently.

cc @gaudenz

stapelberg commented 6 years ago

Some more details from today’s foray:

Installing the multipath-tools-boot is sufficient on a vanilla Debian stretch VM: the package installs an initramfs hook which sets up a multipath mapping for the root file system.


After ticking the “hot pluggable” checkbox in the virtualbox storage configuration, you can use the following two commands to detach/attach the root hard disk:

vboxmanage storageattach "deb" --storagectl "SATA" --port 0 --device 0 --medium none
vboxmanage storageattach "deb" --storagectl "SATA" --port 0 --device 0 --type hdd --medium "/home/michael/VirtualBox VMs/deb/deb.vdi"

Now, the initramfs integration for Lernstick is tricky because of the live-boot package: in a vanilla installation, specifying break=pre-multipath results in 2 breaks during boot (one before storage drivers are loaded, one after), but live-boot hijacks the initramfs, resulting in the second multipath script not being run at all, and hence no mapping for the root file system.

So, at the very least, some integration work with live-boot is necessary.


Further, when booting from a USB device, multipath-tools/libmultipath/discovery.c needs to be patched: one needs to return 0 from the if (value && !strcmp(value, "usb")) branch. Afterwards, /etc/multipath.conf needs to be modified like so:

blacklist_exceptions {
    devnode "/dev/*"
    property "(ID_BUS)"
}
defaults {
    no_path_retry queue
}

cc @darkskiez @ronnystandtke @THS-on

darkskiez commented 6 years ago

I patched the live boot scripts to try this out livebootmp.patch.txt

set live-mp=1 in the boot params to activate it

Some problems: no_path_retry is not working as expected, filesystem is frequently erroring and going readonly somewhat defeating the purpose

It's also very greedy and enumerates additional usb sticks as multipath devices and then the user cant use them.

THS-on commented 3 years ago

Today I've looked again if this might be possible and found out a few things. First multipath now allows usb devices if allow_usb_devices yes is set and second for no_path_retry queue to work in the initramfs multipath must be called with -q because otherwise no_path_retry will be unset if multipathd is not running.