Use online resize2fs, and run filesystem check only when needed
When trying offline resize2fs, it require running fsck first, which takes time, especially on large volumes. And in most cases, resize2fs will notice that no action is needed - after wasting some time on fsck. To remedy this, use resize2fs in online mode (on mounted filesystem). And drop fsck call if it fails (filesystem is already mounted read-write, running fsck isn't good idea). But do not remove fsck call completely - still call it, but without '-f' flag, so it run actual check only when really needed (unclean shutdown, last check far in the past etc). Fixes QubesOS/qubes-issues#979 Fixes QubesOS/qubes-issues#2583
This commit is contained in:
parent
d8e568fa13
commit
9f9c3c56fc
@ -1,9 +1,19 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
dev=/dev/xvdb
|
||||||
|
|
||||||
if mountpoint -q /rw ; then
|
if mountpoint -q /rw ; then
|
||||||
# This means /rw is mounted now.
|
# This means /rw is mounted now.
|
||||||
echo "Checking /rw" >&2
|
echo "Checking /rw" >&2
|
||||||
|
|
||||||
|
echo "Private device size management: enlarging $dev" >&2
|
||||||
|
if content=$(resize2fs "$dev" 2>&1) ; then
|
||||||
|
echo "Private device size management: resize2fs of $dev succeeded" >&2
|
||||||
|
else
|
||||||
|
echo "Private device size management: resize2fs $dev failed:" >&2
|
||||||
|
echo "$content" >&2
|
||||||
|
fi
|
||||||
|
|
||||||
if ! [ -d /rw/config ] ; then
|
if ! [ -d /rw/config ] ; then
|
||||||
echo "Virgin boot of the VM: populating /rw/config" >&2
|
echo "Virgin boot of the VM: populating /rw/config" >&2
|
||||||
|
|
||||||
|
@ -26,27 +26,11 @@ if [ -e "$dev" ] ; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Private device size management: enlarging $dev" >&2
|
echo "Private device management: checking $dev" >&2
|
||||||
if content=$(resize2fs "$dev" 2>&1) ; then
|
if content=$(fsck.ext4 -p "$dev" 2>&1) ; then
|
||||||
echo "Private device size management: resize2fs of $dev succeeded" >&2
|
echo "Private device management: fsck.ext4 of $dev succeeded" >&2
|
||||||
else
|
else
|
||||||
echo "Private device size management: resize2fs $dev failed:" >&2
|
echo "Private device management: fsck.ext4 $dev failed:" >&2
|
||||||
echo "$content" >&2
|
echo "$content" >&2
|
||||||
echo "Private device size management: attempting to mark $dev clean" >&2
|
|
||||||
if content=$(fsck.ext4 -fp "$dev" 2>&1) ; then
|
|
||||||
echo "Private device size management: $dev marked clean, enlarging it again" >&2
|
|
||||||
if content=$(resize2fs "$dev" 2>&1) ; then
|
|
||||||
echo "Private device size management: resize2fs of $dev succeeded" >&2
|
|
||||||
else
|
|
||||||
echo "Private device size management: resize2fs of $dev failed even after marking file system clean:" >&2
|
|
||||||
echo "$content" >&2
|
|
||||||
echo "Private device size management: expect serious trouble ahead" >&2
|
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
echo "Private device size management: $dev could not be marked clean:" >&2
|
|
||||||
echo "$content" >&2
|
|
||||||
echo "Private device size management: expect serious trouble ahead" >&2
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user