btrfs-progs: add "btrfs device scan" before overlay/extroot
authorMarius Dinu <m95d+git@psihoexpert.ro>
Sun, 17 Apr 2022 10:23:51 +0000 (13:23 +0300)
committerRosen Penev <rosenp@gmail.com>
Thu, 14 Nov 2024 18:32:35 +0000 (10:32 -0800)
If users choose to build OpenWrt with btrfs included
and want to use a btrfs RAID for overlay/extroot,
then devices need to be scanned *before* mounting overlay/extroot.
If not, btrfs won't find all RAID drives and fail to mount.

This commit:
- creates a duplicate (symlink) of the btrfs scan script so that it runs
  both before and after overlay/extroot mount,
- changes the scan command to not depend on blkid (-d),
- outputs the scan results to kernel log to show what's being detected,
  as the system logger is not yet running.

Signed-off-by: Marius Dinu <m95d+git@psihoexpert.ro>
utils/btrfs-progs/Makefile
utils/btrfs-progs/files/btrfs-scan.init

index ac9d064d8d2db533421fb94d6412bd0be286e4b5..5619e12bbe9feb56ff74f4bfe9a1cbe1658661bc 100644 (file)
@@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=btrfs-progs
 PKG_VERSION:=6.11
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=$(PKG_NAME)-v$(PKG_VERSION).tar.xz
 PKG_SOURCE_URL:=@KERNEL/linux/kernel/people/kdave/btrfs-progs
@@ -67,6 +67,7 @@ CONFIGURE_ARGS += \
        --disable-documentation \
        --disable-libudev \
        --disable-python
+
 ifneq ($(CONFIG_BTRFS_PROGS_ZSTD),y)
 CONFIGURE_ARGS += --disable-zstd
 endif
@@ -90,7 +91,8 @@ define Package/btrfs-progs/install
        $(foreach prog,$(boxprogs),$(LN) btrfs $(1)/usr/bin/$(prog);)
        $(foreach prog,$(progs),$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(prog) $(1)/usr/bin/;)
        $(INSTALL_DIR) $(1)/lib/preinit
-       $(INSTALL_BIN) ./files/btrfs-scan.init $(1)/lib/preinit/85_btrfs_scan
+       $(INSTALL_BIN) ./files/btrfs-scan.init $(1)/lib/preinit/85_btrfs_scan_post
+       $(LN) ./85_btrfs_scan_post $(1)/lib/preinit/78_btrfs_scan_pre
 endef
 
 $(eval $(call BuildPackage,btrfs-progs))
index 6b9ab62df9c05addc0d8aad08886ac30fbc2e7ce..e5ec1705be2e6dc3940006158218ff4f79fc0c44 100644 (file)
@@ -2,7 +2,7 @@
 
 preinit_btrfs_scan() {
        if grep -q btrfs /proc/filesystems; then
-                btrfs device scan
+               btrfs device scan -d > /dev/kmsg
        fi
 }