English Français

Replacing a disk drive

The idea is to totally replace a hard drive with a new one, this means copying all the data from each partition of the old hard drive to a new one.
why? :

What you need :

What needs to be done :

Booting off the Debian CD, partitioning et formatting

Boot off the Debian CD and go through the first options, mostly keyboard options. (stop anywhere before using partitioning tool).
Then get a terminal by pressing alt - F2.
If you have already partitioned the disk than yay for you, otherwise you can do this with fdisk. You must keep in mind that sda1 should be at least as big as sdb1 (or at least have enough space to contain the contents of sdb1), the same goes for sda3. As for the swap partition, in this case sda2, you can do whatever you want of course.
On the Debian install CD "fdisk" is available, this tutorial does not cover this, for that you can make a request. Different boot and/or live CDs may have other partitioning and/or formatting software. So basically, create your partitions.
I use ext3 filesystem, but of course you can do whatever you want, actually you can even use this process if you wanted to just safely change the filesystem (if you do change the filesystem than don't forget to update the fstab that you copy to sda1). Here is an example with basic ext3 fs.

mke2fs -j /dev/sda1
mke2fs -j /dev/sda3

Data copying

It's possible to simply use cp to copy the data with the option "-a" which is the equivalent to "-dpR" which means :

Mount the disks as follows :

cd /mnt
mkdir sda1 sdb1 sda3 sdb3
mount /dev/sda1 /mnt/sda1
mount /dev/sdb1 /mnt/sdb1
mount /dev/sda3 /mnt/sda3
mount /dev/sdb3 /mnt/sdb3

now the super simple part, it can take forever though :

cp -a /mnt/sdb1/* /mnt/sda1/
cp -a /mnt/sdb3/* /mnt/sda3/

Next, initiate the swap partition

mkswap /dev/sda2

And finally, install grub (or lilo) on the MBR

chroot /mnt/sda1
grub-install # or 'lilo'
halt

Swell, the machine should be off and you can unplug the "old" disk drive et maybe even rid the CD-Rom drive of the boot CD.. :] .. voilĂ , you can now boot onto your same old system with a brand new, bigger, faster, awesomer disk drive.. . .. . if .. if everything went well.. :]

And then.. .

Yes, there is a bit more to do, you should recycle your old equipement of course, but before doing that, you might want to destroy the data before disposing (or selling/giving) your hard drives.. you can check the programs shred and wipe

Add A Comment

Add A Comment

This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)
Code in the picture:
Your Name(*):
Email:
Website:
Comment(*):