uvtool (uvt-kvm) provides the ability to easily launch an ubuntu guest of kvm.
This can be used for testing curtin from bzr or from the Ubuntu archive.
For more information on getting started with uvtool, see Ubuntu doc. Once that is set up you can follow along here.
Note that much of this document is not uvt-kvm specific. That is just used as an easy way to get an Ubuntu vm with a spare disk. You could just as easily do this on a cloud instance (OpenStack, Azure, DigitalOcean).
Launch a machine and then wait for it to be up. Here we use --ephemeral-disk=4
twice to get 2 non-root disks of 4G in size.
$ uvt-kvm create --ephemeral-disk=4 --ephemeral-disk=4 sm-x1 release=xenial
$ uvt-kvm wait sm-x1
Note: From here on out, we are assuming you're on the vm.
If you want to use curtin trunk, you need to get bzr and then get curtin's dependencies.
$ sudo apt-get update -q
$ git clone https://git.launchpad.net/curtin
$ cd curtin
$ ./bin/curtin --install-deps
If you'd rather just install from the archive:
$ sudo apt-get update -q
$ sudo apt-get install --assume-yes curtin
Obviously you need something to install. Here we pick the 'squashfs' file as it is consistently available after xenial.
$ wget http://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64.squashfs -O /tmp/install.squashfs
Note that below we use 'fsimage:/tmp/install.squashfs' in the curtin command line to provide the install source. We could let curtin download that and remove it itself by instead providing 'fsimage://http://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64.squashfs'. For iteration/development, having the file downloaded is useful.
Whatever config you want is fine to provide to excercise whatever path you want to do.
There are many examples in examples/
directory in curtin.
Some things to be aware of that are shown here:
- showtrace: this key enables showing stack trace rather than erroring with just a message.
- path: /dev/vdc: This is the path to one of the 'ephemeral' disks we attached, which were both 4G in size. Make sure you get this right.
Here is the example config that should work for us:
$ cat install-config.yaml
showtrace: true
storage:
version: 1
config:
- id: disk1
type: disk
ptable: msdos
path: /dev/vdc
wipe: superblock
grub_device: true
- id: disk1p1
type: partition
number: 1
size: 3GB
device: disk1
flag: boot
- id: disk1_root
type: format
fstype: ext4
volume: disk1p1
label: 'testinstall-rootfs'
- id: disk1_mount
type: mount
path: /
device: disk1_root
reporting:
my-log:
type: log
level: "DEBUG"
install:
log_file: /tmp/install.log
We run the installation with '-vvv' so it is noisy, and provide it the path to the source directory we set up above.
$ sudo ./bin/curtin -vvv install --config=install-config.yaml \
fsimage:/tmp/install.squashfs
After the installation we should have a disk created as above.
Check out the disk partitioning:
$ sudo sfdisk -l /dev/vdc
Disk /dev/vdc: 4 GiB, 4294967296 bytes, 8388608 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x8ef570d2
Device Boot Start End Sectors Size Id Type
/dev/vdc1 2048 6293503 6291456 3G 83 Linux
And the disk labels:
$ sudo blkid /dev/vdc /dev/vdc1
/dev/vdc1: LABEL="testinstall-root" UUID="cd39e042-9fc0-11e7-9ca6-5254001034dd" TYPE="ext4" PARTUUID="8ef570d2-01"
And fstab was set up correctly:
$ sudo mount /dev/vdc1 /mnt/
$ chroot /mnt cat /etc/fstab
$ sudo chroot /mnt cat /etc/fstab
UUID=cd39e042-9fc0-11e7-9ca6-5254001034dd / ext4 defaults 0 0
/swap.img none swap sw 0 0
$ sudo chroot /mnt ls -lh /swap.img
-rw------- 1 root root 399M Sep 22 18:08 /swap.img
$ sudo umount /mnt