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:
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- My 10 UNIX Command Line Mistakes
- 10 Greatest Open Source Software Of 2009
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- Top 20 OpenSSH Server Best Security Practices
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Linux Video Editor Software
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!
- Email FAQ to a friend
- Download PDF version
- Printable version
- Comment RSS feed
- Last Updated: 02/5/08



{ 12 comments… read them below or add one }
Hi,
Please check your steps. Instead of if & of you have written if twice
Is is possible to copy one disc to another, a bigger one?
please answer Dorin’s question…
I want to know the answer of Dorin’s question too. Thanks~~
I would also appreciate an answer please ….
I guess we will have to try to copy one small disk to a bigger one.
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
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.
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.
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
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)
GNU ddrescue is better, since it shows progress, won’t make any errors, and you can interrupt it without worry.