3 type getarg
>/dev
/null
2>&1 || .
/lib
/dracut-lib.sh
5 PATH
=/usr
/sbin
:/usr
/bin
:/sbin
:/bin
16 # root is in the form root=nbd:srv:port[:fstype[:rootflags[:nbdopts]]]
21 # If it's not nbd we don't continue
22 [ "${nroot%%:*}" = "nbd" ] ||
return
25 nbdserver
=${nroot%%:*}; nroot
=${nroot#*:}
26 nbdport
=${nroot%%:*}; nroot
=${nroot#*:}
27 nbdfstype
=${nroot%%:*}; nroot
=${nroot#*:}
31 # If nbdport not an integer, then assume name based import
32 if [ ! -z $
(echo "$nbdport" |
sed 's/[0-9]//g') ]; then
36 if [ "$nbdopts" = "$nbdflags" ]; then
39 if [ "$nbdflags" = "$nbdfstype" ]; then
42 if [ "$nbdfstype" = "$nbdport" ]; then
45 if [ -z "$nbdfstype" ]; then
49 # look through the NBD options and pull out the ones that need to
50 # go before the host etc. Append a ',' so we know we terminate the loop
52 while [ -n "$nbdopts" ]; do
58 if [ -z "${f%bs=*}" -o -z "${f%timeout=*}" ]; then
65 # look through the flags and see if any are overridden by the command line
67 while [ -n "$nbdflags" ]; do
69 nbdflags
=${nbdflags#*,}
73 if [ "$f" = "ro" -o "$f" = "rw" ]; then
77 fsopts
=${fsopts:+$fsopts,}$f
82 fsopts
=${fsopts:+$fsopts,}${nbdrw}
84 # XXX better way to wait for the device to be made?
86 while [ ! -b /dev
/nbd0
]; do
87 [ $i -ge 20 ] && exit 1
88 if [ $UDEVVERSION -ge 143 ]; then
89 udevadm settle
--exit-if-exists=/dev
/nbd0
96 # If we didn't get a root= on the command line, then we need to
97 # add the udev rules for mounting the nbd0 device
98 if [ "$root" = "block:/dev/root" -o "$root" = "dhcp" ]; then
99 printf 'KERNEL=="nbd0", ENV{DEVTYPE}!="partition", ENV{ID_FS_TYPE}=="?*", SYMLINK+="root"\n' >> /etc
/udev
/rules.d
/99-nbd-root.rules
100 udevadm control
--reload
101 type write_fs_tab
>/dev
/null
2>&1 || .
/lib
/fs-lib.sh
102 write_fs_tab
/dev
/root
"$nbdfstype" "$fsopts"
103 wait_for_dev
-n /dev
/root
105 if [ -z "$DRACUT_SYSTEMD" ]; then
106 printf '/bin/mount %s\n' \
108 > $hookdir/mount
/01-$$
-nbd.sh
112 if strstr
"$(nbd-client --help 2>&1)" "systemd-mark"; then
113 preopts
="--systemd-mark $preopts"
116 nbd-client
$preopts "$nbdserver" $nbdport /dev
/nbd0
$opts ||
exit 1
118 # NBD doesn't emit uevents when it gets connected, so kick it
119 echo change
> /sys
/block
/nbd
0/uevent