iscsi, nbd: call write_fs_tab() and write /etc/fstab
authorHarald Hoyer <harald@redhat.com>
Wed, 6 Mar 2013 16:04:57 +0000 (17:04 +0100)
committerHarald Hoyer <harald@redhat.com>
Wed, 6 Mar 2013 16:29:12 +0000 (17:29 +0100)
modules.d/95iscsi/iscsiroot.sh
modules.d/95iscsi/parse-iscsiroot.sh
modules.d/95nbd/nbdroot.sh

index 20738cf..463fa45 100755 (executable)
@@ -10,6 +10,7 @@
 
 type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
 type parse_iscsi_root >/dev/null 2>&1 || . /lib/net-lib.sh
+type write_fs_tab >/dev/null 2>&1 || . /lib/fs-lib.sh
 
 PATH=/usr/sbin:/usr/bin:/sbin:/bin
 
@@ -43,6 +44,8 @@ if getargbool 0 rd.iscsi.firmware -d -y iscsi_firmware ; then
         # if root is not specified try to mount the whole iSCSI LUN
         printf 'ENV{DEVTYPE}!="partition", SYMLINK=="disk/by-path/*-iscsi-*-*", SYMLINK+="root"\n' >> /etc/udev/rules.d/99-iscsi-root.rules
         udevadm control --reload
+        write_fs_tab /dev/root
+        wait_for_dev /dev/root
     fi
 
     for p in $(getargs rd.iscsi.param -d iscsi_param); do
@@ -136,6 +139,8 @@ handle_netroot()
         # if root is not specified try to mount the whole iSCSI LUN
         printf 'SYMLINK=="disk/by-path/*-iscsi-*-%s", SYMLINK+="root"\n' $iscsi_lun >> /etc/udev/rules.d/99-iscsi-root.rules
         udevadm control --reload
+        write_fs_tab /dev/root
+        wait_for_dev /dev/root
 
         # install mount script
         echo "iscsi_lun=$iscsi_lun . /bin/mount-lun.sh " > $hookdir/mount/01-$$-iscsi.sh
index cc59f5a..eccde3c 100755 (executable)
@@ -24,6 +24,8 @@
 
 [ -n "$iscsiroot" ] && [ -n "$iscsi_firmware" ] && die "Mixing iscsiroot and iscsi_firmware is dangerous"
 
+type write_fs_tab >/dev/null 2>&1 || . /lib/fs-lib.sh
+
 # Root takes precedence over netroot
 if [ "${root%%:*}" = "iscsi" ] ; then
     if [ -n "$netroot" ] ; then
@@ -33,6 +35,8 @@ if [ "${root%%:*}" = "iscsi" ] ; then
     # if root is not specified try to mount the whole iSCSI LUN
     printf 'ENV{DEVTYPE}!="partition", SYMLINK=="disk/by-path/*-iscsi-*-*", SYMLINK+="root"\n' >> /etc/udev/rules.d/99-iscsi-root.rules
     root=/dev/root
+
+    write_fs_tab /dev/root
 fi
 
 # If it's not empty or iscsi we don't continue
index b176a16..4aebef0 100755 (executable)
@@ -101,11 +101,14 @@ nbd-client $preopts "$nbdserver" $nbdport /dev/nbd0 $opts || exit 1
 # add the udev rules for mounting the nbd0 device
 root=$(getarg root=)
 if [ -z "$root" ] || strstr "$root" "nbd:" || strstr "$root" "dhcp"; then
-    echo '[ -e /dev/root ] || { info=$(udevadm info --query=env --name=/dev/nbd0); [ -z "${info%%*ID_FS_TYPE*}" ] && { ln -s /dev/nbd0 /dev/root 2>/dev/null; :; };} && rm $job;' \
+    echo '[ -e /dev/root ] || { info=$(udevadm info --query=env --name=/dev/nbd0); [ -z "${info%%*ID_FS_TYPE*}" ] && { ln -s /dev/nbd0 /dev/root 2>/dev/null; type systemctl >/dev/null 2>&1 && systemctl --no-block start sysroot.mount;:; };} && rm $job;' \
         > $hookdir/initqueue/settled/nbd.sh
 
-    printf '/bin/mount -t %s -o %s %s %s\n' \
-        "$nbdfstype" "$fsopts" /dev/nbd0 "$NEWROOT" \
+    type write_fs_tab >/dev/null 2>&1 || . /lib/fs-lib.sh
+    write_fs_tab /dev/nbd0 "$nbdfstype" "$fsopts"
+
+    printf '/bin/mount %s\n' \
+        "$NEWROOT" \
         > $hookdir/mount/01-$$-nbd.sh
 fi