Run a Custom Distro on a KVM Linode
Updated by Alex Fornuto
This guide entails installing a custom Linux distribution on your KVM Linode. If you’re currently running a Xen Linode, you can upgrade, or follow our older guide on Running a Custom Linux Distribution on a Linode.
While there are methods of installing operating systems in place on the Linode, they often create partition tables on the disk image which are incompatible with our Backups service, and prevent us from resizing the disk image properly. Therefore we will install the operating system on a virtual image locally, then copy the filesystem to the Linode.
For this guide we’ll be using Ubuntu as an example, but you’re welcome to apply these steps to any compatible OS.
Before You Begin
Make sure you have a working installer ISO for the distribution. In our example, we’ve downloaded the Ubuntu 15.04 Server ISO from the Ubuntu Downloads page.
Have a virtual machine manager installed. In this example we’ll be using Oracle’s VirtualBox.
A local copy of the Finnix ISO.
Create the Virtual Machine
From VirtualBox, create a new virtual machine:
Name your new virtual machine based on your selected distribution. In this example the virtual machine is named Ubuntu 15.04. VirtualBox should recognize the name and assign the correct type and version:
Select the RAM and hard drive size for your virtual machine. Because we need to transfer the entire filesystem to the Linode, make your disk image as small as possible. In this example we’ve set the virtual machine to 512MB RAM and 2048MB of disk space.
After you’ve created your new virtual machine, right-click on it and select Settings. From the Storage tab, select the IDE disk device, which should currently say
Empty. Click on the disk icon to the right, and select Choose a virtual CD/DVD disk file. Select the Ubuntu install ISO.
In the main VirtualBox window, select your new virtual machine and click on Start. Install the operating system as you would on any physical machine. Take note of what device and partition you install your system to.
Using disk encryption and/or LVM partition schemas will interfere with our Backups service, and may inhibit the ability to resize your Linode’s disk images later. The same applies for file systems other than ext3/4.
Ensure that the OpenSSH package is selected during the installation process. Without this package you will only be able to access your Linode through the Lish console.
Prepare the Linode
From the Linode Manager create a new Linode. Under the Disks section of the Linode Dashboard, click on Create a new Disk:
Label your new disk image and choose an appropriate size. Leave the Type as ext4. Once complete, click on Save Changes.
Repeat these steps for any additional disk images you wish to make, such as a swap disk.
Select the Create a new Configuration Profile option. Assign a label, and select your disk images under Block Device Assignment. Remember this configuration, as you will need to modify your
/etc/fstabfile to match. If you choose a device assignment other than
/dev/sdafor root device, be sure to update the root / boot device drop-down menu:
At this point you have the option of using the Linux kernel provided by Linode, or the one provided by your distribution. For more information, check out our guide Run a Distribution-Supplied Kernel on a KVM Linode.
Click on Save Changes once your profile is complete.
Return to the Linode Dashboard, and select the Rescue tab. From there, click the Reboot into Rescue Mode button. Your Linode will now boot into the Finnix recovery image. Use the Lish shell to access your Linode.
Run the following set of commands to create a root password and enable the SSH server:
passwd service ssh start
Copy the Disk Image
Power down your local virtual machine, either via the VirtualBox interface, or by issuing the following command at the virtual machine’s terminal:
shutdown -h now
Return to your virtual machine’s storage settings and attach the Finnix ISO
Restart your virtual machine, and boot into the Finnix console. You can use
ls /dev/sd*to verify the disk images and partitions:
root@tty1:~# ls /dev/sd* /dev/sda /dev/sda1 /dev/sda2 /dev/sda5
Copy the system partition to your Linode’s system disk. Replace
/dev/sda1with your system partition,
220.127.116.11with your Linode’s IP address, and
/dev/sdawith the target disk image on your Linode:
dd if=/dev/sda1 | pv | ssh email@example.com "dd of=/dev/sda"
By piping our
pv, we can track the progress of the transfer. The
ddcommand will transfer the entire partition including empty space, this process will take some time.
Configure the transferred image
While still booted into Finnix on your Linode, mount the newly transferred disk:
Remove the tty service for the graphic console:
/media/sda/etc/fstaband replace the contents. You can use the example below as a template; be sure to modify for the block device assignment you chose:
1 2 3 4 5 6 7 8 9 10
# /etc/fstab: static file system information. # # Use 'blkid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # <file system> <mount point> <type> <options> <dump> <pass> proc /proc proc defaults 0 0 /dev/sda / ext4 noatime,errors=remount-ro 0 1 /dev/sdb none swap sw
1 2 3
unlink /media/sda/etc/resolv.conf echo "# resolv.conf - DNS resolver configuration file" > /media/sda/etc/resolv.conf echo "options rotate" > /media/sda/etc/resolv.conf.tail
Reboot your Linode.
Your Linode should now be running your custom distro!
This guide is published under a CC BY-ND 4.0 license.