LVM
General LVM usage.
Shrink a logical volumne
Unmount and check the filesystem:
# umount /foo
# e2fsck -f /dev/mapper/vg-foo
Resize the filesystem and the logical volumne, perform a filesystem check to see if it fits into the logical volumne:
# resize2fs -p /dev/mapper/vg-foo 4G
# lvreduce -L 4G /dev/mapper/vg-foo
# e2fsck -f /dev/mapper/vg-foo
Resize the filesystem to match the logical volumne size:
# resize2fs -p /dev/mapper/vg-foo
# e2fsck -f /dev/mapper/vg-foo
Mount the filesystem:
# mount /foo
Extend a logical volumne online
# e2fsck -f /dev/mapper/vg-foo
# lvresize -L 10G /dev/mapper/vg-foo
# resize2fs /dev/mapper/vg-foo
# e2fsck -f /dev/mapper/vg-foo
Create a new physical volumne
# pvcreate /dev/sdXY
Create a new volumne group
# vgcreate vg01 /dev/sdXY
Create a new logical volumne
Create logical volumne and filesystem:
# lvcreate -L 8G -n foo vg
# mkfs.ext4 /dev/mapper/vg-foo
Add to /etc/fstab
:
/dev/mapper/vg-foo /foo ext4 defaults 0 2
Mount:
# mount /foo
Sources: