Linux Tutorials

Find out how to Clone a Partition or Laborious drive in Linux


There are various explanation why chances are you’ll wish to clone a Linux partition and even arduous drive, most of that are associated to creating backups of your information. There are a number of methods you’ll be able to obtain this in Linux through the use of some exterior instruments reminiscent of partimage or Clonezilla.

Nevertheless on this tutorial we’re going to assessment Linux disk cloning with instrument referred to as dd, which is mostly used to transform or copy recordsdata and it comes pre-installed in most Linux distributions.

Find out how to Clone Linux Partition

With dd command you’ll be able to copy total arduous drive or only a Linux partition. Lets begin with cloning considered one of our partitions. In my case I’ve the next drives: /dev/sdb, /dev/sdc.. I’ll clone /dev/sdb1/ to /dev/sdc1.

Learn Additionally: Find out how to Clone Linux Partitions Utilizing ‘cat’ Command

First record the these partitions utilizing the fdisk command as proven.

# fdisk -l /dev/sdb1/ /dev/sdc1

List Linux PartitionsList Linux Partitions

Listing Linux Partitions

Now clone a partition /dev/sdb1/ to /dev/sdc1 utilizing the next dd command.

# dd if=/dev/sdb1 of=/dev/sdc1

The above command tells dd to make use of /dev/sdb1 as enter file and write it to output file /dev/sdc1.

Clone Linux Partition with dd CommandClone Linux Partition with dd Command

Clone Linux Partition with dd Command

After cloning Linux partition, you’ll be able to then verify each partitions with:

# fdisk -l /dev/sdb1 /dev/sdc1

Verify Linux Partition CloningVerify Linux Partition Cloning

Confirm Linux Partition Cloning

Find out how to Clone Linux Laborious Drive

Cloning a Linux arduous drive is just like cloning a partition. Nevertheless, as an alternative of specifying the partition, you simply use all the drive. Observe that on this case it is strongly recommended that the arduous drive is identical in dimension (or larger) than the supply drive.

# dd if=/dev/sdb of=/dev/sdc

Clone Hard Drive in LinuxClone Hard Drive in Linux

Clone Laborious Drive in Linux

This could have copied the drive /dev/sdb with its partitions on the goal arduous drive /dev/sdc. You may confirm the modifications by itemizing each drives with fdisk command.

# fdisk -l /dev/sdb /dev/sdc

Verify Linux Hard Drive CloningVerify Linux Hard Drive Cloning

Confirm Linux Laborious Drive Cloning

Find out how to Backup MBR in Linux

dd command will also be used to backup your MBR, which is positioned on the first sector of the gadget, earlier than the primary partition. So if you wish to create backup of your MBR, merely run:

# dd if=/dev/sda of=/backup/mbr.img bs=512 depend=1.

The above command tells dd to repeat /dev/sda to /backup/mbr.img with step of 512 bytes and the depend choice tells to repeat solely 1 block. In different phrases you inform dd to repeat the primary 512 bytes from /dev/sda to the file you could have offered.

Backup MBR in LinuxBackup MBR in Linux

Backup MBR in Linux

That’s all! dd command is a strong Linux instrument that ought to be used with warning when copying or cloning Linux partitions or drives.

Source link

Related Articles

Back to top button