Yes, a 100% exact copy of your HDD is possible, and it would preserve all your files, data and system configurations intact. And, as you've already correctly guessed, simply copying files over won't work. (it can be done, but not worth the trouble of doing it right)
A HD cloner tool is your best bet. There are dozens available.
- Is the new hard drive larger than the old one?
- Do you have any Ubuntu bootable CD / USB key?
If so, I recommend the good old dd
. Its a one-liner, rudimentary, ancient solution for cloning a HDD. But it works, and its amazingly easy. dd
is also pre-installed in Ubuntu.
- Boot using your Live CD or USB stick
- Using
System > Administration > gparted
(Disk Utility also works), take note which is your old and which is your new hard drive (sda, sdb, etc).
- Checked? Great!
- Now check them again:
- Ready?
- Now Triple check it. I mean it!
dd
will have no mercy if you use the wrong letters. dd is commonly known as "d isk d estroyer" for a reason!
From now on, Ill assume the old is /dev/sdX
and the new is /dev/sdY
. Check your actual values! (did I say that already?)
Using Terminal, issue the granddaddy of all HDD cloners:
sudo dd if=/dev/sdX of=/dev/sdY bs=1M
bs=1M
is optional, only to improve performance. The best value depends on your drives/cache/cpu/ram. Commonly used values are 4K, 64K, 1M, 16M. Try for yourself in a 1GB test (add count=
256K, 16K, 1K, 64 respectively). For my machine, anything from 4K to 32M leads to very similar results.
If you want to monitor the copy, you may try this fancy version:
sudo su - # neccessary to get correct pid
dd if=/dev/sdX of=/dev/sdY bs=1M & pid=$!
while kill -USR1 $pid 2>/dev/null; do sleep 10; done
It will output dd's progress every 10 seconds.
- Now go grab a lunch. Or better, go to sleep. It will take long ;)
Post-copy procedures:
- Remove the old drive
- Install the new one in the same connector as the old (so you dont need to reconfigure BIOS)
- Boot and check that everything is fine
- Since
dd
makes an exact copy, partitions will be the same size. If new hdd is much larger than the old one, use gparted to expand partitions to claim the unused space.
cp
parameters to keep all attributes (ownership, permissions, times, ACLs, etc.), but then you have to make the disk bootable afterwards.cp
is not only finding the necessary parameters, but also requiring to create the partition(s), issuecp
for each, and setup grub afterwards.dd
(or your suggestion onddrescue
) does this all in 1 linedd
is (probably) useless if the new disk is smaller than the old one though, and if the new disk is bigger you'll probably have/want to resize partitions afterwards... Both approaches have pros & cons, and I think Brian will have to decide what is likely to work best for him.