How to create an image from scratch

This page shows how to create a new image from scratch. This process consists in building a root filesystem in an extra volume of one of your servers.

The following procedure will create an Ubuntu based image from scratch.


When you create a server you have to select a base image. If you create your own base image, you can customize more deeply.

There are four steps to create a new image from scratch:

  • Create the root filesystem
  • Create a snapshot
  • Create an image from a snapshot
  • Create a new server with your image

Create the root filesystem

Connect to your server and execute the following command:

apt-get update
apt-get install debootstrap

Debootstrap is used to install Debian-like systems without using an installation disk. This way, you can create a fully functioning minimal installation.

Then, we create a bash script to build our image.

Each part of the script is described line by line.


# Name  of  the  bootstrap  script variant to use.
# Currently, the variants supported are minbase,
# which  only  includes  essentialpackages  and  apt;  buildd,
# which installs the build-essential
# packages  into  TARGET;  and  fakechroot,  which  installs   the
# packages  without  root  privileges.   Finally  there is variant
# scratchbox, which is for creating targets for scratchbox  usage.
#  The  default,  with no --variant=X argument, is to create a base

# The system architecture, C1 server architecture type is armhf

# Use packages from the listed components of the archive.

# The volume to boostrap the system

# The list of packages included in the system

PKGS_INCLUDE='ca-certificates, cron, curl, iptables, iputils-ping, isc-dhcp-client, less,libnss-myhostname, man-db, nano, nbd-client, net-tools, ntp, ntpdate, rsyslog, ssh, sudo, vim, wget, whiptail, xnbd-client'



# Check if directory DEBOOTSTRAP_DIR exists
if [ ! -d "$DEBOOTSTRAP_DIR" ]; then

# Format /dev/nbdx volume

# Format & Mount /dev/nbdx in #DEBOOTSTRAP_DIR
if [ ! `mountpoint -q $DEBOOTSTRAP_DIR` ]; then
  mkfs.ext4 $DEVICE

# Bootstrap a basic Ubuntu trusty system
 debootstrap --arch $ARCH --variant=$VARIANT --components "$COMPONENTS" --include "$PKGS_INCLUDE" trusty $DEBOOTSTRAP_DIR "$MIRROR"

for i in {1..6}
  echo manual > $DEBOOTSTRAP_DIR/etc/init/tty$i.override

# The list of files required to copy on the template

# Upstart job - Maintains a getty on ttyS0

# Upstart job - Fetches ssh-keys associated with your account in `/root/.authorized_keys`
FILES_TO_COPY+=" /etc/init/ssh-keys.conf"

# Upstart job - Preserves the NBD client process on shutdown
FILES_TO_COPY+=" /etc/init/nbd-root-preserve-client.conf"

# Upstart job - Gracefully umount and disconnect root volume
FILES_TO_COPY+=" /etc/init/nbd-root-disconnect.conf"

# Upstart job - Connects additional volumes to NBD server
FILES_TO_COPY+=" /etc/init/nbd-add-extra-volumes.conf"

# Upstart job - Synchronizes kernel modules
FILES_TO_COPY+=" /etc/init/sync-kernel-modules.conf"

# This script is required by `/nbd-root-disconnect.conf` to disconnect root volume gracefully.
FILES_TO_COPY+=" /usr/sbin/nbd-disconnect-root"

# Variables for the behavior of boot scripts
FILES_TO_COPY+=" /etc/default/rcS"

# ntpd service configuration with appropriate NTP servers
FILES_TO_COPY+=" /etc/ntp.conf"

# Map some hostnames to IP addresses before DNS can be referenced.
FILES_TO_COPY+=" /etc/hosts"

# Kernel options related on C1 server
FILES_TO_COPY+=" /etc/sysctl.conf"

# Network interfaces configuration
FILES_TO_COPY+=" /etc/network/interfaces"

# Executable which synchronizes kernel modules
FILES_TO_COPY+=" /usr/sbin/oc-sync-kernel-modules"

# Executable which retrieves server metadata (TEXT)
FILES_TO_COPY+=" /usr/local/bin/oc-metadata"

# Executable which retrieves server metadata (JSON)
FILES_TO_COPY+=" /usr/local/bin/oc-metadata-json"

# DHCP hook
FILES_TO_COPY+=" /etc/dhcp/dhclient-exit-hooks.d/hostname"

# Copy files above in the appropriate directory


Important: All scripts source are available on the official image.

Execute the script above on your server chmod +x ./ && ./
Finally, stop your server.

Create a snapshot

At this point the extra volume contains a valid Ubuntu root filesystem. We must now transform this volume into a snapshot.

Once you server is powered off, from the servers page, select the server you created the image with.
Click the “Snapshot” button on the extra volume (in our example “volume_to_backup” - /dev/nbd1).

Volume snapshot

Create an image from snapshot

In the Control Panel, click “Volumes” in the compute section.
On this page, select the snapshot containing your rootfs and click “Create an image from snapshot”.

Create a new server with your image

Create a new server and choose your image in “My images” section.

Your server will start on your own “from scratch” image.

Discover the Cloud That Makes Sense