Tuesday, February 9, 2010

install ubuntu 9.10 karmic on lvm

Recently I upgraded my Ubuntu install on my netbook to the latest version of 9.10 karmic. I wasn't too happy with the leftovers and some applet configurations that were missing after upgrading so I decided to just reinstall directly to 9.10. I thought this would also give me a chance to redo my filesystem layouts to better utilize my 4GB SSD and 12G SSD in my netbook.

Things quickly turned ugly as I found out that the 'advanced partitioning' provided by ubuntu is no where near what I am used to when installing RHEL or SLES at work. I soon found out to install to LVM you first need to setup your LVM configuration and mkfs your volumes BEFORE you start the ubuntu install. After everything is setup it will see them and you can then specify what you want to mount where and the install will work as you want it.

Of course there are some workarounds to doing all this ... here is the process I used.

  1. Get your Ubuntu 9.10 install/live cd
  2. If you do not have network for the system your installing to (wired or wireless) then download the following to a USB drive (these are 32-bit versions since I have a netbook, you may need to find 64-bit versions for your install)
  3. Boot your system using the Ubuntu 9.10 install/live cd
  4. Once booted open a terminal and get root
    • sudo su -
  5. For systems with no network:
    • Insert your USB stick with the packages you downloaded above
    • cd to /media/[USBdriveName]/[directoryWithPackages]
    • Install lvm2 and watershed to the live cd OS
      • dpkg -i lvm2*.dev watershed*.deb
  6. For systems with network:
    • apt-get update
    • apt-get install lvm2
Now that lvm2 is installed you can create your PVs, VGs, LVs. You can do this however you want. The following is what I did as a reference for people who may not know much about LVM. My setup including striping between 2 disks so you may want to adjust how you do things ...

  1. fdisk /dev/sda
    • o
    • w
    • n
    • p
    • 1
    • 1
    • +100M
    • n
    • p
    • 2


    • t
    • 2
    • 8e
    • w
  2. fdisk /dev/sdb
    • o
    • w
  3. This is where I had some issues. I had some type of lock on /dev/sdb when trying to do the next step of pvcreate to pull it into LVM ... so I needed to reboot to release it. If you need to reboot to use your disk you will need to follow steps 1-6 from the first section to get a live boot enviornment with LVM running again.
  4. pvcreate /dev/sda2
  5. pvcreate /dev/sdb
  6. mkfs.ext2 /dev/sda1
  7. vgcreate rootdisk /dev/sda2 /dev/sdb
  8. lvcreate -i2 -I4 -L6G -nroot_lv rootdisk
  9. lvcreate -l100%PVS -nvar_lv rootdisk /dev/sda2
  10. lvcreate -l100%PVS -nhome_lv rootdisk /dev/sdb
  11. mkfs.ext4 /dev/rootdisk/root_lv
  12. mkfs.ext4 /dev/rootdisk/var_lv
  13. mkfs.ext4 /dev/rootdisk/home_lv
We now have LVM setup to host /, /var and /home filesystems. /boot will exist directly on /dev/sda1 (I later found out I could have tried to include it in LVM because 9.10 uses grub2, but too late now :( ) . So now you can initiate the install.
  1. Start install
  2. When you get to partition/disk setup section choose advanced
  3. You will see the /dev/mapper/[vg]-[lv] devices you created in LVM. Below them will be the filesystem you put on each. Highlight the filesystem one and click the "Change..." button to specify the filesystem to use (should match how you mkfs above) and where to mount. DO NOT HAVE THE INSTALL REFORMAT THE FILESYSTEM.
  4. For /dev/sda1 highlight and click "Change...". Specify the filesystem, where to mount (/boot) and DO HAVE IT FORMAT IT!
  5. Proceed through the rest of the questions to start the install
One the install is finished WE ARE NOT DONE YET. The install installed it to where we want it, but it did NOT install LVM to our new OS! So now we need to mount everything by hand and chroot to our new OS to install LVM and then remake the initramfs. (If you reboot at this point it will not boot stating it can not find your /dev/mapper/[rootVG]-[rootLV]

These instructions follow how I setup my system, you need to make adjustments for the VG/LV names you created.
  1. mount /dev/rootdisk/root_lv /mnt
  2. mount /dev/rootdisk/var_lv /mnt/var
  3. mount /dev/rootdisk/home_lv /mnt/home
  4. mount /dev/sda1 /mnt/boot
  5. mount -t proc proc /mnt/proc
  6. mount -t sysfs sys /mnt/sys
  7. mount -o bind /dev /mnt/dev
  8. IF YOU DO NOT HAVE NETWORK:
    • Insert your USB stick with the packages you downloaded above
    • cd to /media/[USBdriveName]/[directoryWithPackages]
    • cp lvm2*.dev watershed*.deb libreadline5*.deb /mnt/var/tmp
    • chroot /mnt
    • cd /var/tmp
    • dpkg -i lvm2*.dev watershed*.deb libreadline5*.deb
  9. IF YOU HAVE NETWORK:
    • chroot /mnt
    • apt-get update
    • apt-get install lvm2
  10. mkinitramfs -o /boot/[filenameOfCurrentInitramfs]
  11. reboot
That should be it. I made these instructions all after-the-fact, so its all from memory trying to walkthrough what I did. I hope I didn't miss anything, but this should set you on the right track regardless. Below are links I referenced while trying to figure this out that may be helpful as well:

No comments: