Remount writable when moving the mountpoint of the persistence device.
authorJan Blunck <jblunck@vyatta.com>
Mon, 2 Sep 2013 15:27:41 +0000 (17:27 +0200)
committerDaniel Baumann <mail@daniel-baumann.ch>
Fri, 13 Sep 2013 12:15:52 +0000 (14:15 +0200)
If the persistence device has been mounted before, e.g. for mounting the
rootfs image file, then we should try to remount it writable. This way the
result for both cases, 1. was and 2. was not mounted before, are identical.

components/9990-misc-helpers.sh

index c502d59..4c8383d 100755 (executable)
@@ -722,15 +722,24 @@ mount_persistence_media ()
                fi
        elif [ "${backing}" != "${old_backing}" ]
        then
-               if mount --move ${old_backing} ${backing} >/dev/null
+               if mount --move ${old_backing} ${backing} >/dev/null
                then
-                       echo ${backing}
-                       return 0
-               else
                        [ -z "${probe}" ] && log_warning_msg "Failed to move persistence media ${device}"
                        rmdir "${backing}"
                        return 1
                fi
+               mount_opts="rw,noatime"
+               if [ -n "${PERSISTENCE_READONLY}" ]
+               then
+                       mount_opts="ro,noatime"
+               fi
+               if ! mount -o "remount,${mount_opts}" "${backing}" >/dev/null
+               then
+                       log_warning_msg "Failed to remount persistence media ${device} writable"
+                       # Don't unmount or rmdir the new mountpoint in this case
+               fi
+               echo ${backing}
+               return 0
        else
                # This means that $device has already been mounted on
                # the place expected by live-boot, so we're done.