Linux Server Diary

The trials and tribulations of a Linux newbie trying to setup a home server.

Saturday, February 23, 2008

Replacing the Hard Drive

As I mentioned in the last post, I've been having troubles with the hard drive on my server. After receiving a shipment from NewEgg, I'm ready to install a new drive. I found this page from Encodable Industries the other day that outlines a way to transfer the files and boot from the new drive.
I find it disturbing that I'm sometimes ables to access the drive without difficulty. Since the new drives arrived, I haven't seen an error on the old one. I hope that the drive is problem, and not something else that will continue to bother me once the replacement is complete. We'll see.
Anyway, I connected the new drive the same way I've used a CD ROM drive in the past, making the cable connections with the drive resting on top of the opened case. Not the most elegant solution, but it works.


Next, I booted to the old drive, and ran partman to partition the drive. I wish I would have documented what commands I ran, but I can say that I ended up with a large ext3 partition and a small swap partition. Just what I needed.
Interesting note: After a power reset following the partition, the machine wouldn't boot. The reason was that the BIOS was trying the boot from the first drive found, and the new drive is slave on the first IDE interface, while the old drive is primary on the second. A quick BIOS reconfiguration took care of it.
Next, it was time to mount the new drive. As root, I created a mount point
sudo mkdir /mnt/newdrive
And added a line to fstab to make the connection:
/dev/hdb1 /mnt/newdrive ext3 defaults 0 0
Finally, I remounted all connections
sudo mount -a
With both drives connected, operational, and mounted, it's time to copy the contents from old to new. The Encodable page linked above gave me this rsync command that will do the deed:
rsync -av --delete --exclude /mnt/newdisk / /mnt/newdisk
(Several hours later)

All of the files copied to the new drive without incident. Still, I'm worried that the old drive isn't really bad, and that something else is causing the problem. Finally, after a couple more hours of accessing the drive, I finally got a failure. Time to move on.

Next, I removed the ailing drive and replaced it with the new one. To boot to a CD, I connected an old CD ROM drive where the new drive had been hanging. After a little experimentation, I found the steps I needed to get things going.
Boot to a Ubuntu 7.04 Live CD
Open a Terminal Window
Fix GRUB using the method outlined in an earlier post
Mount the new drive
sudo mkdir /mnt/hd0
cd /mnt/hd0
sudo mount -t ext3 -o defaults /dev/hdc1 /media/hd0
(use your own partition name)
Get the UUID for the main partition
CD to /dev/disk/by-uuid and find the entry
Modify menu.lst and fstab to use the correct UUID
Do the same to update the UUID for the swap partition in fstab
Reboot and enjoy the new drive

I've been using it for the past several hours without incident. I'll let things burn in for a few days before calling it done.

Next time, we install the other new drive in the backup server. Stay tuned!

Labels:

0 Comments:

Post a Comment

<< Home