summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMadoura <madouura@gmail.com>2022-01-09 18:06:03 -0600
committergithub-actions[bot] <github-actions[bot]@users.noreply.github.com>2022-01-21 15:40:06 +0000
commit20b008c3aad9ed4aaa52c837b87f32a923ef9de4 (patch)
treea1e905ef8d1055d9664137dcc7e63533d507ae6a
parentMerge pull request #155469 from jyooru/backport/brave (diff)
downloadnixpkgs-origin/backport-153095-to-release-21.11.tar.gz
nixos/stage-1: colon-separated multi-device supportorigin/backport-153095-to-release-21.11
(cherry picked from commit f363642de7b2cd217728e71a493ea2569c0b7096)
-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 3dfcc010b64e..eabdbe3bcbb1 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.