Friday, October 23, 2009

Replacing multiple hard drives including the one containing boot under linux with LVM.

I had a server with 3 old hard drives 2 IDE and 1 SCSI.

One of the IDE discs had the /boot partition ~200MB. The rest was part of an LVM partition which was a logical volume group along with the rest of the drives. The group had 2 logical volumes, 1 for the root and a 2GB one for swap.

I decided to move everything to one SATA drive. Turns out it was a relatively simple and safe process.

The first thing is to create the boot partition on the new drive. Same size ~200MB. I've used fdisk to do that. Then I've created another partition which spanned across the remaining disk. I had to change its type (use the t command) to 8e which is the LVM type.

Next simply mounted the new boot partition: mount /dev/sdc1 /mnt/newboot
Then copy the old boot to the new boot: cp -afv /boot/* /mnt/newboot

Add the new disc's partition into the volume group:

pvcreate /dev/sda2
vgextend VolGroup00 /dev/sda2

Time to to the lvm transfer now, simply pmove each of the old disks to the old one and then remove them from the group:

pmove /dev/hda2 /dev/sda2
vgreduce VolGroup00 /dev/hda2

pmove /dev/hdb1 /dev/sda2
vgreduce VolGroup00 /dev/hdb1

pmove /dev/hdd1 /dev/sda2
vgreduce VolGroup00 /dev/hdd1

All done, now poweroff and remove old discs.

Boot using a live CD,USB or Super grub and install grub and voila!
Post a Comment