Table of Contents

Install logical volumes (LVM)

Prepare and install volumes

Prepare a single disk or a disk raid:

mkfs.ext3 <phsvol>
lvm
lvm> pvcreate <physvol>
lvm> vgcreate <physvol> // or several physical volumes: <physvol1> <physvol2> <physvol3>
lvm> lvcreate <volgroup> <physical>
lvm> quit
mkfs.ext3 /dev/mapper/<volgroup-logvol>
mount /dev/mapper/<volgroup-logvol> <dir>

Auto-mount during boot:

vim /etc/fstab
/dev/mapper/<volgroup-logvol> <dir> ext3 noatime,user_xattr 0 0

Replace LVM disk to upgrade capacity

This example will copy /dev/sde1 mounted on /backup to /dev/sdf1 mounted on /replace and afterwards change mount point, logical volume and volume group names to the source names.

Prepare new disk

Copy content and assign new disk

Setting up LVM on top of a Linux Software Raid

Merge 2 volume groups

  1. Unmount and remove LV0 and LV1 from VG1 with umount/lvremove
  2. Remove VG1 with vgremove
  3. Unmount LV0 and LV1 from VG0 with umount
  4. Extend VG0 with any available PVs if necessary
  5. Mount LV0 and LV1 on VG0 with mount
lvcreate -l<extents> -n testlv testvg
mkfs.ext4 /dev/mapper/vg-lv

Increase / decrease size of logical volume

First, check the status with:

# pvs
# vgs
# lvs

Decrease

  1. sudo umount /srv/media
  2. sudo lvresize –resizefs –size -1024GB /dev/vg_data/lv_media

Increase

  1. sudo lvresize –resizefs –size +1024GB /dev/vg_data/lv_home