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.
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
- Creating a temporary instance on the basis of a Linux family OS image
- Preparing the source disk
- Converting the source disk to a file image of the required format
- Completion phase
- 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.
- The amount of free disk space of the temporary instance, following OS setup, should be sufficient to accommodate the disk image.
- 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¶
- 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.
- We recommend the use of an OS based on Ubuntu or Debian.
- 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.
- 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.
- 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.
- Use the command
dmesgor look at the log file
/var/log/syslog, to define the name of the disk from which the image file will be made.
- 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”.
- 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¶
- The disk must have the status ‘Available’.
- If the disk is not bootable, it should be disconnected beforehand from the instance on which it is used.
- If the disk is bootable, it will be necessary to temporarily delete the instance that is executed from it.
- 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¶
- 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’.
- This is done with the command qemu-img convert -p /dev/vdb -O vmdk /mnt/dst-disk.vmdk
- The source disk can be disconnected and used as required for further work in the instance.
- 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.
- 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.