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"