Hard drive migration

This entry was posted by Tuesday, 7 April, 2009
Read the rest of this entry »

This is handy if you just got yourself that new xxxTB hard drive.

Firstly, BACKUP!
This is one of the most important things to do, you never know when you may screw something up royally.

Make sure your new hdd and old one are both in the machine.

This is only a basic overview for the purposes of a tutorial. It assumes you dont have multiple partitions for /var or /usr or /boot or any other and that all your data is only one the one partition (basicly the home user not a server).
Be aware that if you have an entirely new system and have gone from IDE to SCSI then you may want/need to recompile your kernel before you do this to support the new drive.

These are the commands you probably want to do. /dev/hdxxx is the destination hard drive.

fdisk /dev/hdxx
– This is to partition the disk

mkfs -t ext3 /dev/hdxx – This is to format it

mkdir /target

mount /dev/hdxx /target – Mounting the new drive.

rsync -a --exclude="/dev" --exclude="/proc" --exclude="/sys" --exclude="/target" / /target/
– this copies your data accross

mkdir /target/{proc,dev,sys}

(Note: you can probably cp -a /dev across)

cp /dev/MAKEDEV /target/dev/ – this file is needed for making device nodes

cd /target/dev

Now you need to make the device links. This is done with a script called MAKEDEV that you just copyed accross.
./MAKEDEV will give you the options you need/want.

./MAKEDEV generic-i386 should do the basic nodes

Now you have to edit a couple of things.
vi /target/etc/fstab
This only really needs to be done if the hard drives are going to change places on the ide chain.
Please do note that Redhat/Fedora uses labels instead of partitions, label your partitions if you wish to continue with this method, alternativly change the label for the actual device name.

vi /etc/lilo also if needed for the same reasons.

Now for the tricky bit, you can copy the masterboot record with something that looks like this
dd bs=512 count=1 if=/dev/hddxx(oldone) of=/dev/hdxx(newone)

However, apon saying this i have found it to break my partitioning before on some hard drives.
So Im more inclined to just reboot and using another linux install disk or floppy to boot.

I find slackware disk excellent as a rescue disk, when it comes up to the lilo screen i just type
Lilo: linux root=/dev/hdxx(new hard drive)

Debian cd can be booted with,
Lilo: rescue root=/dev/hdxx(new hard drive)

etc. Most distros will do it, just read the help.

Reboot with rescue cd and run lilo or dd the MBR (which i find to screw up sometimes)

Then login as root and rerun your lilo or grub onto the new hard drives MBR.
Last-Modified: 2007-03-07 19:38:50

Be Sociable, Share!

Leave a Reply



Time limit is exhausted. Please reload CAPTCHA.