Merge pull request #153095 from Madouura/dev/bcachefs-init

nixos/stage-1: colon-separated multi-device support
This commit is contained in:
Janne Heß 2022-01-21 16:35:10 +01:00 committed by GitHub
commit 45048dfd0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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/udev/hwdb.bin # to shut up udev
touch /etc/initrd-release touch /etc/initrd-release
# Function for waiting a device to appear. # Function for waiting for device(s) to appear.
waitDevice() { waitDevice() {
local device="$1" 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 # USB storage devices tend to appear with some delay. It would be
# great if we had a way to synchronously wait for them, but # great if we had a way to synchronously wait for them, but
# alas... So just wait for a few seconds for the device to # alas... So just wait for a few seconds for the device to
# appear. # appear.
if test ! -e $device; then for dev in $device; do
echo -n "waiting for device $device to appear..." if test ! -e $dev; then
try=20 echo -n "waiting for device $dev to appear..."
while [ $try -gt 0 ]; do try=20
sleep 1 while [ $try -gt 0 ]; do
# also re-try lvm activation now that new block devices might have appeared sleep 1
lvm vgchange -ay # also re-try lvm activation now that new block devices might have appeared
# and tell udev to create nodes for the new LVs lvm vgchange -ay
udevadm trigger --action=add # and tell udev to create nodes for the new LVs
if test -e $device; then break; fi udevadm trigger --action=add
echo -n "." if test -e $dev; then break; fi
try=$((try - 1)) echo -n "."
done try=$((try - 1))
echo done
[ $try -ne 0 ] echo
fi [ $try -ne 0 ]
fi
done
} }
# Mount special file systems. # Mount special file systems.