summary refs log tree commit diff
path: root/nixos/modules/system/boot/stage-1-init.sh
diff options
context:
space:
mode:
authorMadoura <madouura@gmail.com>2022-01-09 18:06:03 -0600
committerMadoura <madouura@gmail.com>2022-01-09 18:06:03 -0600
commitf363642de7b2cd217728e71a493ea2569c0b7096 (patch)
tree151f3d0277a613890423b7cbd8b23adaca7ed9aa /nixos/modules/system/boot/stage-1-init.sh
parentdf2c21de512180f349fde25d938185cfbd02b2e6 (diff)
downloadnixpkgs-f363642de7b2cd217728e71a493ea2569c0b7096.tar
nixpkgs-f363642de7b2cd217728e71a493ea2569c0b7096.tar.gz
nixpkgs-f363642de7b2cd217728e71a493ea2569c0b7096.tar.bz2
nixpkgs-f363642de7b2cd217728e71a493ea2569c0b7096.tar.lz
nixpkgs-f363642de7b2cd217728e71a493ea2569c0b7096.tar.xz
nixpkgs-f363642de7b2cd217728e71a493ea2569c0b7096.tar.zst
nixpkgs-f363642de7b2cd217728e71a493ea2569c0b7096.zip
nixos/stage-1: colon-separated multi-device support
Diffstat (limited to 'nixos/modules/system/boot/stage-1-init.sh')
-rw-r--r--nixos/modules/system/boot/stage-1-init.sh39
1 files changed, 22 insertions, 17 deletions
diff --git a/nixos/modules/system/boot/stage-1-init.sh b/nixos/modules/system/boot/stage-1-init.sh
index 98409ed6ae5..f86d4641228 100644
--- a/nixos/modules/system/boot/stage-1-init.sh
+++ b/nixos/modules/system/boot/stage-1-init.sh
@@ -81,30 +81,35 @@ ln -s /proc/mounts /etc/mtab # to shut up mke2fs
 touch /etc/udev/hwdb.bin # to shut up udev
 touch /etc/initrd-release
 
-# Function for waiting a device to appear.
+# Function for waiting for device(s) to appear.
 waitDevice() {
     local device="$1"
+    # Split device string using ':' as a delimiter as bcachefs
+    # uses this for multi-device filesystems, i.e. /dev/sda1:/dev/sda2:/dev/sda3
+    local IFS=':'
 
     # USB storage devices tend to appear with some delay.  It would be
     # great if we had a way to synchronously wait for them, but
     # alas...  So just wait for a few seconds for the device to
     # appear.
-    if test ! -e $device; then
-        echo -n "waiting for device $device to appear..."
-        try=20
-        while [ $try -gt 0 ]; do
-            sleep 1
-            # also re-try lvm activation now that new block devices might have appeared
-            lvm vgchange -ay
-            # and tell udev to create nodes for the new LVs
-            udevadm trigger --action=add
-            if test -e $device; then break; fi
-            echo -n "."
-            try=$((try - 1))
-        done
-        echo
-        [ $try -ne 0 ]
-    fi
+    for dev in $device; do
+        if test ! -e $dev; then
+            echo -n "waiting for device $dev to appear..."
+            try=20
+            while [ $try -gt 0 ]; do
+                sleep 1
+                # also re-try lvm activation now that new block devices might have appeared
+                lvm vgchange -ay
+                # and tell udev to create nodes for the new LVs
+                udevadm trigger --action=add
+                if test -e $dev; then break; fi
+                echo -n "."
+                try=$((try - 1))
+            done
+            echo
+            [ $try -ne 0 ]
+        fi
+    done
 }
 
 # Mount special file systems.