View previous topic :: View next topic |
Author |
Message |
DiddyWolf n00b
Joined: 13 Oct 2003 Posts: 4
|
Posted: Wed Feb 04, 2004 7:59 pm Post subject: dd and switching hard drives |
|
|
I've read like 5-6 different articles about moving a gentoo install from one hard drive to another and all of them have said different things about dd.
My hard drive in my gentoo box started making clicking and whurring noises and i'm getting ready to move everything from that 7GB hard drive to a (hopefully) new 7-20GB hard drive (if/when i can find one. While i'm at it, any subjestions on where i can get one for cheep?).
My question is will dd copy the MBR or not and is this a good way to move from one hard drive to another? Also, are any other steps needed to get everything up and running on the new drive?
--DiddyWolf |
|
Back to top |
|
|
TheCoop Veteran
Joined: 15 Jun 2002 Posts: 1814 Location: Where you least expect it
|
Posted: Wed Feb 04, 2004 8:08 pm Post subject: |
|
|
afaik 'dd if=/dev/hda dd=/dev/hdb' will copy the entire disk surface ie partition table, data and all. This is technically possible, and will work fine if you're lucky (YMMV), but its not recommended. The easiest way is probably to create the partitions on the new disk and then copy the data itself over (using methods in the forums, ie cp -axr or find . |cpio something) _________________ 95% of all computer errors occur between chair and keyboard (TM)
"One World, One web, One program" - Microsoft Promo ad.
"Ein Volk, Ein Reich, Ein Führer" - Adolf Hitler
Change the world - move a rock
Last edited by TheCoop on Wed Feb 04, 2004 8:28 pm; edited 1 time in total |
|
Back to top |
|
|
Jake Veteran
Joined: 31 Jul 2003 Posts: 1132
|
Posted: Wed Feb 04, 2004 8:17 pm Post subject: |
|
|
I would (and have in the past, actually) simply use the "cp -a" command and install the bootloader the traditional way (setup in the grub console or lilo after editing the config). |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54317 Location: 56N 3W
|
Posted: Wed Feb 04, 2004 8:19 pm Post subject: |
|
|
DiddyWolf,
Don't use dd to make a drive image unless you are going to restore it to an identical drive.
It will copy the MBR, partition tables and partitions quite literally, which may break on a drive with different geometry since a partition must start on head 0.
Any space on a bigger drive will also become unuseable, since the partition table will show the drive as fully used.
If you must use dd, make images of each partition to reinstall later. (tar would be better, provided you preserve permissions and timestamps)
Partition your new drive restore the partitions and reinstall the bootloader from scrach. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
Baldzius Apprentice
Joined: 17 Mar 2003 Posts: 154 Location: Lithuania
|
Posted: Thu Feb 05, 2004 2:28 pm Post subject: |
|
|
Never tried , but i would do that way:
1. Copy original MBR to another HDD
dd if=/dev/hda of=/dev/hdb bs=512 count=1
2. Make partitions, file systems
3. Not sure but as Jake said, i would give a try with cp command.
Can't try but really interested is this works? |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54317 Location: 56N 3W
|
Posted: Thu Feb 05, 2004 6:36 pm Post subject: |
|
|
Baldzius,
If cp can preserve permissions it will do in place of tar.
Why preserve the MBR? _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
Baldzius Apprentice
Joined: 17 Mar 2003 Posts: 154 Location: Lithuania
|
Posted: Fri Feb 06, 2004 6:40 am Post subject: |
|
|
NeddySeagoon wrote: | Baldzius,
If cp can preserve permissions it will do in place of tar.
Why preserve the MBR? |
It is up to you, preserve MBR or not. I would. |
|
Back to top |
|
|
flowctrl n00b
Joined: 18 May 2003 Posts: 53 Location: Banff, Canada
|
Posted: Fri Feb 06, 2004 5:01 pm Post subject: 'cp' is a bad idea |
|
|
Large recursive copies can totally thrash a filesystem. I'm not sure why, but I've seen inodes get completely scrambled when doing large recursive cp. The best way to do it is to use dump/restore, or if the filesystem that you're using doesn't have dump/restore (like reiserfs), then use tar.
Examples:
Code: |
mount /dev/newdisk1 /mnt
mount /dev/newdisk2 /mnt/home
cd /mnt
dump -0f - / | restore -xf -
cd /mnt/home
dump -0f - /home | restore -xf -
|
That will make a perfect copy, and unlike dd, your partition sizes need not be the same, only large enough to hold the data from the source partitions. If you're using reiserfs and so don't have dump, which is standard on pretty much every *nix filesystem, then use tar instead:
Code: |
mount /dev/newdisk1 /mnt
mount /dev/newdisk2 /mnt/home
cd /
tar cpf - ./ | tar xf - -C /mnt
cd /home
tar cpf - ./ | tar xf - -C /mnt/home
|
Tar doesn't handle as many file oddities as dump does. There is a great discussion of the various *NIX backup tools in the FreeBSD handbook, that applies equally to all UNIX variants (bsd, linux, solaris, etc):
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/backup-basics.html
Cheers.
. |
|
Back to top |
|
|
|