summaryrefslogtreecommitdiff
path: root/bin/debvm-create
diff options
context:
space:
mode:
authorHelmut Grohne <helmutg@debian.org>2023-01-17 13:07:26 +0000
committerHelmut Grohne <helmutg@debian.org>2023-01-17 13:07:26 +0000
commit8961c87b6b1289d50e7e53cbca497f5ee9ed7b3c (patch)
treeeec289dc0eb4ff5c33dbb0c813c3c9270354a08c /bin/debvm-create
parent0564f314afc45b757a5813e5c6e485dc343a6b2d (diff)
parentefd7142c00191bbe06ff9f6a6995583d97cd4da3 (diff)
downloaddebvm-8961c87b6b1289d50e7e53cbca497f5ee9ed7b3c.tar.gz
Merge branch 'cleanup' into 'main'
Cleanup See merge request helmutg/debvm!25
Diffstat (limited to 'bin/debvm-create')
-rwxr-xr-xbin/debvm-create30
1 files changed, 18 insertions, 12 deletions
diff --git a/bin/debvm-create b/bin/debvm-create
index 2e838f2..637d613 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
@@ -63,6 +63,12 @@ The following tasks may be skipped.
=over 4
+=item B<autologin>
+
+Skips adding a the customize-autologin.sh to B<mmdebstrap> that configures
+automatic root login on a serial console and also parses the C<TERM> kernel
+cmdline and passes it as C<TERM> to B<agetty>.
+
=item B<kernel>
skips installing a linux kernel image.
@@ -86,9 +92,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.
@@ -118,7 +125,7 @@ set -u
ARCHITECTURE=$(dpkg --print-architecture)
IMAGE=rootfs.ext4
-SIZE=$((1024*1024*1024))
+SIZE=1G
SKIP=,
SSHKEY=
SUITE=unstable
@@ -136,7 +143,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
@@ -163,7 +170,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
@@ -300,7 +307,9 @@ if ! check_skip usrmerge; then
set -- --hook-dir=/usr/share/mmdebstrap/hooks/maybe-merged-usr "$@"
fi
-set -- "--customize-hook=$SHARE_DIR/customize-autologin.sh" "$@"
+if ! check_skip autologin; then
+ set -- "--customize-hook=$SHARE_DIR/customize-autologin.sh" "$@"
+fi
set -- "$SUITE" "$IMAGE" "$@"
@@ -308,11 +317,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"