chiark / gitweb /
@@ -1,3 +1,14 @@
[chiark-utils.git] / backup / remountrocp
index 5e40cc37cc72976d5a7d827a9830de1f0f296683..d9ba15518a20c6279790b632b21c33ed88e9b965 100755 (executable)
@@ -59,7 +59,17 @@ mkfs -t $remountrocp_fs "$lvpath"
 mkdir -- "$snmnt"
 mount -t $remountrocp_fs $lvm_mount_opts "$lvpath" "$snmnt"
 
-mount -o remount,ro "$mountpoint"
+attempts=10
+while true; do
+       if mount -o remount,ro "$mountpoint"; then last; fi
+       attempts=$(( $attempts - 1 ))
+       if [ $attempts = 0 ]; then
+               echo >&2 'cannot remount readonly'
+               exit 1
+       fi
+       sleep 1
+done
+
 trap "mount -o remount,rw $mountpoint; exit 12" 0
 cp -a -- "$mountpoint/." "$snmnt/."
 mount -o remount,rw "$mountpoint"