#772752 btrfs-tools: [Wishlist item] Replace "btrfs device scan" in initramfs with a udev rule and "udevadm trigger -s block" #772752
- Package:
- btrfs-tools
- Source:
- btrfs-progs
- Submitter:
- Goffredo Baroncelli
- Date:
- 2014-12-11 22:24:14 UTC
- Severity:
- wishlist
btrfs-tools has a script for initramfs which load the btrfs module and does a "btrfs device scan". I suggest to replace the "btrfs device scan" with a udev rule (the one provided by the package udev, see Bug#772744) which uses the udev builtin method. Because the module may be inserted after that some devices appeared, after the module insert,we have to be do a "udevadm trigger -s block" to redoing a device rescan for btrfs. The goal of this change is to armonize how the btrfs device scan is done in intramfs to after the initramfs Below two patch to highlight this change. BR G.Baroncelli --- /usr/share/initramfs-tools/scripts/local-premount/btrfs 2014-11-22 15:01:04.000000000 +0100 +++ usr/share/initramfs-tools/scripts/local-premount/btrfs 2014-12-10 20:31:31.289746904 +0100 @@ -19,5 +19,5 @@ if [ -x /sbin/btrfs ] then modprobe btrfs - /sbin/btrfs device scan 2> /dev/null + udevadm trigger -s block fi--- /usr/share/initramfs-tools/hooks/btrfs 2014-11-22 15:01:04.000000000 +0100 +++ usr/share/initramfs-tools/hooks/btrfs 2014-12-10 20:34:07.181751787 +0100 @@ -26,4 +26,13 @@ then copy_exec /sbin/fsck.btrfs /sbin fi + + mkdir -p $DESTDIR/lib/udev/rules.d/ + for rules in 64-btrfs.rules; do + if [ -e /etc/udev/rules.d/$rules ]; then + cp -p /etc/udev/rules.d/$rules $DESTDIR/lib/udev/rules.d/ + elif [ -e /lib/udev/rules.d/$rules ]; then + cp -p /lib/udev/rules.d/$rules $DESTDIR/lib/udev/rules.d/ + fi + done fi
I disagree, udev in initramfs is optional and the premount script is there precisely because at the moment udev based discovery is not sufficient. Also it's not btrfs package/hook responsibility to call udevadm trigger. On a running system this is only done after all local filesystems have been mounted. I have a separate bug report requesting to add an extra systemd unit to call device scan before local filesystems have been mounted. Also 64-btrfs.rules should not be installed by btrfs package, if udev package ships it. Looking at the systemd source package, the 64-btrfs.rules udev rule does something different to the btrfs-tools: btrfs device scan calls BTRFS_IOC_SCAN_DEV whilst systemd's rule calls BTRFS_IOC_DEVICES_READY. I'm not too sure, but if ramdisk is not using systemd and not using udev it really needs device scan. Do you have a bug report against current integration? If not, I will close this bug report as won't fix. Regards, Dimitri.
If udev is optional in initramfs, my request has to be rejected. discovery is not sufficient ? Or are you referring about the fact that udev is not mandatory in initramfs. [...] BR G.Baroncelli
udev in initramfs is optional, moreover initramfs is optional on debian and plenty of people run things without it. mosty yes, refereing to the fact that udev is not mandatory in the Debian's initramfs. There is also ongoing bug stating that udev based discovery is not sufficient in the initramfsless system, i have not investigated it completely.
I read something about that. The report stated that btrfs didn't honor the device=/dev/<disk> mount options; In this case would be impossible to mount a multi-device filesystem. But I didn't understand the reason.... Goffredo