Installing Ubuntu on a drive with an existing RAID and LVM

September 20, 2006 at 09:51 AM | categories: Computers, Programming | View Comments

I recently switched this server from running Gentoo Linux to Ubuntu Linux. In the process I only wanted to replace the OS and not loose my home directory and other data. 160G hard drives which are partitioned identically so that I can used RAID in a mirrored setup (RAID1). There are 4 partitions on the drive: a 10G primary partition which I had intended for windows but never used, 100M primary partition used as /boot, a 2G logical partition for the root filesystem (/), a 500M swap partition (Not raided gives me 1G of swap), and the rest ~151G used as LVM for the rest of the system.

Running # cat /proc/mdstat gives the following output:

Personalities : [raid1]
md2 : active raid1 hde6[0] hdg6[1]
      147717568 blocks [2/2] [UU]

md1 : active raid1 hde5[0] hdg5[1]
      1999936 blocks [2/2] [UU]

md0 : active raid1 hde2[0] hdg2[1]
      96320 blocks [2/2] [UU]

unused devices: <none>

Running # lvscan gives the following ouput:

ACTIVE            '/dev/vg0/tmp' [2.00 GB] inherit
ACTIVE            '/dev/vg0/home' [20.00 GB] inherit
ACTIVE            '/dev/vg0/usr' [15.00 GB] inherit
ACTIVE            '/dev/vg0/local' [5.00 GB] inherit
ACTIVE            '/dev/vg0/opt' [5.00 GB] inherit
ACTIVE            '/dev/vg0/var' [5.00 GB] inherit
ACTIVE            '/dev/vg0/data' [88.87 GB] inherit

I wanted to format md0, md1, /dev/vg0/tmp, /dev/vg0/usr, /dev/vg0/local, /dev/vg0/opt, /dev/vg0/var, and keep the data on /dev/vg0/home, /dev/vg0/data. I did a backup of /etc for reference and /var/www because I would need to restore some stuff. I also backed up my mysql databases since they are also stored in /var. I did a backup of most of the important data on /dev/vg0/data and /dev/vg0/home. Some data I did not backup (media) because there was just too much of it.

Once all of my planning and backing up was done I booted with the Ubuntu Dapper Drake alternate i386 disk which is required for RAID and/or LVM configurations. My first supprise was that there was no GUI install. We were back to the Debian console install manager. Everything went smoothly until I got to the partitioning. It did not detect my existing RAID and LVM configuration. I was able to get my existing configuration up and running via the command line on another Virtual Terminal(VT), but by that point I had the installer wedged in a state where it just would not continue.

I had to reboot and start all over again. Here are the steps I took to get it working:

  1. boot the installer
  2. switch VTs to get a console
  3. run modprobe raid1
  4. run modprobe dm_mod
  5. run mdrun
  6. run vgchange -a y
  7. cat /proc/mdstat and lvscan should give output like above
  8. change back to the VT with the installer running in it
  9. continue with installer steps
  10. when you get to the partitioning step, it should recognise your raid and lvm devices

I ended up getting everything installed with no loss of data.

blog comments powered by Disqus