diff options
Diffstat (limited to 'bin/debvm-create')
-rwxr-xr-x | bin/debvm-create | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/bin/debvm-create b/bin/debvm-create index 95305a9..c58092c 100755 --- a/bin/debvm-create +++ b/bin/debvm-create @@ -11,7 +11,7 @@ debvm-create - Create a VM image for various Debian releases and architectures =head1 SYNOPSIS -B<debvm-create> [B<-a> I<architecture>] [B<-h> I<hostname>] [B<-k> F<sshkey>] [B<-o> F<output>] [B<-r> I<release>] [B<-s> <task>] [B<-z> I<size_in_GB>] [B<--> I<mmdebstrap options>] +B<debvm-create> [B<-a> I<architecture>] [B<-h> I<hostname>] [B<-k> F<sshkey>] [B<-o> F<output>] [B<-r> I<release>] [B<-s> <task>] [B<-z> I<size>] [B<--> I<mmdebstrap options>] =head1 DESCRIPTION @@ -86,9 +86,10 @@ Without the hook, dependencies will pull the B<usrmerge> package as needed, whic =back -=item B<-z> I<size_in_GB>, B<--size>=I<size_in_GB> +=item B<-z> I<size>, B<--size>=I<size> -Specify the minimum image size in giga bytes. +Specify the minimum image size as an integer and optional unit (example: 10K is 10*1024). +Units are K,M,G,T,P,E,Z,Y (powers of 1024) or KB,MB,... (powers of 1000). The resulting image will be grown as a sparse file to this size if necessary. The default is 1 GB. @@ -112,7 +113,7 @@ set -u ARCHITECTURE=$(dpkg --print-architecture) IMAGE=rootfs.ext4 -SIZE=$((1024*1024*1024)) +SIZE=1G SKIP=, SSHKEY= SUITE=unstable @@ -130,7 +131,7 @@ die() { exit 1 } usage() { - die "usage: $0 [-a architecture] [-h hostname] [-k sshkey] [-o output] [-r release] [-s task] [-z size_in_GB] [-- mmdebstrap options]" + die "usage: $0 [-a architecture] [-h hostname] [-k sshkey] [-o output] [-r release] [-s task] [-z size] [-- mmdebstrap options]" } usage_error() { echo "error: $*" 1>&2 @@ -157,7 +158,7 @@ opt_release() { SUITE=$1 } opt_size() { - SIZE=$(($1*1024*1024*1024)) + SIZE=$1 } while getopts :a:h:k:o:r:s:z:-: OPTCHAR; do @@ -296,11 +297,8 @@ set -ex mmdebstrap "$@" -IMAGESIZE=$(stat -c %s "$IMAGE") -if test "$IMAGESIZE" -lt "$SIZE"; then - truncate -s "$SIZE" "$IMAGE" - /sbin/resize2fs "$IMAGE" -fi +truncate -s ">$SIZE" "$IMAGE" +/sbin/resize2fs "$IMAGE" /sbin/tune2fs -L debvm -i 0 -O extents,uninit_bg,dir_index,has_journal "$IMAGE" # Must fsck after tune2fs: https://ext4.wiki.kernel.org/index.php/UpgradeToExt4 /sbin/fsck.ext4 -fDp "$IMAGE" |