Install Ubuntu 14.04 from cloud image

From PrgmrWiki

This guide will show you how to:

As of the date this guide was written, Prgmr does not offer an Ubuntu 14.04 image, so this is probably the easiest way to get up and running with a fresh install of 14.04.

32- vs 64-bit

The author of this guide could not get an Ubuntu 14.04 64-bit kernel to boot on Prgmr (specifically the wemyss server). Hopefully this will change, but in the meanwhile, this guide assumes you are performing a 32-bit install.

Alternatively, as a workaround to boot 64-bit Ubuntu 14.04, I have had luck replacing the latest Ubuntu kernel with the kernel from saucy or earlier versions.

Wipe the system

Since we are extracting from an image, you'll want to start from a clean slate.

  1. Boot CentOS rescue (2.6.18-92.el5xen) from GRUB
  2. Wipe the filesystem:
    mkfs.ext3 -L cloudimg-rootfs /dev/xvda1
  3. Mount the new filesystem:
    mount -n /dev/xvda1 /mnt

Extract the cloud image

Download the cloud image to /mnt:

cd /mnt
wget -qO - "$imageurl" | tar xzf - trusty-server-cloudimg-i386.img

Next, extract the image:

mkdir /tmp/trusty-server-cloudimg-i386
mount -o loop,ro trusty-server-cloudimg-i386.img /tmp/trusty-server-cloudimg-i386
cp -a /tmp/trusty-server-cloudimg-i386/* .
rm -f trusty-server-cloudimg-i386.img       # optional cleanup

Configure Grub

To get the system to boot, update menu.lst to point to /dev/xvda1 instead of /dev/xvda:

sed -i '/^##/ !s/(hd0)/(hd0,0)/' /mnt/boot/grub/menu.lst

Configure cloud-init

To get cloud-init to initialize the system on first-boot, we need to create two files (meta-data and user-data).

Create the first file, /mnt/var/lib/cloud/seed/nocloud/meta-data, with the contents:

instance-id: SERVER_NAME
local-hostname: SERVER_FQDNS_NAME

(Replace SERVER_NAME and SERVER_FQDNS_NAME with the actual values you want to use.)

Create the second file, /mnt/var/lib/cloud/seed/nocloud/user-data, with the contents:

     - ecdsa-sha2-nistp256 AAAA… user@host

Important: replace ecdsa-sha2-nistp256 … with your public key (from $HOME/.ssh/ or from $HOME/.ssh/ or whichever public key you want), otherwise you will not be able to log in.

The file is in YAML format. See the documentation to get an idea of all the things you can configure with this file.

Boot the instance

Reboot your VPS. The new Ubuntu instance should start automatically. cloud-init will run on the first-boot based on the configuration you supplied in the previous step.

Once it is finished booting, you can SSH in to the instance with the ubuntu user:


No password is configured — you must authenticate with the ssh key that you listed in the user-data file.

Final notes

It appears that cloud-init does not enable shell access over the console. This is unfortunate, as it makes it more difficult to regain access to the VPS if for some reason SSH stops working.