diff options
author | Janne Heß <janne@hess.ooo> | 2022-01-21 16:35:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-21 16:35:10 +0100 |
commit | 45048dfd0a52888f5299dd542762e675c8e424de (patch) | |
tree | 04c6c32b76b8da750ab516ecd7194a117b711438 /nixos/modules | |
parent | 85459d00024e67e76c02dee392064e4da2bc3631 (diff) | |
parent | f363642de7b2cd217728e71a493ea2569c0b7096 (diff) |
Merge pull request #153095 from Madouura/dev/bcachefs-init
nixos/stage-1: colon-separated multi-device support
Diffstat (limited to 'nixos/modules')
-rw-r--r-- | nixos/modules/system/boot/stage-1-init.sh | 39 |
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 98409ed6ae525..f86d4641228c3 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. |