Skip to content

Instantly share code, notes, and snippets.

@benzipperer
Last active June 14, 2021 20:10
Show Gist options
  • Save benzipperer/86c58f21c012ff630720a3d5f41c1390 to your computer and use it in GitHub Desktop.
Save benzipperer/86c58f21c012ff630720a3d5f41c1390 to your computer and use it in GitHub Desktop.
lvm stuff

stuff for LVM

create LVM partition on new physical volume

Find the new physical volume using fdisk -l. Let's say it is /dev/sda.

Then partition using fdisk /dev/sda. Type n to create primary partition, default partition 1, default sectors. Then type t to change partition type to 8e (Linux LVM). Then type w to write the partition table.

initialize physical volume for LVM

pvcreate /dev/sda1

Now you can see the new physical volume using pvs and pvdisplay.

create new volume group for partition

Let's say the new volume group is vg_name. Then do

vgcreate vg_name /dev/sda1

Now you can see the new volume group using vgs and vgdisplay.

create new logical volume in the volume group

Let's say the new logical volume is lv_name.

To specify the size in absolute terms use the -L flag:

lvcreate -L 100G -n lv_name vg_name

To specify the size as a percentage of the volume group use the -l flag:

lvcreate -l 100%FREE -n lv_name vg_name

Now you can see the new logical volume using lvs and lvdisplay. In particular the latter will show you that the new logical volume has a path something like /dev/vg_name/lv_name.

format and mount the partition

Use for example

mkfs.ext4 /dev/vg_name/lv_name

and then

mount /dev/vg_name/lv_name /mount/point
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment