I have a machine running Ubuntu Server that has been presenting some HD-related problems. Instead of reinstalling and reconfiguring everything (and to save time) we'd like to copy everything from the current hard drive to a new one and start using it. We only have a single hard drive with a main partition and a swap partition.

What tools or methods would you recommend for replacing a hard drive with minimum difficulty and chance of problems?

4 Answers
4

Dump the entire harddrive image to other host (you can use dd and netcat for that) or tape

Change the harddrive

Restore the image on that new harddrive.

But the real solution would be: Never use single harddrive in any server. On every new installation use raid+LVM to be prepared for inevitable HD replation. For this particular system - reinstall it using at least two harddrives and RAID on them.

Make a backup of the filesystem (tar czf mybackup.tgz /) to an external disk

Replace the hard drive

Boot linux from livecd

Format new drive with a root partition and a swap partition

Unpack the backup onto the new root partition

reinstall the boot manager (i assume grub)

The tricky part is the last one: reinstalling the boot manager. This can sometimes give problems. If you use the livecd from the Ubuntu version that is installed currently on the disk, it shouldn't give any problems though.

This is going to sound obvious sorry but you'll need to back it up, then either install the base OS and restore or boot from a live CD and restore. It depends on how much data you need to backup and what backup hardware you have (i.e. external drives/tapes etc.)

In terms of what software to use, well sbackup is fine ("sudo apt-get install sbackup").