move from "directory" to lvm

limone

Well-Known Member
Aug 1, 2017
89
9
48
31
Hi,

on my test system I have a 20GB Disk, splitted into 18.5GB lv_root and 1GB lv_swap.
Production systems look the same, just with larger disks.

I've set storage in proxmox as directory /var/lib/vz.

It has been fine, but I want to use snapshots, so I have to use lvm. Is there a way to switch from directory to lvm?

My plan was to shut down the containers, do a snapshot and restore them on lvm, but if I add lv_root as storage option in proxmox, it shows disk usage is 100%.

Code:
Disk /dev/sda: 20 GiB, 21474836480 bytes, 41943040 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x1606d709

Device     Boot    Start      End  Sectors  Size Id Type
/dev/sda1  *        2048   976895   974848  476M 83 Linux
/dev/sda2         976896 20969471 19992576  9.5G 8e Linux LVM
/dev/sda3       20969472 41943039 20973568   10G 8e Linux LVM

Code:
root@proxmox:~# pvs
  PV         VG Fmt  Attr PSize  PFree
  /dev/sda2  vg lvm2 a--   9.53g    0
  /dev/sda3  vg lvm2 a--  10.00g    0
 
root@proxmox:~# vgs
  VG #PV #LV #SN Attr   VSize  VFree
  vg   2   2   0 wz--n- 19.53g    0
 
root@proxmox:~# lvs
  LV      VG Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  lv_root vg -wi-ao---- 18.53g
  lv_swap vg -wi-ao----  1.00g
 
Hi,
20GB in a test-system? Sounds like an virtualized system?!

Do an fresh install on another test-system with storage lvm to see the diff. You need free space in the VG for the vm-disks (the old way).
Since a longer time, pve use lvm-thin for an local lvm-installation. With lvm-thin you can use snapshots and so on.

Udo
 
I don't use the proxmox iso, I always install proxmox manually on debian stretch.
Hey,
if you allways install manually on debian stretch, I would assume, that you have good reasons for... and know linux!
So where is the problem?

BTW. there are a lot of howtos in the web to reduce filesystems, create lvm, convert lvm to lvm-thin and so on.
There must be some post from me about lvm in this forum too - try the search function.

aboiut lvm-thin see here: https://pve.proxmox.com/wiki/LVM2#LVM-Thin

Udo
 
I think you don't really have to know linux to use apt-get update/upgrade/install.
I just install it manually because I like the cli.

I never worked with LVM before, so that's why I was asking here.

I found myself this solution now:

Step 1: Shrink the existing root LV
Because it is mounted it is not possible to resize it while proxmox is running, so you have to boot from a debian 9 live cd.
Enter the terminal ->
Code:
sudo bash
Code:
apt-get update && apt-get install lvm2 -y
use lvs to find the VG name where the root LV is located.
Code:
lvs

for me it is 'proxmox-test-lvm-vg' as VG and 'root' as LV.

Then I've checked the file system:
Code:
e2fsck -f /dev/proxmox-test-lvm-vg/root

If there are some error just press
Code:
y
to fix them.
To be safe tell debian which VG you want to operate with:
Code:
vgchange --available y proxmox-test-lvm-vg

And then finally resize the root partition:
Code:
lvreduce --resizefs --size -10G /dev/proxmox-test-lvm-vg/root
(This will shrink the root partition by 10GB, NOT to 10GB)
Then check ths fs again
Code:
e2fsck -f /dev/proxmox-test-lvm-vg/root
Code:
reboot

Step 2: Create a new LV in the VG
Code:
lvcreate -L 10G -n data proxmox-test-lvm-vg
(I use 10GB because i shrunk root by 10GB)

Step 3: Convert it to lvm-thin
Code:
lvconvert --type thin-pool proxmox-test-lvm-vg/data

Then add it via webinterface to the node.

Now I just have to find a way to move my systems which are not using lvm, I guess the easiest way is to shrink the root partition with gparted live cd and then create a VG and apply the steps above.
 
  • Like
Reactions: CLE