(Up-to-date source of this post.)
LVM is the implementation of logical volume management in Linux. As I don’t use it on a day-to-day basis, I created this blog in case I forgot the basics :-).
Terminology
       sda1   sdc       (PVs on partitions or whole disks)
          \   /
           \ /
          diskvg        (VG)
          /  |  \
         /   |   \
     usrlv rootlv varlv (LVs)
       |      |     |
    ext4  reiserfs  xfs (filesystems)
- Physical volume (PV) — partition (ex. /dev/sda1), disk (ex./dev/sdc) or RAID device (ex./dev/md0)
- Volume group (VG) — group of physical volumes (ex. diskvg)
- Logical volume (LV) — equivalent of standard partitions, where filesystems can be created (ex. /usrlv)
Working with LVM
Creating Volumes
- Create PV (initialize disk) - pvcreate /dev/md0- Check the results with - pvdisplay
- Create VG - vgcreate raid1vg /dev/md0- Check the results with - vgdisplay
- Create LV - lvcreate --name backuplv --size 50G raid1vg- Check the results with - lvdisplay
- Create filesystem - mkfs.ext3 /dev/raid1vg/backuplv
- Edit - /etc/fstab- # RAID 1 + LVM /dev/raid1vg/backuplv /backup ext3 rw,noatime 0 0
- Create mount point and mount volume(s) - mkdir -p /backup mount -a
Extending LV
- Extend the LV - lvextend -L +5G /dev/raid1vg/backuplv
- Re-size the filesystem (online re-sizing doesn’t seem to cause troubles) - resize2fs /dev/raid1vg/backuplv
No comments:
Post a Comment