Remount every UFS partition rw just to be sure
[snf-image] / snf-image-helper / tasks / 30MountImage.in
index b0c41ab..508194b 100644 (file)
@@ -45,7 +45,27 @@ if [ ! -b "$rootdev" ]; then
         "(=$SNF_IMAGE_PROPERTY_ROOT_PARTITION) is valid."
 fi
 
-$MOUNT "$rootdev" "$SNF_IMAGE_TARGET" -o rw
+if [[ "$SNF_IMAGE_PROPERTY_OSFAMILY" == *bsd ]]; then
+    if ! $DUMPFS_UFS "$rootdev" &> /dev/null; then
+        os=${SNF_IMAGE_PROPERTY_OSFAMILY^^[bsd]}
+        log_error "For ${os^?} images only UFS root partitions are supported."
+    fi
+    ufstype="$(get_ufstype "$rootdev")"
+    if [ "x$ufstype" = "x" ]; then
+        exit 1
+    fi
+    $MOUNT -t ufs -o ufstype="$ufstype,rw" "$rootdev" "$SNF_IMAGE_TARGET"
+
+    # In many cases when you try to mount a UFS file system read-write,
+    # the mount command returns SUCCESS and a message like this gets printed:
+    #
+    #   mount: warning: /mnt seems to be mounted read-only.
+    #
+    # remounting does the trick
+    $MOUNT -o remount,rw "$SNF_IMAGE_TARGET"
+else
+    $MOUNT -o rw "$rootdev" "$SNF_IMAGE_TARGET"
+fi
 
 if [ "$SNF_IMAGE_PROPERTY_OSFAMILY" != "linux" ]; then
     exit 0