If you want to full backup of your hard drive you can do hard drives cloning. Hard drives cloning is used for server maintenance. It is also useful for upgrading to bigger storage device.You can do cloning without any additional software.You can just clone your hard drive with dd program. dd command is used to do low-level copying. Using cloning full hard drive you can replace your hard drive with new hard drive without re-installing operating system. In this tutorial I am going to explain how we can clone our entire hard drive with dd command.
Note: dd command may destroy your hard drive entire data if you are not sure what are you doing. Please keep a backup copy of your impotent data.
Follow the below steps to before cloning hard drive.
1. Boot your system with Ubuntu Live CD. 2. Switch to root user 3. And make sure no partitions are mounted from the source hard drive.
I have took a small hard drive to copy it all data to new hard drive which has not been formatted yet. Before cloning your hard drive make sure you are working on right drives.
Follow the below commands to clone your entire hard drive.
# fdisk -l Disk /dev/sda: 1873 MB, 1873791829 bytes 255 heads, 63 sectors/track, 138 cylinders Units = cylinders of 16065 * 512 = 8225288 bytes Disk identifier: Bx13084dffh Device Boot Start End Blocks Id System /dev/sdal * 1 65 522881 83 Linux /dev/sda2 66 138 522112+ b W95 FAT32 Disk /dev/sdb: 136.9 GB, 136365211698 bytes 255 heads, 63 sectors/track, 16578 cylinders Units = cylinders of 16065 * 512 = 8225288 bytes Disk identifier: Bxc871c871 Device Boot Start End Blocks Id System /dev/sdbl * 1 16577 133159721 7 HPFS/NTFS Disk /dev/sdc: 1873 MB, 1873741829 bytes 255 heads, 63 sectors/track, 130 cylinders Units = cylinders of 16065 * 512 = 8225288 bytes Disk identifier: 0x00000000 Disk /dev/sdc doesn't contain a valid partition table
As you can see above there are two drives first /dev/sda which has two partitions and second /dev/sdc which in not formatted yet. We are going to copy entire data from /dev/sda to /dev/sdc.
Note: Only you can copy a smaller hard drive to a larger hard drive but you can not copy a larger hard drive to a smaller hard drive using below command.
dd command usage
Follow the below command for cloning the hard drive.
# sudo dd if=/dev/sda of=/dev/sdc 2097152+0 records in 2097152+0 records out 1073741024 bytes (1.1 00) copied, 54.13483 s, 19.9 MB/s
You will get some output like above after executed the command successful.
Above we are using “if” as a input file is /dev/sda, and the output “of” as a output file is /dev/sdc with dd command. It will take some time if your drives are large. But in my case my drive is smaller and it took just less than a minute.
If we run fdisk -l command again, we can see that /dev/sdc has the same partitions as /dev/sda without formatting hard drive.
# fdisk -l Disk /dev/sda: 1873 MB, 1873791829 bytes 255 heads, 63 sectors/track, 138 cylinders Units = cylinders of 16065 * 512 = 8225288 bytes Disk identifier: Bx13084dffh Device Boot Start End Blocks Id System /dev/sdal * 1 65 522881 83 Linux /dev/sda2 66 138 522112+ b W95 FAT32 Disk /dev/sdb: 136.9 GB, 136365211698 bytes 255 heads, 63 sectors/track, 16578 cylinders Units = cylinders of 16065 * 512 = 8225288 bytes Disk identifier: Bxc871c871 Device Boot Start End Blocks Id System /dev/sdbl * 1 16577 133159721 7 HPFS/NTFS Disk /dev/sdc: 1873 MB, 1873791829 bytes 255 heads, 63 sectors/track, 138 cylinders Units = cylinders of 16065 * 512 = 8225288 bytes Disk identifier: Bx13084dffh Device Boot Start End Blocks Id System /dev/sdcl * 1 65 522881 83 Linux /dev/sdc2 66 138 522112+ b W95 FAT32
We can see that all of the data on /dev/sdc is same as on /dev/sda if we mount all of the partitions.
# diff -rq sda1 sdc1 # diff -rq sda2 sdc2
You can restart your computer to see the newly cloned drive.
I hope this article will be helpful to make clone your HDD (Hard Drive) using dd command in Linux. Read our another article Check and Update max_connections value to fix MySQL Error: Too many connections and Top 20 Crontab Examples to Schedule Tasks. If you have any queries and problem please comment in comment section or you can also ask your question.
If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at LookLinux Submit Article. Stay connected to Facebook.
Leave a Comment