Creating a disk image file


This is a general article that describes the main steps for converting disks to image files for subsequent download from SIM-Cloud. In the example given, the procedure is described for advance preparation of the disks and their conversion using qemu-img software.

Basic information

Use of the following content requires intermediate skills in working with operating systems of the Linux family. Additionally, the content of this article is intended for users with an understanding of how to work with block devices in Linux, the basic possibilities offered by the management interface for SIM-Cloud, the Dashboard, and who have familiarised themselves with the following technical articles:

Basic steps for converting a disk to an image file

Initial requirements

  1. Ensure that the project has sufficient free resources (CPU, RAM, disk space) for the deployment of a temporary instance based on an image of a Linux family OS.
  2. The amount of free disk space of the temporary instance, following OS setup, should be sufficient to accommodate the disk image.
  3. If necessary, the required resources can be purchased for the minimum period of availability.

Creating a temporary instance on the basis of a Linux family OS image

  1. The task is to create an instance on the basis of a Linux family OS image to perform all operations for creating an image file of the required disk. It will also be possible to run and configure a FTP server on this OS that can be used to retrieve the file.
  2. We recommend the use of an OS based on Ubuntu or Debian.
  3. For creating the temporary instance we recommend the use of a type not smaller than SIM-A1 (2 vCPU, 4GB RAM) to ensure a convenient speed of operation.
  4. When creating the disk to launch the temporary instance, ensure that a sufficient amount of free disk space is reserved on it for this. We recommend that you reserve a volume not less than 100% of the size of the source disk for which you are creating an image file.
  5. Set up the “qemu-img” software. To do this in an Ubuntu or Debian operating system you can use the command apt install qemu-utils.
  6. Use the command dmesg or look at the log file /var/log/syslog, to define the name of the disk from which the image file will be made.
  7. Define the type of file to be output. The command qemu-img -h | grep "Supported formats" lists the formats supported by the installed version of qemu-img. какие форматы поддерживает установленная версия ПО “qemu-img”.
  8. Example - Supported formats: blkdebug blklogwrites blkreplay blkverify bochs cloop copy-on-read dmg file ftp ftps gluster host_cdrom host_device http https iscsi iser luks nbd nfs null-aio null-co nvme parallels qcow qcow2 qed quorum raw rbd replication sheepdog ssh throttle vdi vhdx vmdk vpc vvfat

Preparing the source disk

  1. The disk must have the status ‘Available’.
  2. If the disk is not bootable, it should be disconnected beforehand from the instance on which it is used.
  3. If the disk is bootable, it will be necessary to temporarily delete the instance that is executed from it.
  4. Once the disk has been brought to the ‘Available’ status, connect it to the temporary instance.

Converting the source disk to a file image of the required format

  1. Here the block device (disk) is converted to an image file. In the example given, the disk ‘/dev/vdb’ is converted to a file in the vmdk format. The file name is ‘dst-disk.vmdk’ and the destination directory in which it is created is ‘/tmp’.
  2. This is done with the command qemu-img convert -p /dev/vdb -O vmdk /mnt/dst-disk.vmdk

Completion phase

  1. The source disk can be disconnected and used as required for further work in the instance.
  2. The image file created can be downloaded from the temporary instance to an external resource, e.g. using the ftp, ssh(scp) or smb(cifs) protocols.
  3. The image file created can be retrieved from the temporary instance by setting up a ftp server on it or using the ssh(scp) protocol.