Copy hard disks or partitions using dd

Warning: The following is for personal note only, and is not meant to be a tutorial or guide.

On Debian server at work, we have /home reside on /dev/hda6 and I want to move to a new hard disk /dev/hdb.

First, I need to format /dev/hdb using fdisk. Then use dd to copy the content from /dev/hda6 to /dev/hdb1, the newly createdd ext3 partition.

# dd if=/dev/hda6 of=/dev/hdb1 bs=1024

The above commands instruct dd to read the content from /dev/hda6 and write it to /dev/hdb1. bs=1024 sets the block size to 1024 bytes.

dd takes a while depends on how big is your hard disk. Then, there is one final step to do — to re-size /dev/hdb1 to its maximum capacity.

# e2fsck -f /dev/hdb1

Now we can resize the file system in /dev/dhb1 partition. If we don’t specify the size, then resize2fs will assume the largest:

# resize2fs /dev/hdb1

# fsck -n /dev/hb1

2 thoughts on “Copy hard disks or partitions using dd

    1. Kenno

      I don’t know, I just wanna practice using dd after seeing you cloning the hdd of my laptop to another bigger drive. Sure, I’ll try cp or rsync next time. Thanks for the comment.


Leave a Reply

Your email address will not be published. Required fields are marked *