Skip to content

Simple script to create a QEMU Debian image using debootstrap and nbd

License

GPL-2.0, GPL-3.0 licenses found

Licenses found

GPL-2.0
COPYING-GPL-2.txt
GPL-3.0
COPYING-GPL-3.txt
Notifications You must be signed in to change notification settings

naosnz/qemu-debian-create-image

 
 

Repository files navigation

qemu-debian-create-image

Simple script to create a QEMU Debian or Ubuntu Linux .qcow2 disk image using debootstrap and nbd.

Usage

sudo apt-get install debootstrap qemu-utils util-linux debian-archive-keyring
export FLAVOUR={debian|ubuntu}   # default: debian
export ARCH={amd64|...}          # default: amd64
export MIRROR=...                # default: http://deb.debian.org/debian
export IMGSIZE=...               # default: 8G
qemu-debian-create-image debian-test.qcow2 debian-test.hostname stretch

Any additional arguments will be passed through to debootstrap.

See blog post by Kamil Trzcinski for more detail. Note that this version of the script will also create the initial disk image for you (of IMGSIZE size) so it is nearly fully automated.

apt-cacher-ng can be used to reduce the download requirements by specifying a MIRROR value like:

http://localhost:3142/us.archive.ubuntu.com/ubuntu/

and with that style of MIRROR value should allow running offline providing all packages are cached.

Vagrant base box

To do additional setup for a Vagrant Base Box, to use with vagrant-libvirt you can run the setup-for-vagrant-base-box script at the end of the setup with:

export ...              # VM flavour, etc, as above
export DISKNAME=vda     # vagrant-libvirt assumes /dev/vda
export ETH_DEVICE=ens5  # vagrant-libvirt uses virtio, which ends up slot 5
export EXTRA_SETUP=setup-for-vagrant-base-box
qemu-debian-create-image debian-test.qcow2 debian-test.hostname stretch

and the script referred to by EXTRA_SETUP will be run at the end, before unmounting the disk image.

History

About

Simple script to create a QEMU Debian image using debootstrap and nbd

Resources

License

GPL-2.0, GPL-3.0 licenses found

Licenses found

GPL-2.0
COPYING-GPL-2.txt
GPL-3.0
COPYING-GPL-3.txt

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%