Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
dd and switching hard drives
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
DiddyWolf
n00b
n00b


Joined: 13 Oct 2003
Posts: 4

PostPosted: Wed Feb 04, 2004 7:59 pm    Post subject: dd and switching hard drives Reply with quote

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
View user's profile Send private message
TheCoop
Veteran
Veteran


Joined: 15 Jun 2002
Posts: 1814
Location: Where you least expect it

PostPosted: Wed Feb 04, 2004 8:08 pm    Post subject: Reply with quote

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
View user's profile Send private message
Jake
Veteran
Veteran


Joined: 31 Jul 2003
Posts: 1132

PostPosted: Wed Feb 04, 2004 8:17 pm    Post subject: Reply with quote

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
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54317
Location: 56N 3W

PostPosted: Wed Feb 04, 2004 8:19 pm    Post subject: Reply with quote

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
View user's profile Send private message
Baldzius
Apprentice
Apprentice


Joined: 17 Mar 2003
Posts: 154
Location: Lithuania

PostPosted: Thu Feb 05, 2004 2:28 pm    Post subject: Reply with quote

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
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54317
Location: 56N 3W

PostPosted: Thu Feb 05, 2004 6:36 pm    Post subject: Reply with quote

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
View user's profile Send private message
Baldzius
Apprentice
Apprentice


Joined: 17 Mar 2003
Posts: 154
Location: Lithuania

PostPosted: Fri Feb 06, 2004 6:40 am    Post subject: Reply with quote

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
View user's profile Send private message
flowctrl
n00b
n00b


Joined: 18 May 2003
Posts: 53
Location: Banff, Canada

PostPosted: Fri Feb 06, 2004 5:01 pm    Post subject: 'cp' is a bad idea Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum