Skip to end of metadata
Go to start of metadata

An Xandr instance image is a gzipped tarball containing the whole filesystem of a Linux host.  These instructions will help you create an image from an external instance.  To create an image of an offline Xandr instance, please use the "manage-instance bundle" command.

Prerequisites for Creating an Image

1. Partitioning

Make sure /etc/fstab satisfies the partitioning scheme and contains the following:

# Required part
/dev/sda1               /                       ext3    defaults        1 1
/dev/sda2               swap                    swap    defaults        0 0
proc                    /proc                   proc    defaults        0 0
# May vary for different Linux distributions, check your original /etc/fstab
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
2. Kernels and Modules

You must select a Xen compatible kernel to use. Here is a link to supported kernels: There may be other restrictions as well. For instance, Ubuntu requires selecting the EC2 kernel and bootloader in order to function properly.

3. Networking

The imaged operating system must be configured to use a single network interface with DHCP enabled.  Additionally, since MAC addresses vary between different instances, network configuration files must contain no old MAC addresses (/etc/sysconfig/network-scripts/ifcfg-eth0 for RedHat based distros).

Moreover, some services may produce problems, if they detect that a MAC address has changed.  For example the "kudzu" service should be disabled by running the following script for RedHat based distros:

chkconfig kudzu off

For Debian based distros, "udev" service has the same caveat.  Run the following script before imaging:

rm -f /etc/udev/rules.d/*persistent-net.rules
4. Avoid File Modification While an Creating Image

Stop all services that may make important changes to any files during the reading of filesystem while imaging (like mysql, postgresql, ldap, apache, ftp servers, …).  Alternate ways to do this are: reboot to single-user mode (pass "-s" kernel parameter via bootloader), or boot from Live CD and mount a Linux partition to the image.

Creating the Image

First, select the partition in which to store the image; it must have enough free space to keep the tarred image before gzipping and the final gzipped tarball (about 120% of total disk space used by the operating system before imaging).

Then cd to / and run

tar cf /path/to/image/destination/image_name.fs.tar --exclude=/path/to/image/destination/image_name.fs.tar <all_dirs_and_files_in_root_dir_except_mentioned_below>

The directories list must exclude dirs that contain special files and pseudo-filesystems.  For CentOS, the /dev, /proc, /sys, and /tmp dirs should be excluded.  Exclude /media and /mnt if you have any data mounted there and don't want them to go to the image.

The next step is to add excluded directories without files in them:

tar rf /path/to/image/destination/image_name.fs.tar --no-recursion <excluded_previously_dirs>

The last operation is compressing the image:

gzip /path/to/image/destination/image_name.fs.tar

For CentOS and /mnt partition as destination, commands are as follows:

cd /
tar cf /mnt/newimage.fs.tar --exclude=/mnt/newimage.fs.tar .autorelabel bin boot etc home lib lib64 misc opt root sbin selinux srv usr var
tar rf /mnt/newimage.fs.tar --no-recursion dev media mnt proc sys tmp
gzip /mnt/newimage.fs.tar

As a result, you'll get a file named /path/to/image/destination/image_name.fs.tar.gz (.gz is added by gzip by default).  Now, the image can be uploaded to storage.  Note that the image extension doesn't matter, but we recommend changing it to .fs.tgz (meaning: "gzipped tarball of a filesystem").

Uploading to Xandr Storage

Private shared storage accessible from all your instances has been created for you with a name like custXXX, where XXX is a number of your share.

If you don't have this share mounted on your management instance:

# Create mountpoint and mount your share on it:
mkdir /mnt/custXXX
mount -t nfs /mnt/custXXX -o defaults,tcp,intr,rw

Replace XXX with the share number, set the proper username, and type share_password when prompted.

# Create a subdir for image on your share (this is optional, but recommended for better share space organization):
mkdir /mnt/custXXX/images/
# Copy your custom image to the share:
scp image_name.fs.tar.gz root@<instance IP>:/mnt/custXXX/images/

Click here for directions on starting an instance from a custom image.

  • No labels