Creating a LVM filesystem

This post is more for more reference, but hopefully someone else finds it useful as well. There are several posts online about LVM, but the directions I follow are:
http://www.debuntu.org/how-to-install-ubuntu-over-lvm-filesystem

$ sudo mke2fs -j /dev/sda2
$ sudo pvcreate /dev/sda3 #create a physical volume on /dev/sda3
Physical volume "/dev/sda3" successfully created
$ sudo vgcreate lvmvolume /dev/sda3 #create a volume group named lvmvolume using /dev/sda3 physical volume
Volume group "lvmvolume" successfully created
$ sudo lvcreate -n root -L 5G lvmvolume #create a logical volume of 5G named "root" in lvmvolume
Logical volume "root" created
$ sudo lvcreate -n home -L 10G lvmvolume #create a logical volume of 10G named "home" in lvmvolume
Logical volume "home" created
$ sudo lvcreate -n swap -L 2G lvmvolume #create a logical volume of 2G named "swap" in lvmvolume
Logical volume "swap" created
$ sudo mkfs -j /dev/lvmvolume/root -L root #format root as ext3
$ sudo mkfs -j /dev/lvmvolume/home -L home #format home as ext3
$ sudo mkswap -L swap /dev/lvmvolume/swap #format swap as swap filesystem, labelled swap
$ sudo pvcreate /dev/sda3 #create a physical volume on /dev/sda3
Physical volume "/dev/sda3" successfully created
$ sudo vgcreate <hostname>-<mountpoint> /dev/sda3 #create a volume group
Volume group "<hostname>-<mountpoint>" successfully created
$ sudo lvcreate -n lvol0 -L 5G <hostname>-<mountpoint> #create a logical volume
Logical volume "lvol0" created
$ sudo mkfs -j /dev/<hostname>-<mountpoint>/lvol0 -L lvol0 #format lvol0 as ext3

© 2011, Steve Flanders. All rights reserved.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top