df_out="$(really df -P --block-size=$extsize $mountpoint)"
extents2="$(printf "%s" "$df_out" | awk '/^\// {print $3}')"
- extents2=$(( ($extents2*150+99)/100 + 4 ))
+ extents2=$(( ($extents2*150+102399)/102400 + 4 ))
lvmextentscore2
fi
$vgroup \
$lvm_lvcreate_args
-mkfs -t $remountrocp_fs "$lvpath"
+mkfs -t $remountrocp_fs -q "$lvpath"
+
mkdir -- "$snmnt"
mount -t $remountrocp_fs $lvm_mount_opts "$lvpath" "$snmnt"
+echo ' copy filesystem created and mounted'
-mount -o remount,ro "$mountpoint"
-trap "mount -o remount,rw $mountpoint; exit 12" 0
-cp -a -- "$mountpoint/." "$snmnt/."
+attempts=10
+while true; do
+ if mount -o remount,ro "$mountpoint"; then break; fi
+ attempts=$(( $attempts - 1 ))
+ if [ $attempts = 0 ]; then
+ echo >&2 'cannot remount readonly'
+ exit 1
+ fi
+ sleep 1
+done
+trap "set +e; mount -o remount,rw $mountpoint; exit 12" 0
+echo ' source remounted readonly, copying...'
+cp -ax -- "$mountpoint/." "$snmnt/."
+echo ' finalising...'
mount -o remount,rw "$mountpoint"
trap '' 0
mount -o remount,ro "$lvpath"