The good thing about having kept a blog these last few years, is I have a searchable record of hardware changes.
Recently, I noticed a few disk errors on caesar, and I was wondering how old that disk was. I disk some searching, and found via this post that the disk in it was a hand-me-down from when I decommissioned daedalus Mk I. One of the reasons I decommissioned it when I did, was the RAID-1 was exhibiting some strange errors during resynchronisation, and I didn't want to leave the country leaving behind an ageing problematic server with my stuff on it.
I'd previously been unable to fault either 120 Gb disk under some light testing with badblocks, so I just reused them, and so around October 2005, I put the larger disk in caesar. So this disk has seen a fair bit of use, originally in daedalus, and then in caesar for another 20 months. It's allowed to fail, it's served me well.
Anyway, so I bought a 750 Gb drive a couple of weeks ago, because one thing that I've wanted to do with caesar was do remote backups of daedalus, and there just wasn't enough space to do that, so I went for as big as I could find, and essentially repeated the same trick as last time, to upsize:
- Power down, attach new disk as a slave
- Boot into single user mode
- Unmount everything, remount root read-only
- sfdisk -d /dev/hda | sfdisk /dev/hdb to copy the partition table (I use a root, swap, LVM, three partition layout)
- dd if=/dev/hda1 of=/dev/hdb1 bs=1M to copy the root filesystem to the new disk
- mkswap /dev/hdb2 to put the swap signature on what will become the new swap device
- cfdisk /dev/hdb and blow away the third partition and recreate it using all of the available space (there's probably a programmatic way of doing this, but hey, it's not exactly hard to do in cfdisk either)
- pvcreate /dev/hdb3 to put an LVM signature on the new LVM physical volume
- vgextend base /dev/hdb3 to tell LVM there's two disks in the volume group for the time being
- Remount the root filesystem read-write
- rm /boot/grub/device.map and run /usr/sbin/grub-install /dev/hdb to install GRUB in the MBR of what will become the new boot disk
- Power down, swap the disks around so that the new disk is now primary and the old disk is now the slave
- Boot into single user mode again, unmount everything except root
- pvmove /dev/hdb3 /dev/hda3 to relocate all of the allocated physical extents off the old disk onto the new one
- Twiddle thumbs for a couple of hours. Admire artwork on computer's motherboard (did you know Compaq EVO's have a picture of a car on their motherboards? A map of Texas?)
- vgreduce base /dev/hdb3 to take the old disk out of the volume group
- pvremove /dev/hdb3 to remove the LVM signature from the old disk
- Power down and remove the old disk
- Reboot into multi-user mode and profit from all the additional free physical extents
I absolutely love how I can do this with LVM, with a minimum of fuss. Last time I did this, I had a kernel panic during the pvmove, but that didn't even stop it, I just rebooted and reran the pvmove and it carried on from the last checkpoint. No such excitement this time.
I'm sure Solaris' ZFS does all of this with substantially less manual steps, but hey, I like my Linux :-)