How to Make Disk Images in Linux with DD Command
How to Make Disk Images in Linux with DD Command
Install LSSCSI Utility
Open the command-line terminal.
Make sure to have the “lsscsi” utility installed on your system. If it is not installed, try to install it using the below “apt” command followed by the keyword “install” and “lsscsi”.
sudo apt install lsscsi
After installing the “lsscsi” utility, now it’s time to use it for listing all the storage devices of our Linux system.
$ lsscsi
Check Disk Information
$ sudo fdisk /dev/sda
Create a Clone Disk Image
Now you have almost every piece of information regarding the “/dev/sda” drive. Press “q” to exit the commanding theme. Now, you are ready to make a disk image using the DD command.
$ sudo dd if=/dev/sda1 of=/tmp/sda.img bs=1k conv=noerror
Let’s check the destination image file to see if all the data from the source drive has been cloned into it properly or not. Use the below list command along with the path of an image file of the drive as:
The output shows the rights assigned to this image file, its size, and location. You can say that it has similar rights and size as the original disk drive have.
To see some more information regarding the disk image file, you have to try the below “fdisk” command followed by the flag “-l” as below.
Restore the Drive from Clone Image
Now, if you want to restore your original disk drive along with all the data it has, you have to use the DD command again to do so.
$ sudo dd if=/tmp/sda1.img of=/dev/sda1 bs=1k conv=noerror
Clonezilla
Clonezilla
Clonezilla is a set of utilities that we can use to create, restore, and deploy images.
We can use Clonezilla in two ways: the Live Clonezilla distribution and the command-line tool. The process of creating and restoring the image is the same for both approaches. Therefore, we’ll go with the former.
Our Linux system is installed on the /dev/sda disk — specifically, on the /dev/sda1 partition. Our data partition is /dev/sda2, and that’s where we’ll write the image of /dev/sda1.
Creating a Bootable Clonezilla Live USB Stick
$ unzip -d clonezilla-live-12.1-amd64.zip /mnt/pendrive
Booting System Into Clonezilla Live
Creating the System Image
back up CentOS using the "dd" command
back up CentOS using the "dd" command
Backup to a Disk Image
how to create an image to an external drive
Using the Gnome Disks Utility
-
1. Run the Gnome Disks utility from the Ubuntu programs menu - WRITE DISKS
- Select the external drive or disk, and then choose “Create Disk image…”.
- Create a file name for the image, choose the folder to store the image, and then press the “Start Creating…” button to begin the process.
- Wait for the process to finish. It could take a couple of hours to finish.
Using the Terminal
To backup to a compressed image using a terminal, simply run the following command:
sudo sh -c "dd if=/dev/sda status=progress | xz -c > /media/cupc/image.img.xz"
Replace /media/cupc/image.img.xz
with the location where you wish to store your disk image.
It may take a couple of hours to complete.
Restore from a Disk Image
Using the Gnome Disks Utility
-
1.Run the Gnome Disks utility from the Ubuntu programs menu.
- Select the 120GB Disk, and then choose “Restore Disk image…”.
- Browse to the location of the image file.
- Press the “Start Restoring…” button.
- Confirm by pressing the “Restore” button.
Using the Terminal
To restore from a compressed image in a terminal, simply run the following command:
sudo sh -c "xz -d -c /media/cupc/image.img.xz | dd of=/dev/sda status=progress"
Replace /media/cupc/image.img.xz
with the location of your compressed disk image.
It may take a couple of hours to complete.
back up CentOS using the "dd" command
back up CentOS using the "dd" command
if=/dev/sda
Is cloning the entire disk and of=/dev/sdd1
Is writing to a partition. Which doesn't make much sense.
You may want to clone the entire disk onto another disk
dd if=/dev/sda conv=sync,noerror status=progress bs=64k of=/dev/sdd
Or yet clone to a compressed image
dd if=/dev/sda | gzip > /sda.img.gz
And restore like so
gzip -d /sda.img.gz | dd of=/dev/sda
to create the image. There where four partitions in my sda
* EFI system
* Microsoft reserved
* mircosoft basic dat
* Windows recovery environment