Logical Volume Manager

Growing filesystems

© 2010, 2011, 2012 Dennis Leeuw dleeuw at made-it dot com
License: GPLv2 or later

Index

    1. LVM
    2. Preparing the physical devices
    3. Volume Groups
    4. Logical Volumes
    5. Resizing an ext3 filesystem

LVM

Disk limitations When a disk is full... it's full you can not grow. Even if another partition has space you can not shrink one and grow the other without backing up both partitions first.

Preparing the physical devices

Create an LVM, note that this is destructive for the data on the disks:

pvcreate /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1

Use pvdisplay to show you what is done.

To revert this action use:

pvremove /dev/md0 /dev/md1

Volume Groups

Creat the volume group:

vgcreate vol1 /dev/md0 /dev/md1

Use vgdisplay to see what has been done for a less verbose output use vgscan.

To rename a Volume Group:

vgrename vol1 vg-1

To remove a Volume Group:

vgremove vg-1

Add another pv to a volume group:

pvcreate /dev/sdf
vgextend vol1 /dev/sdf

Logical Volumes

Create a Logical Volume(s):

lvcreate --name lv-1 --size 40G vg-1
lvcreate --name lv-2 --size 5G vg-1
lvcreate --name lv3 --size 1G vg-1

Use lvdisplay to see what happened, for a less verbose output use: lvscan.

To rename Logical Volumes use:

lvrename fileserver lv3 lv-3

To "grow" a file system use:

lvextend -L1.5G /dev/vg-1/lv-3

To "shrink" a file system use:

lvreduce -L1G /dev/fileserver/media
  WARNING: Reducing active logical volume to 1.00 GB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce media? [y/n]: y
  Reducing logical volume media to 1.00 GB
  Logical volume media successfully resized

Your filesystems are now ready for use. The only thing you need to is to create filesystems on them and mount them.

Resizing an ext3 filesystem

Extend the ext3 file system to also use the additional disk space:

resize2fs /dev/vg-1/lv-3