4 # root=iscsi:[<servername>]:[<protocol>]:[<port>]:[<LUN>]:<targetname>
5 # [root=*] netroot=iscsi:[<servername>]:[<protocol>]:[<port>]:[<LUN>]:<targetname>
8 # [net]root=[iscsi] iscsiroot=[<servername>]:[<protocol>]:[<port>]:[<LUN>]:<targetname>
9 # [net]root=[iscsi] iscsi_firmware
11 # root= takes precedence over netroot= if root=iscsi[...]
14 # This script is sourced, so root should be set. But let's be paranoid
15 [ -z "$root" ] && root
=$
(getarg root
=)
16 if [ -z "$netroot" ]; then
17 for nroot
in $
(getargs netroot
=); do
18 [ "${nroot%%:*}" = "iscsi" ] && break
20 if [ "${nroot%%:*}" = "iscsi" ]; then
23 for nroot
in $
(getargs netroot
=); do
24 [ "${nroot%%:*}" = "dhcp" ] && break
29 [ -z "$iscsiroot" ] && iscsiroot
=$
(getarg iscsiroot
=)
30 [ -z "$iscsi_firmware" ] && getargbool
0 rd.iscsi.firmware
-y iscsi_firmware
&& iscsi_firmware
="1"
32 [ -n "$iscsiroot" ] && [ -n "$iscsi_firmware" ] && die
"Mixing iscsiroot and iscsi_firmware is dangerous"
34 type write_fs_tab
>/dev
/null
2>&1 || .
/lib
/fs-lib.sh
36 # Root takes precedence over netroot
37 if [ "${root%%:*}" = "iscsi" ] ; then
38 if [ -n "$netroot" ] ; then
39 echo "Warning: root takes precedence over netroot. Ignoring netroot"
42 # if root is not specified try to mount the whole iSCSI LUN
43 printf 'ENV{DEVTYPE}!="partition", SYMLINK=="disk/by-path/*-iscsi-*-*", SYMLINK+="root"\n' >> /etc
/udev
/rules.d
/99-iscsi-root.rules
44 [ -n "$DRACUT_SYSTEMD" ] && systemctl is-active systemd-udevd
&& udevadm control
--reload-rules
47 write_fs_tab
/dev
/root
50 # If it's not empty or iscsi we don't continue
51 for nroot
in $
(getargs netroot
); do
52 [ "${nroot%%:*}" = "iscsi" ] ||
continue
57 # Root takes precedence over netroot
58 if [ "${root}" = "/dev/root" ] && getarg
"netroot=dhcp" ; then
59 # if root is not specified try to mount the whole iSCSI LUN
60 printf 'ENV{DEVTYPE}!="partition", SYMLINK=="disk/by-path/*-iscsi-*-*", SYMLINK+="root"\n' >> /etc
/udev
/rules.d
/99-iscsi-root.rules
61 [ -n "$DRACUT_SYSTEMD" ] && systemctl is-active systemd-udevd
&& udevadm control
--reload-rules
64 if [ -n "$iscsiroot" ] ; then
65 [ -z "$netroot" ] && netroot
=$root
68 echo "Warning: Argument iscsiroot is deprecated and might be removed in a future"
69 echo "release. See 'man dracut.kernel' for more information."
71 # Accept iscsiroot argument?
72 [ -z "$netroot" ] ||
[ "$netroot" = "iscsi" ] || \
73 die
"Argument iscsiroot only accepted for empty root= or [net]root=iscsi"
75 # Override root with iscsiroot content?
76 [ -z "$netroot" ] ||
[ "$netroot" = "iscsi" ] && netroot
=iscsi
:$iscsiroot
79 # iscsi_firmware does not need argument checking
80 if [ -n "$iscsi_firmware" ]; then
81 if [ "$root" != "dhcp" ] && [ "$netroot" != "dhcp" ]; then
82 [ -z "$netroot" ] && netroot
=iscsi
:
84 modprobe
-b -q iscsi_boot_sysfs
2>/dev
/null
85 modprobe
-b -q iscsi_ibft
86 # if no ip= is given, but firmware
87 echo "[ -f '/tmp/iscsistarted-firmware' ]" > $hookdir/initqueue
/finished
/iscsi_started.sh
88 initqueue
--unique --online /sbin
/iscsiroot online
"iscsi:" "$NEWROOT"
89 initqueue
--unique --onetime --timeout /sbin
/iscsiroot timeout
"iscsi:" "$NEWROOT"
90 initqueue
--unique --onetime --settled /sbin
/iscsiroot online
"iscsi:" "'$NEWROOT'"
93 # ISCSI actually supported?
94 if ! [ -e /sys
/module
/iscsi_tcp
]; then
95 modprobe
-b -q iscsi_tcp || die
"iscsiroot requested but kernel/initrd does not support iscsi"
98 modprobe
--all -b -q qla4xxx cxgb3i cxgb4i bnx2i be2iscsi
100 if [ -n "$netroot" ] && [ "$root" != "/dev/root" ] && [ "$root" != "dhcp" ]; then
101 if ! getargbool
1 rd.neednet
>/dev
/null ||
! getarg
"ip="; then
102 initqueue
--unique --onetime --settled /sbin
/iscsiroot dummy
"'$netroot'" "'$NEWROOT'"
106 if arg
=$
(getarg rd.iscsi.initiator
-d iscsi_initiator
=) && [ -n "$arg" ] && ! [ -f /run
/initiatorname.iscsi
] ; then
108 echo "InitiatorName=$iscsi_initiator" > /run
/initiatorname.iscsi
109 ln -fs /run
/initiatorname.iscsi
/dev
/.initiatorname.iscsi
110 if ! [ -e /etc
/iscsi
/initiatorname.iscsi
]; then
112 ln -fs /run
/initiatorname.iscsi
/etc
/iscsi
/initiatorname.iscsi
113 if [ -n "$DRACUT_SYSTEMD" ]; then
114 systemctl try-restart iscsid
115 # FIXME: iscsid is not yet ready, when the service is :-/
121 # If not given on the cmdline and initiator-name available via iBFT
122 if [ -z $iscsi_initiator ] && [ -f /sys
/firmware
/ibft
/initiator
/initiator-name
] && ! [ -f /tmp
/iscsi_set_initiator
]; then
123 iscsi_initiator
=$
(while read line ||
[ -n "$line" ]; do echo $line;done < /sys
/firmware
/ibft
/initiator
/initiator-name
)
124 if [ -n "$iscsi_initiator" ]; then
125 echo "InitiatorName=$iscsi_initiator" > /run
/initiatorname.iscsi
126 rm -f /etc
/iscsi
/initiatorname.iscsi
128 ln -fs /run
/initiatorname.iscsi
/etc
/iscsi
/initiatorname.iscsi
129 > /tmp
/iscsi_set_initiator
130 if [ -n "$DRACUT_SYSTEMD" ]; then
131 systemctl try-restart iscsid
132 # FIXME: iscsid is not yet ready, when the service is :-/
138 if [ -z "$netroot" ] ||
! [ "${netroot%%:*}" = "iscsi" ]; then
142 initqueue
--unique --onetime --timeout /sbin
/iscsiroot timeout
"$netroot" "$NEWROOT"
144 for nroot
in $
(getargs netroot
); do
145 [ "${nroot%%:*}" = "iscsi" ] ||
continue
146 type parse_iscsi_root
>/dev
/null
2>&1 || .
/lib
/net-lib.sh
147 parse_iscsi_root
"$nroot" ||
return 1
148 netroot_enc
=$
(str_replace
"$nroot" '/' '\2f')
149 echo "[ -f '/tmp/iscsistarted-$netroot_enc' ]" > $hookdir/initqueue
/finished
/iscsi_started.sh
155 # Shut up init error check
156 [ -z "$root" ] && root
="iscsi"