Skip to content

Instantly share code, notes, and snippets.

@linuxkathirvel
Last active June 22, 2018 07:41
Show Gist options
  • Save linuxkathirvel/2393fe5c07548cb7b48adcbf4a99129f to your computer and use it in GitHub Desktop.
Save linuxkathirvel/2393fe5c07548cb7b48adcbf4a99129f to your computer and use it in GitHub Desktop.

LVM Management in GNU/Linux

Create new LVM partition from unallocated space

  1. Create new partition using fdisk
  2. Change partition type using t option and put 8e to LVM type in fdisk
  3. Write the changes in disk using w option in fdisk
  4. Reboot system to commit changes
  5. Create Physical Volume using pvcreate /dev/sdaX
  6. Create Volume Group using vgcreate vgname /dev/sdaX
  7. Create Logical Volume in Volume Group using lvcreate -n datalv0 -L 30G centos-data
  8. Get create LV name using lvdisplay
  9. Format LV using mkfs.ext4 /dev/centos-data/datalv0

Mounting Logical Volumes on Boot and on Demand

  1. Create new directory mkdir /data
  2. Get UUID using blkid /dev/centos-data/datalv0
  3. Append UUID=3f33f393-8b09-48e0-8a7e-5e06d90f7781 /data ext4 defaults 0 0 in /etc/fstab file to mount in boot time
  4. mount -a to Mount all filesystems (of the given types) mentioned in /etc/fstab file
  5. Give the prior permissions to mount point
  6. Done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment