Table Of Contents
Here is how you can clone and back-up important partition on Linux PCs/Tablets
Backing up your data is a way to ensure that your important data will be safe against unplanned situations. This can be achieved by numerous ways. One can either use methods native to the Operating system or use software utilities .
Linux is an OS which is loved by computer professionals worldwide. Linux users like to partition their HDD and format them to different file-systems .
Linux provides two built in ways- use of
cat commands for cloning one partition to another. I’ll discuss each of them and at the end enlist some GUI based software utilities.
Cloning a partition using dd command
The dd command is a simple, yet versatile and powerful tool. It can be used to copy from source to destination, block-by-block, regardless of their filesystem types or operating systems. A convenient method is to use dd from a live environment, as in a Live CD.
( Be careful in choosing values for “if” and “of” attributes. Interchanging values will format your source partition and you will end up with loss of data.)
Cloning a partition
From physical disk /dev/sda, partition 1, to physical disk /dev/sdb, partition 1.
# dd if=/dev/sda1 of=/dev/sdb1 bs=64K conv=noerror,sync
You can also clone entire HDD by using:
# dd if=/dev/sdX of=/dev/sdY bs=64k conv=noerror,sync
This will clone the entire drive, including the MBR (and therefore bootloader), all partitions, UUIDs, and data.
>> “if” stands for input file while “of” stands for output file.
>> “noerror” instructs dd to continue operation by ignoring all the read errors(default is to halt at an error).
>> “sync” fills input blocks with zeroes if there were any read errors, so data offsets stay in sync.
>> bs= sets the block size. Defaults to 512 bytes, which is the “classic” block size for hard drives since the early 1980s, but is not the most convenient. Use a bigger value, 64K or 128K. Also please read this before proceeding with bs:
The dd utility technically has an “input block size” (IBS) and an “output block size” (OBS). When you set bs, you effectively set both IBS and OBS. Normally, if your block size is, say, 1 MiB, dd will read 1024*1024 bytes and write as many bytes. But if a read error occurs, things will go wrong. Many people seem to think that dd will “fill up read errors with zeroes” if you use the noerror,sync options, but this is not what happens. dd will, according to documentation, fill up the OBS to IBS size after completing its read, which means adding zeroes at the end of the block. This means, for a disk, that effectively the whole 1 MiB would become messed up because of a single 512 byte read error in the beginning of the read: 12ERROR89 would become 128900000 instead of 120000089.
If you are positive that your disk does not contain any errors, you could proceed using a larger block size, which will increase the speed of your copying several fold. For example, changing bs from 512 to 64K changed copying speed from 35 MB/s to 120 MB/s on a simple Celeron 2.7 GHz system. But keep in mind that read errors on the source disk will end up as block errors on the destination disk, i.e. a single 512-byte read error will mess up the whole 64 KiB output block.
If everything goes as planned, this will cmone your partition to the target partition.
Lets talk about the “cat” command
Follow these steps to get the job done:
# cat /dev/sda1 /dev/sdb1
(first attribute is source partition and second one is the destination partition.
After this the cloned partition has to be mounted to
/mnt and both mount point directories are listed to check if any files are missing.
# mount /dev/sdb1 /mnt
# ls /mnt
# ls /boot
Now you can compare the original partition with
/mnt to confirm that cloning has been successfully completed.
These are available either as commercial tools or free tools:
In case you face any problem, feel free to ask in the comments, we’ll resolve ASAP.