I am a big fan of LVM, the Linux Logical Volume Manager. It allows me to create, resize and delete disk partitions very easily. That comes in handy when you’re trying new things out. And it also has a nice snapshot feature, which I use when I am making a backup of a partition… while it is still in use.

If you use the Ubuntu alternate install CD, it gives you menu options for using and configuring Logical Volume Manager. But if you’re using the normal Live installation CD, you have to do it manually. Fortunately, this is not too hard. Below, I will tell how I do it.

  • Boot the Live CD and open a shell.
  • Install the LVM package in the Live CD environment:
    apt-get install lvm2
  • Tell LVM to look for existing volumes, and make them active:
    vgchange -ay
  • You may need to mark one or more physical volumes as being LVM pv’s:
    pvcreate /dev/sdX1
  • You may need to create a volume group:
    vgcreate vglaptop /dev/sdX1
  • Create the volumes that you want to use:
    lvcreate vglaptop --name=ubuntu --size=10G
  • Put a filesystem on the new volume:
    mkfs.ext4 /dev/vglaptop/ubuntu
  • Run the installer and do “manual partitioning”.
  • Use the menus to match up the newly formatted filesystems with the different mount points(root, home, etc).
  • When the installer finishes, tell it to “keep on testing”. Do not reboot.
  • Mount the new root filesystem:
    cd /mnt ; mkdir u ; mount /dev/vglaptop/ubuntu u
  • Mount any other partitions below that:
    mount /dev/sda1 u/boot ; mount /dev/vglaptop/home u/home

    (actually, you only need the root filesystem and /boot — you won’t need /home and others)

  • Mount the “special” filesystems:
    mount --bind /dev u/dev ; mount -t proc proc u/proc
  • Start up a “change root”:
    chroot u

    A new shell will start, using the new root filesystem as its root.

  • Install the LVM package inside the chroot:
    apt-get install lvm2
  • Re-build the initial RAM disk:
    update-initramfs -u -k all

    (this step may be done for you when you install LVM)

  • You may need to update grub:
    update-grub
  • Exit the chroot shell:
    exit
  • Cleanly unmount everything:
    umount u/dev ; umount u/proc ; umount u/home ; umount u
  • Reboot:
    reboot

And when it boots up, it will load the kernel and initramfs, and then it will mount the root filesystem, which is on your new logical volume!