VM Creation (host part)
virt-install -v --accelerate --nographics -x console=ttyS0,115200 \ --name template-focal --vcpus=3 --ram $((1 * 1024)) \ --os-type=linux --os-variant=ubuntu18.04 --network bridge:br0 \ --disk path=/var/lib/libvirt/images/boot/template-focal-boot.img,bus=virtio,size=0.25,format=raw \ --disk path=/dev/justice/template-focal-root,bus=virtio,size=10 \ --location http://ubuntu.media.mit.edu/ubuntu/dists/focal/main/installer-amd64/
Obs: format=raw is mandatory, otherwise qcow2 format will be used by default. raw format allows us to easily create device mappings for the image.
The new VM will boot into the installer. Answer all questions with the defaults, except:
- Hostname: template-focal
- Mirror: enter information manually
- Mirror hostname: ubuntu.media.mit.edu
- (create your user with a strong password and no encrypted home)
- Partitioning: manual (see Partitioning below)
- Automatically install security updates
- Software selection:
- Basic Ubuntu Server
- OpenSSH server
- GRUB: let the installer setup grub on /dev/vda (which contains /boot)
The goal is to have a small disk file for the MBR and /boot, and a larger raw filesystem in an LVM Logical Volume. We don't want the LV to be partitioned because this makes it harder to resize, mount, etc.
Now create a partition table in the smallest disk (256MB) and create a single partition in it. Format this partition as ext4, labeled "boot" and mounted as /boot.
The installer won't let you format the entire disk as a filesystem, so go ahead and partition the 10GB disk too, then create a primary partition in it and format it as ext4, mounted as / and labeled "template-focal" ("template-focal-root" would exceed the ext4 limit).
Preferably, when asked for size, remove the contents and replace it with 'max'
And yes.. just in case you're wondering. We don't use swap partitions.
We'll have to fix the disk later.