Linux Copy One Hard Disk to Another Using dd Command

by Vivek Gite · 12 comments

Q. How can I copy one hard disk to another using dd command?

A. dd command can copy disk in raw format. It will copy partition table and bootloader and all partitions within this disk. For example, you can copy /dev/sda to /dev/sdb (same size) using the following dd command. dd should complete with no errors, but output the number of records read and written.

Login as the root user (use sudo or su command)

WARNING! These examples may result into data loss, ensure there are good backups before doing this, as using dd wrong way can be dangerous.

Open terminal or shell prompt and type the following dd command:
# dd if=/dev/sda of=/dev/sdb
Where,

  • if=/dev/sda : Input disk (source)
  • of=/dev/sdb : Output disk (destination)

You can also copy hard disk or partition image to another system using a network and netcat (nc) command.

Featured Articles:

Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our daily email newsletter to make sure you don't miss a single tip/tricks. Subscribe to our weekly newsletter here!

{ 12 comments… read them below or add one }

1 Anil Waghmare 02.05.08 at 4:08 am

Hi,
Please check your steps. Instead of if & of you have written if twice

2 Dorin 09.01.08 at 6:58 am

Is is possible to copy one disc to another, a bigger one?

3 Youpi 02.17.09 at 10:23 pm

please answer Dorin’s question…

4 Andy 02.22.09 at 11:03 am

I want to know the answer of Dorin’s question too. Thanks~~

5 Looo 06.19.09 at 12:41 pm

I would also appreciate an answer please ….

6 Dorin 06.20.09 at 6:20 am

I guess we will have to try to copy one small disk to a bigger one.

7 Jeff 07.03.09 at 3:19 am

you can dd one smaller hdd to one larger hdd, depending on the tools, you can then resize the partition to fit the entire new hdd

8 Kerem ERSOY 07.19.09 at 3:52 am

You can copy a smaller disk to alarger one. But initially the Filesyem over the large disk will be exactly s it is over the smaller disk. Then if you’re using ext2 / ext3 you can directly modify the partition size using resize2fs command. If you’re using LVM then you’ll need to expand LVM first.

9 Don Lassini 07.21.09 at 3:53 pm

You can copy a small disk to a larger disk, and then resize the partition with gparted.
You can also copy one partition from one disk to another, and then resize that partition afterwards.
e.g. dd if=/dev/sdb1 of=/dev/sdc1

Again, you can use gparted to resize the partition afterwards.

10 Ashu 08.22.09 at 8:23 pm

Hi…

I was looking if any one can provide me the instructions on how to resize my linux hard disk (sda)

I am unable to perform wirte command after I making the changes in fdisk /dev/sda command.
Please help me out with this.

Thank you.
Ashu

11 Arjan 09.03.09 at 2:33 pm

You can try to boot your system with a ubuntu live cd, and start the partition editor (gparted) when the system is booted. Or use a linux recovery cd

You should not resize a partition you are working on (=mounted)

12 Hmm 09.21.09 at 1:21 am

GNU ddrescue is better, since it shows progress, won’t make any errors, and you can interrupt it without worry.

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Previous FAQ:

Next FAQ:

nixCraft FAQ PDF Collection Now Available To All