This short article describes how to create a custom image for a server that can be deployed as a “private image” on the Oracle Public Cloud. This is not really security-related but may still be helpful for someone.
The first step is to use Oracle’s free VirtualBox virtualization app to create a new VM image. Download VirtualBox if you don’t have it and then create a new image. In my case, I’m creating a FreeBSD VM by first booting from a FreeBSD “boot only” ISO image. I create the VM with two virtual CPUs (vCPUs), 7.5GB of RAM and 50GB of disk since that is the default shape of the smallest image on the Oracle Public Cloud (OPC).
By default VirtualBox creates the VM with VMDK disk files. This doesn’t work with OPC so we need to convert the disk image to an .img format. The easiest way is to follow a two-step procedure, starting with a command line utility that gets installed on the Mac when you first installed VirtualBox. Navigate to the directory for your VM and issue the following command in a terminal window:
VBoxManage clonehd /path/to/MyVMfile.vmdk --format VDI /path/to/MyVMfile.vdi
The next step is to convert the VDI image into an IMG file. Note that this will be a huge file, in this case 50GB with lots of empty space inside, so make sure you have enough space before proceeding:
VBoxManage internalcommands converttoraw /path/to/MyVMfile.vdi /path/to/MyVMfile.img
On Linux and Windows, we would then create a sparse copy of this file to significantly reduced its size. Unfortunately, Mac is based on BSD and their HFS+ filesystem does not support sparse files. Your options are to either copy the file into Linux or Windows and perform a sparse copy before creating a compressed tarball to upload to OPC, or just suck it up and use the massive 50GB file.
Finally, we’ll tar/gzip it up before uploading to Oracle Public Cloud:
tar -czSf /path/to/MyVMfile_sparse.tar.gz /path/to/MyVMfile_sparse.img
You might as well delete the huge .img file now to save space.
If you have any problems, leave a comment here or email me and I’ll see if I can help you out.