3 # We don't have any prerequisites
10 for x
in $
(cat /proc
/cmdline
); do
16 nbdroot
="${x#nbdroot=}"
24 # if nbd root is not requested exit early and silently
25 if [ -z "$nbdroot" ] && [ -z "$nbddev" ]
32 log_begin_msg
"Setting up nbd-client"
38 # Support setting stuff using DHCP by overloading 'option root-path'
46 nbdbasedev
="${nbddev#/dev/}"
50 nbdsrv
="${nbdroot%%,*}"
51 nbdpath
="${nbdroot%,*}"
52 nbdpath
="${nbdpath##*,}"
53 # root= parameter overrides three-option nbdroot= parameter
54 if [ -z "$nbdrootdev" ]
56 nbdbasedev
="${nbdroot##*,}"
57 nbdrootdev
=/dev
/$nbdbasedev
61 nbdsrv
="${nbdroot%,*}"
62 nbdport
="${nbdroot#*,}"
66 # Note: this is specifically written to be compatible with NFS
70 nbdpath
=${nbdroot#\[$nbdsrv\]}
77 nbdportpath
=${nbdroot#\[$nbdsrv\]}
78 nbdportpath
=${nbdportpath#:}
79 nbdport
=${nbdportpath%%/*}
80 nbdpath
=${nbdportpath#$nbdport/}
84 # Note: this is specifically written to be compatible with NFS
86 nbdsrv
=${nbdroot%%[:/]*}
87 nbdpath
=${nbdroot#$nbdsrv}
92 nbdsrv
=${nbdroot%%[:/]*}
93 nbdportpath
=${nbdroot#$nbdsrv}
94 nbdportpath
=${nbdportpath#:}
95 nbdport
=${nbdportpath%%/*}
96 nbdpath
=${nbdportpath#$nbdport/}
100 nbdrootdev
=${nbdrootdev%p*}
101 nbdbasedev
=${nbdbasedev%p*}
102 # If host is omitted, use ROOTSERVER from DHCP.
109 if [ -z "$nbdsrv" ] ||
[ -z "$nbdrootdev" ] ||
[ -z "$nbdpath" ]
111 log_failure_msg
"Insufficient information to set up nbd, quitting (nbdroot=$nbdroot, host=$nbdsrv, name=$nbdpath, port=$nbdport, nbd-device=$nbdrootdev)"
115 # Support defining an alternate launch script with env variable NBDCLIENT.
116 NBDCLIENT
=${NBDCLIENT:-/sbin/nbd-client}
117 $NBDCLIENT $nbdsrv -N $nbdpath $nbdport $nbdrootdev -swap -persist -systemd-mark
119 # This should be removed once the cfq scheduler no longer deadlocks nbd
121 if grep -q '\[cfq\]' /sys
/block
/$nbdbasedev/queue
/scheduler
123 echo deadline
> /sys
/block
/$nbdbasedev/queue
/scheduler