From 3929c490ecb35d285fd324c632b3dc83d1d1c10c Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Tue, 28 Mar 2017 10:10:54 -0400 Subject: Wait for nbd-client before using /dev/nbd0 For explanation, see: https://lists.freedesktop.org/archives/systemd-devel/2014-March/018053.html But for the proper solution, see: https://lists.freedesktop.org/archives/systemd-devel/2014-March/018054.html Another option would just be to use a partitioned nbd device. The nbd device _partitions_ do not have this issue at all. --- src/initrd/grok-block | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/initrd') diff --git a/src/initrd/grok-block b/src/initrd/grok-block index d3fe7a2..3ad0432 100755 --- a/src/initrd/grok-block +++ b/src/initrd/grok-block @@ -123,6 +123,14 @@ parent_device() printf '%s' "$d" } +wait_for_files_() +{ + local f + for f in "$@"; do + while ! [ -e "$f" ]; do sleep 0.1; done + done +} + grok_block() { local mountpoint="/mnt/${DEVNAME##*/}" @@ -140,7 +148,12 @@ grok_block() case "$DEVNAME" in # Avoid mouting this multiple times in case this script gets called multiple times, # because while it's mounted, the dmsetup stuff will fail with device busy. - /dev/nbd0) [ -e /bootwait/samizdat-nbd-dev ] && return ;; + /dev/nbd0) + if [ -e /bootwait/samizdat-nbd-dev ] + then return + else wait_for_files_ /sys/block/nbd0/pid + fi + ;; esac case "$ID_PART_ENTRY_NAME" in samizdat-grub-incomplete|samizdat-plaintext-incomplete|samizdat-luks-encrypted-incomplete) return ;; -- cgit v1.2.3