Steps to Backup Linux Disk Using dd: A Comprehensive Guide to Ubuntu 18.04
In this article, we will discuss the steps to create a full disk image backup of an Ubuntu 18.04 system using the dd command. This method is useful for creating a sector-by-sector copy of a disk, including the file system, partition table, and boot sector. This is important for system administrators who want to ensure data integrity and consistency during disaster recovery scenarios.
What is dd?
dd (short for "data duplication") is a command-line utility that is used for converting and copying files. It can be used for a variety of purposes, including creating disk images, converting file formats, and wiping disks securely. The dd command has many options and parameters, making it a powerful and versatile tool for system administrators.
Prerequisites
Before we begin, make sure you have the following:
- An Ubuntu 18.04 system with at least two disks (or partitions) - one for the source data and one for the backup image.
- Access to the command line as a superuser (
sudo).
Step 1: Identify the Source Disk and Destination Device
The first step is to identify the source disk and the destination device. Use the lsblk command to list the available block devices:
sudo lsblk
This will display a list of disks and partitions, along with their size, mount point, and other information. Identify the source disk and the destination device. For example:
- /dev/sda - This is the source disk (500GB SSD).
- /dev/sdb - This is the destination device (1TB HDD).
Step 2: Create a Backup Image of the Source Disk
To create a backup image of the source disk, use the following command:
sudo dd if=/dev/sda of=/dev/sdb bs=4M status=progress oflag=sync
Here, the if parameter specifies the source disk (/dev/sda), the of parameter specifies the destination device (/dev/sdb), the bs parameter specifies the block size (4 MB), the status parameter shows the progress of the command, and the oflag parameter synchronizes the output.
Step 3: Verify the Backup Image
After the backup image has been created, it's important to verify its integrity. To do this, use the md5sum command:
md5sum /dev/sda | grep -v "^md5sum"
This will display the MD5 hash of the source disk. Compare it to the MD5 hash of the backup image:
md5sum /dev/sdb | grep -v "^md5sum"
If the hashes match, this confirms that the backup image was created successfully.
Step 4: Securely Wipe the Source Disk
Once the backup image has been created and verified, it's important to securely wipe the source disk. Use the following command:
sudo dd if=/dev/zero of=/dev/sda bs=4M status=progress oflag=sync
This will overwrite the source disk with zeros, making it impossible to recover any data from it.
In this article, we discussed the steps to backup a Linux disk using the dd command on Ubuntu 18.04. This method can be used for creating sector-by-sector copies of disks, including the file system, partition table, and boot sector. This is important for system administrators who want to ensure data integrity and consistency during disaster recovery scenarios. Remember to always verify the backup image and securely wipe the source disk after the backup has been created.