adding a disk and set it as lvm-thin: help needed, please

FiNaR

New Member
Sep 23, 2021
24
2
3
51
hello people,

I have been reading quite a bit how to add a new ssd to my homelab (proxmox) and how to add it as lvm-thin storage...

I got to the following list of actions (assuming that nvme0n1 is the newly added SSD)

  • format the disk
    Code:
    sgdisk -N 1 /dev/nvme0n1
  • create a physical volume
    Code:
    pvcreate /dev/nvme0n1
  • create a volume group
    Code:
    vgcreate pve_nvme0n1 /dev/nvme0n1
    or I should use the existing
    Code:
    pve
    volume group? (at the moment the pve is composed by a SATA SSD where Proxmox and ISO images are stored)
At this point I am stack on what next....

my readings tells me that the next actions should be :

  1. create LVM thin pool
  2. create LVM thin volume
  3. EXT4 File System
  4. Mount new Logical Volume (LV)
  5. Add the LVM-Thin in proxmox UI
I am here to:

  • validate initial three points
  • get confirmation and seek suggestions on the 5 "next actions" points
and in specific:

  • can I create a LVM thin pool that is 100% of the available storage?
  • why I need a volume within the thin pool?
  • do I need to mount the LV? why?
looking forward to hearing back from you experts :)
 

Dunuin

Famous Member
Jun 30, 2020
6,811
1,585
149
Germany
  • can I create a LVM thin pool that is 100% of the available storage?
100% didn't worked here, but 99%.
  • why I need a volume within the thin pool?
You don't need it, unless you want to store files on that disk too. Then a mounted LV as a directory storage might be useful.


In case you want to use the whole disk for LVM-Thin you could also create it using the webUI.
 

FiNaR

New Member
Sep 23, 2021
24
2
3
51
100% didn't worked here, but 99%.
how do I do that? something like : lvcreate -l 100%FREE ?
You don't need it, unless you want to store files on that disk too. Then a mounted LV as a directory storage might be useful.
thank i want to do is to have LVM-thin to store VM and Container, hence, once I have created the thinpool, what do I need to do?
 

Dunuin

Famous Member
Jun 30, 2020
6,811
1,585
149
Germany
You could just create a complete LVM-Thin Disk by using the webUI:
1.) Wipe Disk to start with a empty unpartitioned disk: Datacenter -> YourNode -> Disks -> disk you want to wipe ->"Wipe disk" button
2.) Create a LVM-Thin storage using that wiped disk: Datacenter -> YourNode ->Disks -> LVM-Thin ->"Create Thin pool" button

Or if you want do do it manually using the CLI:
1.) create new partition table + create a partition:
Code:
fdisk /dev/disk/by-id/yourDisk
g
n
Enter
Enter
Enter
w
2.) Create PV and VG:
Code:
pvcreate /dev/disk/by-id/yourDisk-part1
vgcreate newVgName /dev/disk/by-id/yourDisk-part1
3.) Create a LV and convert that LV into a thin pool:
Code:
lvcreate -l99%FREE -n newLvName newVgName
lvconvert --type thin-pool newVgName/newLvName
4.) Add LVM-Thin storage to PVE:
Code:
pvesm add lvmthin newStorageName --content rootdir,images --thinpool newLvName --vgname newVgName
 
Last edited:

FiNaR

New Member
Sep 23, 2021
24
2
3
51
Or if you want do do it manually using the CLI:

Great! thank you! this is what I was looking for!!!

Couple of questions, please:

1) pvcreate and vgcreate parameters
2.) Create PV and VG:
Code:
pvcreate /dev/disk/by-id/yourDisk-part1
vgcreate newVgName /dev/disk/by-id/yourDisk-part1

some online tutorial suggests to add parameters to pvcreate and vgcreate, what is your opinion on that? see example below:

Code:
pvcreate --metadatasize 1024M -y -ff /dev/disk/by-id/yourDisk-part1
vgcreate --metadatasize 1024M newVgName /dev/disk/by-id/yourDisk-part1

2) My Proxomx already has a Volume Group: pve what will happen if I use the same volume group instead of creating a new one? what is the best practice here?

3) is it a technical limitation to only use 99% of the disk?
lvcreate -l99%FREE -n newLvName newVgName

4) when I add the LVM-This storage to PVE, the command has few parameters; just for clarity:
  • newStorageName: is the name I want to give to the storage, it does not exist before this command, right?
  • rootdir: store containers, right?
  • images: store VMs, right?
4.) Add LVM-Thin storage to PVE:
Code:
pvesm add lvmthin newStorageName --content rootdir,images --thinpool newLvName --vgname newVgName

Thank you so much!
 

Dunuin

Famous Member
Jun 30, 2020
6,811
1,585
149
Germany
Great! thank you! this is what I was looking for!!!

Couple of questions, please:

1) pvcreate and vgcreate parameters


some online tutorial suggests to add parameters to pvcreate and vgcreate, what is your opinion on that? see example below:

Code:
pvcreate --metadatasize 1024M -y -ff /dev/disk/by-id/yourDisk-part1
vgcreate --metadatasize 1024M newVgName /dev/disk/by-id/yourDisk-part1
I'm not a big fan of stuff like "-y" or "-ff". If there is a problem I want to decide what to do next instead of skipping any dicisions or forcing stuff ignoring warnings. If you want you can use a custom metadata size. But how big it needs to be depends on multiple factors like the size of your disk, how big the logical blocks are your data will be stored in and so on. If you don't manually set it will default to a calculated size based on your disk and other configurations that should be usually big enough without wasting space. But if you don't care about some wasted GB you can choose a bigger metadata size to be sure not to run into the problem that your metadata will run full before the data will, as the metadata size of a PV can't be changed later. If I understand it right creating a LVM-Thin using the webUI, PVE would choose 1% of the disk size but atleast 1GB and maximum 16GB.
2) My Proxomx already has a Volume Group: pve what will happen if I use the same volume group instead of creating a new one? what is the best practice here?
Using the same VG would be useful if you want to create a LVM based raid1, raid0 or JBOD.
3) is it a technical limitation to only use 99% of the disk?
You can try it with 100%, but here the VG doesn't got enough space for 100% and creation failed.
4) when I add the LVM-This storage to PVE, the command has few parameters; just for clarity:
  • newStorageName: is the name I want to give to the storage, it does not exist before this command, right?
  • rootdir: store containers, right?
  • images: store VMs, right?
Jup.
 

FiNaR

New Member
Sep 23, 2021
24
2
3
51
I'm not a big fan of stuff like "-y" or "-ff". If there is a problem I want to decide what to do next instead of skipping any dicisions or forcing stuff ignoring warnings. If you want you can use a custom metadata size. But how big it needs to be depends on multiple factors like the size of your disk, how big the logical blocks are your data will be stored in and so on. If you don't manually set it will default to a calculated size based on your disk and other configurations that should be usually big enough without wasting space. But if you don't care about some wasted GB you can choose a bigger metadata size to be sure not to run into the problem that your metadata will run full before the data will, as the metadata size of a PV can't be changed later. If I understand it right creating a LVM-Thin using the webUI, PVE would choose 1% of the disk size but atleast 1GB and maximum 16GB.

Using the same VG would be useful if you want to create a LVM based raid1, raid0 or JBOD.

You can try it with 100%, but here the VG doesn't got enough space for 100% and creation failed.

Jup.
perfect! it seems I managed to do it!!! :) thank you
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get your own in 60 seconds.

Buy now!