diff --git a/dracut-modules/90void-usb/squashfs-img.sh b/dracut-modules/90void-usb/squashfs-img.sh index 5a9e1d5..b1c1a4a 100644 --- a/dracut-modules/90void-usb/squashfs-img.sh +++ b/dracut-modules/90void-usb/squashfs-img.sh @@ -17,7 +17,40 @@ case "$CONTAINER" in emergency_shell esac -mount -t f2fs -o nodev,nosuid "$CONTAINER" /sysroot/container +# try to wait for $CONTAINER to be available +function mount_container { + mount -t f2fs -o nodev,nosuid "$CONTAINER" /sysroot/container; +} + +if [ -b "$CONTAINER" ]; then + mount_container +else + sleep 1 + if [ -b "$CONTAINER" ]; then + mount_container + else + sleep 1 + if [ -b "$CONTAINER" ]; then + mount_container + else + sleep 3 + if [ -b "$CONTAINER" ]; then + mount_container + else + sleep 5 + if [ -b "$CONTAINER" ]; then + mount_container + else + sleep 10 + if [ -b "$CONTAINER" ]; then + mount_container + fi + # assume that the drive won't show up after more than 20s + fi + fi + fi + fi +fi if [ -f /sysroot/container/squashfs.img ]; then losetup -r -f /sysroot/container/squashfs.img