Linux Copy One Hard Disk to Another Using dd Command

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

  • 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.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 22 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
22 comments… add one
  • Anil Waghmare Feb 5, 2008 @ 4:08

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

  • Dorin Sep 1, 2008 @ 6:58

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

    • Shams Aug 17, 2010 @ 4:16

      I want to know the reply of Dorin’s question

      • Subsentient Sep 19, 2012 @ 9:30

        It’s probably best to copy preserving permissions (cp -a) your install to a new filesystem and reinstall the bootloader on the new partition.

    • rel Apr 21, 2015 @ 18:33

      yes , its possible , do the dd if=/dev/sda of=/dev/sdb first and once done using GNU parted , resize option .

      pls note : fdisk wont work if you try to expand after copy , parted will do the job.

  • Youpi Feb 17, 2009 @ 22:23

    please answer Dorin’s question…

  • Andy Feb 22, 2009 @ 11:03

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

  • Looo Jun 19, 2009 @ 12:41

    I would also appreciate an answer please ….

  • Dorin Jun 20, 2009 @ 6:20

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

  • Jeff Jul 3, 2009 @ 3:19

    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

  • Kerem ERSOY Jul 19, 2009 @ 3:52

    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.

  • Don Lassini Jul 21, 2009 @ 15:53

    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.

  • Ashu Aug 22, 2009 @ 20:23


    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.

  • Arjan Sep 3, 2009 @ 14:33

    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)

  • Hmm Sep 21, 2009 @ 1:21

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

  • Ashrock Nov 15, 2010 @ 18:57

    I have a external hard drive of 250GB capacity mounted on /mnt/sda2.
    The device is at /dev/sda2.
    So, if i want to copy the complete hard drive to take a backup using this dd command.
    Do i have to unmount it first and then use dd command.
    There are actually two partitions in the hard drive i want to copy.
    One is of 5.5GB other is of 63GB.
    Can i copy both using dd command, if so, would i be able to preserve the filesytem for later recovery.


  • yashwanth Dec 14, 2010 @ 8:18

    Hey, my question is something different.

    I have a 55GB hard disk … but it has only 30 GB filled with partitions and remaining 25G I have not even extended,
    now my question is if I have one more disk with 49GB hard disk … can I copy the 30GB data into the 49G disk … ?

    pls reply me as soon as possible …. I need it very urgent ..!!

  • onur Oct 12, 2012 @ 9:03


    I am learning the linux environment so that I need yours experince

    I have one server with raid 5 and I want to image from all disk to the external disk??

    How can I do this step??

  • Kaustubh Ghanekar Jul 10, 2013 @ 3:18

    If I clone a 1 Gig disk to a 3 Gig disk, can I add partitions to remaining 2 Gigs on new disk?

  • Darren Jan 8, 2014 @ 14:56

    To all the people asking questions about whether or not a smaller disk will go onto a bigger disk – the answer is yes, and yes you can create additional partitions afterwards.

    DD will just copy block by block what it finds – remember that if you are copying a bad drive you might need the extra parameter conv=noerror so it ignores the errors it finds.

    DD can also be used to create a mirror file containing the hard drive as well – something like dd if=/dev/sda1 of=/mnt/sda2/sda1.img would create an image file of sda1 – and dd if=/mnt/sda2/sda1.img of=/dev/sda1 would write the image file back to the partition (bear in mind that obviously if your creating an image file you wouldn’t create it on the same partition because it’s going to be the same size as the partition!)

  • MOHAMED Aug 30, 2014 @ 8:33



  • Scornfulheal Jan 15, 2015 @ 15:06


    In linux terminal, if you know your source and target drives, what others have mentioned should work.

    ” dd if=/dev/sda1 of=/dev/sdb1 ”
    where ” if= ” is the input file and ” of= ” is the output file (aka the HDDs). In this example, dd would copy from partition one of disk one and write block by block to partition one of disk two. Make sure to check your disk/partition names on your system, this is just an example.

    To make it faster, you may append ” bs=1M ” to increase the block read/write size. ” bs= ” referring to block size parameter. As another mentioned, adding ” conv=noerror ” will continue the operation even after an input/output error.

    In this example, that would leave ” dd if=/dev/sda1 of=/dev/sdb1 conv=noerror bs=1M ”

    Also look into the function “cp” which is different than “dd”


Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum