-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KVM --disksize option to grow target disk image
This is needed for users with larger caches.
- Loading branch information
Showing
3 changed files
with
110 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
SUITE=lucid | ||
ARCH=amd64 | ||
SIZE=10G | ||
|
||
VMSW=KVM | ||
if [ -n "$USE_LXC" ]; then | ||
VMSW=LXC | ||
elif [ -n "$USE_VBOX" ]; then | ||
VMSW=VBOX | ||
fi | ||
|
||
usage() { | ||
echo "Usage: ${0##*/} [OPTION]..." | ||
echo "Resize target copy of the base client's disk image." | ||
echo | ||
cat << EOF | ||
--help display this help and exit | ||
--suite U build suite U instead of lucid | ||
--arch A build architecture A (e.g. i386) instead of amd64 | ||
--size N new disk image size, in | ||
EOF | ||
} | ||
|
||
if [ $# != 0 ] ; then | ||
while true ; do | ||
case "$1" in | ||
--help|-h) | ||
usage | ||
exit 0 | ||
;; | ||
--suite|-s) | ||
SUITE="$2" | ||
shift 2 | ||
;; | ||
--arch|-a) | ||
ARCH="$2" | ||
shift 2 | ||
;; | ||
--size) | ||
SIZE="$2" | ||
shift 2 | ||
;; | ||
--*) | ||
echo "unrecognized option $1" | ||
exit 1 | ||
;; | ||
*) | ||
break | ||
;; | ||
esac | ||
done | ||
fi | ||
|
||
export LXC_SUITE=$SUITE | ||
export LXC_ARCH=$ARCH | ||
|
||
OUT=target-$SUITE-$ARCH | ||
|
||
case $VMSW in | ||
KVM) | ||
out="$(qemu-img resize -f qcow2 "$OUT.qcow2" "$SIZE" || echo FAILED)" | ||
if grep -q "shrink" <<<"$out"; then | ||
echo "Disk image already large enough." | ||
exit 0 | ||
elif grep -q "FAILED" <<<"$out"; then | ||
exit 1 | ||
else | ||
echo "$out" | ||
fi | ||
;; | ||
*) | ||
echo "Growing disk images not supported with $VMSW" >&2 | ||
exit 1 | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends -y install expect-dev parted tcl | ||
root_partno=$(perl -nle 'm[^/dev/vda(\d+)\s+/\s]&&print $1' /proc/mounts) | ||
# TODO: Delete all swap and use space | ||
{ cat <<EOF; sleep 1; while pidof parted; do sleep 1; done; } | unbuffer -p parted /dev/vda | ||
resizepart Fix ${root_partno} yes 100% | ||
quit | ||
EOF | ||
resize2fs /dev/vda${root_partno} |