1. Ubuntu 10.04 on LVM

    I never get partition sizes right; too much root, too little root etc. So I’m going to re-build my notebook with LVM partitioning, just for kicks. Ubuntu Server CDs support LVM install from the “Expert” mode, but it doesn’t look like the desktop variants do. Given that they save me a fair bit of work subsequently, I’ll therefore work around that.

    My starting point will probably be http://bit.ly/92oE - I’ll write up my discoveries here.

    The raw instructions. First, boot off a live CD or memory key. Open a terminal and get ready for LVM:

    $ sudo apt-get install lvm2

    Ignore errors about not being able to open casper-functions and not being able to stat /vmlinux.

    $ sudo modprobe dm-mod

    I’m using the whole disk (/dev/sda) but /boot needs to be on a normal partition and I’m going to put /swap on there as well. The rest, that’ll be for LVM. Use fdisk to partition:

    $ sudo fdisk /dev/sda

    I made a 100Mb boot partition (type 83), 6Gb swap (type 82) and the rest is LVM (type 8e). Now the kernel needs to re-read the partition table:

    $ sudo partprobe

    although this failed for me for various reasons so i just rebooted.

    Now make the ext3 partition on /boot

    $ sudo mke2fs -j /dev/sda1

    Now let’s make the LVM volume

    $ sudo pvcreate /dev/sda3 sudo vgcreate lvmvolume /dev/sda3 sudo

    $ lvcreate -n root -L 20G lvmvolume sudo lvcreate -n home -L80G

    $ lvmvolume sudo mkfs.ext4 /dev/lvmvolume/root -L root sudo mkfs.ext4 /dev/lvmvolume/home -L home sudo mkswap /dev/sda1

    Now install Ubuntu onto your new LVM partitions. Once done you need to install LVM2 into the new installation otherwise you’ll not be able to boot it. The plan is to open a shell, chroot into your new installation and install with apt-get. To start you’ll need to mount your future root partion; I’m just mounting on /mnt; /dev/sdaX is the new root partition:

    $ mount /dev/lvmvolume/root /mnt mount /dev/lvmvolume/home /mnt/home

    $ chroot /mnt sudo apt-get install lvm2

    Now go ahead and reboot! 

    This worked a treat for me - now I can change my partitions on-the-fly when I want. That is a very simple use-case of course, but useful enough that I don’t see why I wouldn’t use LVM for all future installs.

    For less trivial circumstances, when you have multiple disks, servers etc, the value is much greater. Being able to add and remove physical drives, stripe your data across dives, snapshot drives and more all make LVM deeply compelling.

    I think I just got excited about storage.

Notes

  1. matthew-pontefract posted this