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

    • 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

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s