dd command usage to clone hdd

Asked by Anton Kanishchev

I have 2 harddrives - one internal and one external , both are 500gb. The external harddrive is empty(unformatted) and the internal hdd has 12.04 as well as win7 partitions on it.

output of lsbk shows that my internal hdd is sda and the external hdd is sdb, hence running the command below would copy the internal hdd to my external hdd

 if=/dev/sda of=/dev/sdb

Since dd does a 100% copy it should also copy my filesystem , grub etc, so I dont need to format the external hdd for dd to work, correct?

Do i need to boot to a live cd environment to clone entire hdd ?

Both ubuntu and win7 partitions are encrypted (via LUKS from alternative installer and truecrypt on windows ), can I just confirm that dd will indeed copy the encrypted data , i.e. upon restore i still need to provide a passphrase etc etc?

Thanks

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
actionparsnip
Solved:
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#1

You will need to use sudo but it will work fine. Grub should be copied but you can boot liveCD and add Grub manually. Another method is to mount the source and destination then use grsync (carefully) in liveCD to copy the data over. You wil need to manually install Grub

Revision history for this message
Anton Kanishchev (ak12-deactivatedaccount) said :
#2

Thanks for the reply actionparsnip,

My rationale behind using dd is that if my internal hdd were to fail all i would need to do is insert my backup hdd into the system and I am back online so to speak, I would like to minimise the steps required in recovering from hardware failure.

I would ideally like to back up grub as well. Would booting from live cd to run dd copy grub as well?

Thanks,

Anton

Revision history for this message
Best actionparsnip (andrew-woodhead666) said :
#3

Then I would use dd. The install of Grub isn't hard

Revision history for this message
Anton Kanishchev (ak12-deactivatedaccount) said :
#4

Thanks actionparsnip, that solved my question.