Aug 10, 2011
tom

Rebuild Software RAID1+LVM after OS change (from Ubuntu to CentOS)

Question

I think the title is pretty self-explanatory about my current situation, but here is the long version:

I am currently running Ubuntu 9.04, I built a RAID 1 array with two disks and then used LVM to mount several partitions on top of it and it looks like this:

/dev/sda1           /               <- single disk, has /home, /root, /etc, /boot ... everything else
/dev/mapper/vg1-lv1 /media/medios   <- LVM on RAID 1
/dev/mapper/vg1-lv3 /media/iso      <- LVM on RAID 1
/dev/mapper/vg1-lv5 /media/backup   <- LVM on RAID 1
/dev/mapper/vg1-lv6 /media/varios   <- LVM on RAID 1

RAID 1 lies on two external 1TB usb disks.

What I want to accomplish is to remove Ubuntu and install CentOS, but I don’t want to lose my data on RAID + LVM, What are the required steps to follow in order to get it right? Or CentOS installer will just “recover” things automatically?

Answer

I’ll assume for a moment that Ubuntu 9.04 uses LVM2 and that you’re referring to software raid using mdadm. If that is the case, the CentOS installer (anaconda) can discover your RAID on the external disks, and then the vg1 volume group. I’ve only done this successfully when the RAID1 was configured on top of the first partition (/dev/sdb1 and /dev/sdc1, for example), and the partition was configured as type ‘fd’.

I suggest you slip in the CentOS CD and start the installer. When you get to this screen, select “Create Custom Layout” from the dropdown. On the next page, it should show you all your filesystems graphically. If it doesn’t, just reboot – nothing has changed yet. Obviously, you’ll need to wipe /dev/sda1 to install the new OS.

A safer, but less automatic, way would be to unplug your external drives during the CentOS install. After the system boots for the first time, yum install mdadm and mdadm --assemble. After you have your /dev/md0 device and have updated /etc/mdadm.conf, yum install lvm and pvscan, vgscan, lvscan, create /media/* directories, and add the mounts to /etc/fstab.

Related posts:

  1. Clarifications on encrypted LVM in Ubuntu, RAID1, and headless server
  2. Centos 5.5 Installation on Intel RAID 1
  3. Rescue disk is unable to see the lvm physical volumes
  4. Centos 5.5 SoftRaid Grub Installation
  5. Detaching EBS Volumes (in LVM) take a lot of time

Leave a comment