Intro arrow Fenix arrow Labs arrow Migrating a Gentoo build from drive to drive

Migrating a Gentoo build from drive to drive

Sunday, 13 July 2008

Ours is an age of information, my community is one of data.

 

I dropped $90 for a 500GB Hard Drive, a fine price if you ask me.

I am running an amazing* little IBM ThinkCentre, pentium 4 w/hyperthreading. A gigabyte of mismatched DDR, An old Geforce 6200 that a friend had no use for. And up till now, two 40GB PATA Hard Drives. 

(* Amazing that the government would throw this out)

 So now came the challenge of throwing these things together. My colleague Adam, recently tried to image a Copy of SuSe 10 from one drive to another using dd (the data destroyer), and unlike when the same process is applied to a windows machine, was not properly booting.  Now, I have no idea why SuSe Linux install doesn't like being mirrored using dd, but I have heard that Gentoo can be mirrored using rsync.

I struggled to make room for the new drive and eventually succeed. I had to remove the floppy drive and toss the new drive on top of my older storage drive.  It still sits there now, and I think I should fix it and take out the old primary drive.

 Anyway, here's how I did it:

I installed the new drive, booted up the newest gentoo liveCD.

I used fdisk to partition the new drive.

I then mounted my old drive and all of its partitions kind of like:

 mount /dev/hda2 /mnt/gentoo/

 mount /dev/hda4 /mnt/gentoo/home/

mount /dev/hda1 /mnt/gentoo/boot/

 And then I mounted the new drive in a similar way:

mount /dev/sda2 /mnt/gent2

 mount /dev/sda4 /mnt/gent2/home/

 mount /dev/sda1 /mnt/gent2/boot/

 At first, I used a plain old cp command, but it ended up with bad permissions and possibly bad file permisions, Everything was owned by root.

 So I looked through the rsync man page, figuring out just what command line options to use. I used command line option I figured would be appropriate.  I didn't write down what command I did, but after discussing with captian Adama, I believe the following command will suffice.

rsync -ah /mnt/gentoo/* /mnt/gen2/

Please don't copy and paste these things, in other words, please confirm this before you blindly trust me or anyone.

from there I chrooted into the new mirror

mount -t proc none /mnt/gen2/proc
mount -o bind /dev /mnt/gen2/dev
chroot /mnt/gen2 /bin/bash
env-update
>> Regenerating /etc/ld.so.cache...
source /etc/profile
 and ran what was in my case,
grub-install (hd2,0)
 I also had to modify my /etc/fstab and /boot/grub/grub.conf
to boot to the appropriate hard drive.
Had to change my BIOS to boot to the SATA drive first as well.
But now it works great (It can move ~40MB/s (~10MB faster than the old drive))