[TUTORIAL] How to create an LVM-Thinpool and Vz directory on the same disk.

jieiku

Member
Jan 1, 2020
26
20
23
43
I wanted to add a disk, and primarily use it as a Thinpool, and I also wanted some directory storage for images and templates on the same disk.
The guide here shows how to do it: https://pve.proxmox.com/pve-docs/chapter-sysadmin.html#chapter_lvm
However its not as simple as copy and paste. You have to read between the lines, and understand what your doing.

screenshot_30.png

Here is my copy/paste to setup a New 600gb /dev/sdb drive:

Code:
    #wipe the drive:
parted /dev/sdb mklabel gpt
    *or*
wipefs -a /dev/sdb
    *or*
dd if=/dev/zero bs=512 count=1 of=/dev/sdb status=progress

    #create an sdb1:
lvs -a
sgdisk -N 1 /dev/sdb

    #create Physical Volume and Volume Group:
pvcreate --metadatasize 1024M -y -ff /dev/sdb1
vgcreate --metadatasize 1024M proxvg /dev/sdb1

    #create lvm thinpool:
lvcreate -l 100%FREE --poolmetadatasize 1024M --chunksize 256 -T -n proxthin proxvg
lvcreate -n proxvz -V 200G proxvg/proxthin

    #create ext4 filesystem:
mkfs.ext4 /dev/proxvg/proxvz

    #mount the LV:
mkdir /media/vz
echo '/dev/proxvg/proxvz /media/vz ext4 defaults,errors=remount-ro 0 2' >> /etc/fstab
mount -a
lvs -a

PROXMOX WEB UI:
==========================
Datacenter->Storage->Add->Directory
    id:vz
    directory:/media/vz

Datacenter->Storage->Add->LVM-Thin
    id:proxthin
    Volume group:proxvg
    Thin Pool:proxthin
 
Last edited:
Great !!
But, I have one question about a thing.

I need to add a disk to create a OSD to CEPH.

I put SSD on server, and its appear by command line:

# fdisk -l

Bash:
Disk /dev/sdc: 4 TiB, 4398058045440 bytes, 1073744640 sectors
Disk model: 100E-00         
Units: sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 84DDFAFA-BEE6-F04E-AF5E-CA30BE34D1A5

Device     Start        End    Sectors Size Type
/dev/sdc1    256 1073744634 1073744379   4T Linux filesystem

But, there is one more BUT, on de GUI of Proxmox doesn't show the disk

ssd.PNG

Whats command line am I missing to do?
 
This guide was created as a result of me slowly working through the problem. I am not a proxmox expert and only just recently started usinig Proxmox. You may want to ask your question in a new thread, because i have no idea about OSD or CEPH. and I dont normally give advice until I have tested that something works first hand.
 
Many thanks, it works perfectly!
Could you please tell me how can I remove a disk that I added before (following your guide)? Thank you very much!
 
Last edited:
If you mean from proxmox VE you would goto Datacenter > storage > click on the one you want to remove, then click the remove button.

if you mean to erase the drive, do as the guide shows at the top, but understand this wipes out the entire device, meaning all partitions on that drive.

Code:
#wipe the drive:
parted /dev/sdb mklabel gpt
    *or*
wipefs -a /dev/sdb
    *or*
dd if=/dev/zero bs=512 count=1 of=/dev/sdb status=progress
 
Last edited:
If you mean from proxmox VE you would goto Datacenter > storage > click on the one you want to remove, then click the remove button.
I mean to remove it from proxomox. I already did it, but it didn't work: when I physically disconnect the harddisk and I reboot Proxmox, it doesn't start and shows this error.
 

Attachments

  • proxmox.jpeg
    proxmox.jpeg
    544.7 KB · Views: 27
You can remove storage devices from proxmox by editing the file directly if the UI is not getting the job done, just ssh in and do this:
Code:
nano /etc/pve/storage.cfg

however I am not certain if this removes the device in question from the /etc/fstab if it somehow get an entry for the device into there.
If that is the case then you can edit the /etc/fstab file, remove the device from the file, power off, disconnect drive, then power back on

This is however untested advice so proceed at your own risk.

my entire /etc/fstab file if i open it with nano looks like this:

Code:
nano /etc/fstab
# <file system> <mount point> <type> <options> <dump> <pass>
/dev/pve/root / ext4 errors=remount-ro 0 1
UUID=A01C-32BA /boot/efi vfat defaults 0 1
proc /proc proc defaults 0 0
 
  • Like
Reactions: datacommerce
You can remove storage devices from proxmox by editing the file directly if the UI is not getting the job done, just ssh in and do this:
Code:
nano /etc/pve/storage.cfg

however I am not certain if this removes the device in question from the /etc/fstab if it somehow get an entry for the device into there.
If that is the case then you can edit the /etc/fstab file, remove the device from the file, power off, disconnect drive, then power back on

This is however untested advice so proceed at your own risk.

my entire /etc/fstab file if i open it with nano looks like this:

Code:
nano /etc/fstab
# <file system> <mount point> <type> <options> <dump> <pass>
/dev/pve/root / ext4 errors=remount-ro 0 1
UUID=A01C-32BA /boot/efi vfat defaults 0 1
proc /proc proc defaults 0 0
I confirm you that after remove drive from UI, file "/etc/fstab" must be edited: you have to delete all references of the drive(s) you want to remove... in this case the line
Code:
/dev/proxvg/proxvz /media/vz ext4 defaults,errors=remount-ro 0 2
Thank you very much for your support!
 
Nice post, but would have been nicer if he had given little explanation for each command like what he is trying to achieve and why.
 
Great post!!
Pardon me for any stupid questions. :)
I'm new to proxmox. I just got a new NUC11 and running proxmox 6.4.1
The NUC have 2 disk, a 500G SSD and a 2TB NVME. I am using 2TB to store the images.

Here's the steps i followed:
Bash:
sgdisk -N 1 /dev/nvme0n1
pvcreate --metadatasize 250k -y -ff /dev/nvme0n1p1
vgcreate vmdata /dev/nvme0n1p1
lvcreate -l 100%FREE -T -n vmstore vmdata
mkfs.ext4 /dev/vmdata/vmstore
mkdir /vmstore
echo '/dev/vmdata/vmstore /vmstore ext4 defaults,errors=remount-ro 0 2' >> /etc/fstab
mount -a

Everything's sweet.
However, it went into emergency mode after a reboot.
The issue is with /etc/fstab
I commented the added line and reboot successfully.
Remount it again in proxmox WebUI shell.

Any idea if i'm missing any steps?

Thanks in advanced!
 
It's late but I found that @j3z missed one lvcreate command (which is written in the first post).
You only created a thin pool, not a thin volume.
 

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 yours easily in our online shop.

Buy now!