Uploading Custom Images to Openstack
Snapshots: Customizing Existing Openstack Images
Openstack Image Considerations
Openstack Image Tips
Minimize Image Size
Uploading Custom Images to Openstack
Due to space constraints, only the SCS Technical Staff can upload new custom images to Openstack. Please contact them to arrange for your image to be uploaded.
Snapshots: Customizing Existing Openstack Images
Snapshots are an easier alternative to building your own image before waiting for the SCS Technical Staff to vet and upload the image. To make a snapshot, you simply launch an instance using one of our existing images and then customize the instance as required. The instance can then be captured as a snapshot which can then be used as an image to launch other instances.
Benefits of snapshots based on an existing Openstack image:
- The SCS Technical Staff can permit you to create snapshots on Openstack
As opposed to custom images which can only be uploaded by the SCS Technical Staff - Our images are already tested on our Openstack environment. Customizing one allows you to avoid the risk of your image not being compatible with our Openstack or not working as expected.
- Our images are quite small, so building off them may help you keep your own image compact so that it launches as quickly as possible.
- Our images have a consistent environment and user interface, which also matches that of our course virtual machines (virtualbox/vmware). Thus, a large number of our Students, TAs, Instructors and Researchers will already be familiar with the basic environment. This may be helpful if other users will be using your image.
- If you plan to use a Multi-node compute cluster, you can create a customized instance with the environment required for your nodes. You can then snapshot it and use that snapshot to spawn all of the nodes. This way you don’t have to repeat the steps for setting up your environment on each of your nodes
Openstack Image Considerations
If you wish to put your own image onto the SCS Openstack, there are a few things to consider:
- Disk Size Considerations:
Ideally, your initial image’s disk space should be no larger than 8-16 GB. You can get additional space once it is operating in the SCS Openstack, but initially, you should try to keep the operating system and installed applications under that size so that they can be rapidly staged onto the compute nodes.
NOTE: The above size is the size of the physical disk, not the amount of actual data (which will be less). When creating an image with a virtualization tool, start with a disk size that is as small as possible and only increase it by a small amount as required. - Networking Considerations:
The operating system may differ in how it names virtual networking devices, so you should NOT hardcode network settings into your operating system and instead rely on a generic config that uses DHCP, as required by Openstack. This way, whether you create the image in Openstack, virtualbox, vmware, kvm, etc., the instances should still properly get an IP address when launched on Openstack
Openstack Image Tips
- Snapshots: Instead of building an image on your own computer, launch an instance on the SCS Openstack using one of our existing – optimized – images. You can then customize this image as you require, and we can then capture a snapshot of it for you to use as an image.
- No Data!: Do not save computational data on your image, as this will increase its size and cause delays when you want to launch an image. It is always possible to add the data to the instances once they are running
- Minimum Physical Disk Size: Keep the size of your physical disk as small as possible (8-16 GB – see above). Ideally, you should only have 30-40% or less of free space. It is easy to add space to an image later, but removing it to make the image smaller requires additional effort.
Minimize Image Size
Here are some tips that can help you reduce the amount of data in your image, and reduce the size of the image/snapshot file:
- Remove swap partitions/files – swap partitions are not needed in an image. They can easily be added later if needed
swapon -s
– should not show any files or partitions
/etc/fstab
– make sure no swap is defined. - Clean-up distro cache – make sure there are no unnecessary packages and that the cache is clear (eg: ubuntu):
apt autoremove
– removes dependent packages that are no longer required
apt clean
– cleans the cache - Clear excess log files – check
/var/log
for large log files that are not needed
Clear ubuntu system log:journalctl --vacuum-size=32M
– This clears all but the last 32 MB of log files - IMPORTANT Final step: zero the disk – “zero” all of the empty disk space on the server. This is vital as deleting files in linux usually just de-links the file, but does not “zero” the data. When openstack captures the image, even though the file is deleted, the data (bits) is still there and gets copied into the image/snapshot. Zeroing the disk ensures this space appears empty and is not captured in the image/snapshot.
cat /dev/zero > zero.file ; sync ; sleep 1 ; sync ; rm zero.file
– This sequence of commands uses the/dev/zero
device to create a file of just zero (0) bits that fills the entire disk, and is then deleted.