Skip to content

Commit

Permalink
Use online resize2fs, and run filesystem check only when needed
Browse files Browse the repository at this point in the history
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
  • Loading branch information
marmarek committed Feb 27, 2017
1 parent d8e568f commit 9f9c3c5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
10 changes: 10 additions & 0 deletions init/setup-rw.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
#!/bin/sh

dev=/dev/xvdb

if mountpoint -q /rw ; then
# This means /rw is mounted now.
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
echo "Virgin boot of the VM: populating /rw/config" >&2

Expand Down
24 changes: 4 additions & 20 deletions init/setup-rwdev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,11 @@ if [ -e "$dev" ] ; then
fi
fi

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
echo "Private device management: checking $dev" >&2
if content=$(fsck.ext4 -p "$dev" 2>&1) ; then
echo "Private device management: fsck.ext4 of $dev succeeded" >&2
else
echo "Private device size management: resize2fs $dev failed:" >&2
echo "Private device management: fsck.ext4 $dev failed:" >&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
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

0 comments on commit 9f9c3c5

Please sign in to comment.