diff options
author | Andrew Cady <d@jerkface.net> | 2017-03-28 10:10:54 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2017-03-28 10:10:54 -0400 |
commit | 3929c490ecb35d285fd324c632b3dc83d1d1c10c (patch) | |
tree | 3620f5947c95d672f019e95d5724adf7c1f67cde | |
parent | 42f0b3ff9b9e71da74ddca1b41f3f04787d571c4 (diff) |
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.
-rwxr-xr-x | src/initrd/grok-block | 15 |
1 files changed, 14 insertions, 1 deletions
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() | |||
123 | printf '%s' "$d" | 123 | printf '%s' "$d" |
124 | } | 124 | } |
125 | 125 | ||
126 | wait_for_files_() | ||
127 | { | ||
128 | local f | ||
129 | for f in "$@"; do | ||
130 | while ! [ -e "$f" ]; do sleep 0.1; done | ||
131 | done | ||
132 | } | ||
133 | |||
126 | grok_block() | 134 | grok_block() |
127 | { | 135 | { |
128 | local mountpoint="/mnt/${DEVNAME##*/}" | 136 | local mountpoint="/mnt/${DEVNAME##*/}" |
@@ -140,7 +148,12 @@ grok_block() | |||
140 | case "$DEVNAME" in | 148 | case "$DEVNAME" in |
141 | # Avoid mouting this multiple times in case this script gets called multiple times, | 149 | # Avoid mouting this multiple times in case this script gets called multiple times, |
142 | # because while it's mounted, the dmsetup stuff will fail with device busy. | 150 | # because while it's mounted, the dmsetup stuff will fail with device busy. |
143 | /dev/nbd0) [ -e /bootwait/samizdat-nbd-dev ] && return ;; | 151 | /dev/nbd0) |
152 | if [ -e /bootwait/samizdat-nbd-dev ] | ||
153 | then return | ||
154 | else wait_for_files_ /sys/block/nbd0/pid | ||
155 | fi | ||
156 | ;; | ||
144 | esac | 157 | esac |
145 | case "$ID_PART_ENTRY_NAME" in | 158 | case "$ID_PART_ENTRY_NAME" in |
146 | samizdat-grub-incomplete|samizdat-plaintext-incomplete|samizdat-luks-encrypted-incomplete) return ;; | 159 | samizdat-grub-incomplete|samizdat-plaintext-incomplete|samizdat-luks-encrypted-incomplete) return ;; |