- Provision with the latest Ubuntu template from the control panel. At the time of writing this was ubuntu18img.
- Once the machine is booted, login as root over the noVNC console (you may wish to SSH in to easy copy&paste but have a noVNC console open as you'll need it at points) and run:
- Stop the cloud init scripts running and setup grub so you can see the boot menu easily:
- We then create a simple script to ease tasks when we drop to the initramfs shell
- Time for the first reboot - keep an eye on the noVNC as you'll need it to get into the initramfs
- Go to 'Advanced options for Ubuntu' and press 'e' when the latest kernel's recovery mode option is selected.
- Edit the 'linux' line and remove all options but add 'ro init=/bin/sh'
- Press Ctrl-X to boot
- You'll now be at an initramfs prompt
- Once here you'll need to make a directory, mount the root drive, copy the script we made earlier and run it. After running it the machine will reboot.
- Reboot to your previous ubuntu install. On logging in you'll now see you have a small root (/) partition of only a few gig rather than the previous one that took the whole disk.
- We'll now shrink the partition table to match this size, and create a new partition to hold a copy of the current install. Because we are working on an active disk we'll need to reboot after this
- Now we have sda1 - the shrunk root from the initial install, sda13 - a bare parition to copy the initial install to along with sda14 and sda15 for Boot and EFI. Lets copy sda1 to sda13:
- We'll then mount sda13 and make some changes to make it bootable
- Now for another reboot, this time you should find yourself on sda13 as the root - you can confirm with df. It's an exact copy so you shouldn't see anything different other than this.
- So now we can re-use sda1 so lets delete it first
- Optional Step: Having the partitions in a strange order (sda14 and 15) seems odd to me so I re-number them also. Another reboot here to make sure we have a clean working system
- Now lets create the new partition for LUKS and LVM. Again, because it's an active disk we'll need to reboot :-(
- Now we setup LUKS and LVM - you might want a different layout here:
- Now is the time to reinstall to the new structure. First step mount it all:
- Next step install debootstrap and install a base system to it. I'm using groovy here:
- We can now chroot into that install and create an apt sources file, generate an fstab and install some required packages:
- Because I'm using LUKS I also setup CRYPTODISK settings for grub and create the keyfile script
- Now time to regenerate the initramfs, update grub and install it
- At this point I also update the root passwd and generate some users and configure the network
- You can now drop out of the chroot, unmount everything, delete the old install, grow the paritions to fullsize and do a final reboot into your new system
- You'll just want to max on the PV Size like so as the final step... no reboot needed this time! :D