Creating and Deploying a Disk Image with the dd Utility
This step-by-step guide will come in handy if server image support is temporarily unavailable in your location.
To complete the procedure, you will need the following:
- The source server you will create the image from.
- A new server with a disk of the same size. The operating system and installed software on this server may differ.
- SSH access to both servers.
The procedure is as follows:
- Boot the new server from the rescue disk (go to the server page, open the "Access" section, and change the boot mode).
- Run the following commands so that you can connect to the server via SSH:
systemctl stop iptables
passwd root
- Go to the control panel of the source server and create a backup of its disk (go to the server page and select the "Backups" section).
- Then mount this backup in the control panel.
- Connect to the source server via SSH and run the following command to find the name of the new device:
dmesg
From here on, this guide uses the device name /dev/vdb.
- Make sure the disk sizes on both servers match by running the following command on each of them:
fdisk -l
- If the sizes match, run the following command on the source server:
ssh root@NEW_SERVER_IP "cat > /dev/vda" < /dev/vdb
You can also use the following command to display a progress bar, but keep in mind that it will slow down copying:
dd if=/dev/vdb | pv -s [image size] | ssh root@NEW_SERVER_IP "cat > /dev/vda"
- When the process is complete, make sure the copy was made without errors: run the following command on each server, specifying the corresponding disk name:
- On the source server, specify the disk the backup was created from:
sha256sum /dev/vdb
- On the new server, specify the disk the copy was written to:
sha256sum /dev/vda
- Compare the resulting hashes. If they match, the copy was completed successfully.
You can now unmount and delete the backup on the source server and boot the new server in normal mode.