How to: Delete/Remove local-lvm from Proxmox VE (PVE) (and Some LVM basics, commands)

Last Updated on

1 Delete/Remove local-lvm

Before we start, make sure we login to PVE web gui, delete local-lvm from Datacenter -> Storage. Select the local-lvm, Click on “Remove” button

1.1 Login to pve via SSH

1.2 Unmount and Delete lvm-thin

umount /dev/pve/data
lvremove /dev/pve/data

Confirm to delete

1.3 Check free space

vgdisplay pve | grep Free

1.4 Create new lvm

Note: Replace 92482 with the number you get from step 3, which is available free space

lvcreate -l 92482 -n data pve

1.5 Format and mount

mkfs.ext4 /dev/pve/data
mkdir /mnt/data
mount /dev/pve/data /mnt/data

Note: Use “mkfs.ext4” for ext4 format, “mkfs.xfs -f” to use xfs format

1.6 Modify fstab, so that it’s mounted on boot, add following line to the end of the file

nano /etc/fstab
/dev/pve/data /mnt/data ext4 defaults 0 0

Note: If you have used xfs, replace ext4 with xfs

2 Use it in Proxmox

If you want to use it from PVE with ease, here is how

2.1 Login to Proxmox web gui

2.2 Navigate to Datacenter -> Storage, click on “Add” button

2.3 Click on “Directory”

2.4 Give it a name (ID field), Directory is “/mnt/data”, select Content you want to put to the directory, you can just select all of them.

2.5 Click on “Add” button

2.6 Now you can use the folder on that LVM volume easily within Proxmox

3 To revert to lvm-thin

3.1 Unmount

umount /mnt/data

3.2 Remove partition

lvremove /dev/pve/data

3.3 Create a one 1 block sized data partition, to prevent error for next step

lvcreate -l 1 -n data pve

3.4 Convert to thin-pool

lvconvert --type thin-pool pve/data

3.5 Merge the reset free space to the partition

lvextend -l +99%FREE pve/data

3.6 Remove mount line from /etc/fstab file

nano /etc/fstab
# Remove following line, if there is one
/dev/pve/data /mnt/data ext4 defaults 0 0


LVM: Logical Volume Manager

LVM Usage: Create logical partition, so that it can be resized easily

PV: Physical Volume, similar to partition

PE: Physical Extent, Physical blocks, similar to block (Multiple continues blocks)

LV: Logical Volume, what file system sees as “partition”

LE: Logical Extent, what file systems sees as “block”

VG: Volume Group, like a storage pool

1 Physical Volume can have/contain multiple Physical Extents

1 Logical Volume can have/contain multiple Logical Extents

1 Volume Group is made up of multiple Physical Volumes

Logical Extent is created from Volume Group, which is similar to /dev/sda etc.

View Physical Volumes: pvdisplay

View Logical Volumes: lvdisplay

View Volume Groups: vgdisplay

Create Physical Volume

Use the entire disk

pvcreate /dev/sdb

Use only one partition: Use fdisk to change partition type to 0x8E which is (Linux LVM)

Create Volume Group

Create one Volume Group (vg1) from two disks (/dev/sda and /dev/sdb)

vgcreate vg1 /dev/sda /dev/sdb

Add Physical Volume to Volume Group

vgextend vg1 /dev/sdc

Create Logical Volume

Check size of Physical Extent

vgdisplay vg1

Create an 10GB Logical Volume

lvcreate -L 10G -n lv1 vg1

Create ext4

mkfs.ext4 /dev/vg1/lv1
mkfs -t ext4 /dev/vg1/lv1

Extend file system size

(Extend data partition with another 10GB)

Extend Logical Volume size

lvextend -L +10G /dev/vg1/lv1

Extend file system size

resize2fs /dev/vg1/lv1

Shrink files system size

Shrink to 10GB

umount /data
resize2fs /dev/vg1/lv1 10G
# Run e2fsck to check file system
e2fsck -f /dev/vg1/lv1
lvreduce -L 20G /dev/vg1/lv1
mount -t ext4 /dev/vg1/lv1 /mnt/lv1

Extend Logical Volume and file system

Extend Logical Volume so tat it uses all free space from Volume Group, then extend the file system

lvextend -l +100%FREE /dev/vg1/lv1
resize2fs /dev/vg1/lv1

Use all of the free space on Volume Group to create a new Logical Volume

lvcreate -l 100%FREE -n lv2 vg1

Proxmox (PVE) Unlock locked virtual machine

qm unlock 100

Proxmox (PVE) Stop virtual machine

qm stop 100

Note: Replace 100 with your virtual machine ID

Leave a Reply

Your email address will not be published. Required fields are marked *