How to store backups on same physical disk, but NOT on root partition - maybe its own LV?

teeeeee

New Member
Feb 1, 2023
26
2
3
I have a 128 GB internal SSD disk on my machine, and have installed a fresh Proxmox with the following setup:
  • 16 GiB for the Proxmox OS root (set using the maxroot parameter during installation)
  • 7.58 GiB allocated to SWAP
  • 32 GiB allocated to VM-100
It seems that the proxmox installer has already created an LVM-Thin section, allocating almost all of the remaining space of size 83.65 GB (88% "assigned to LVs"). Not sure why.

Immediately after creating the 32 GiB VM, then 5.26 GB of space is used in LVM-Thin.

After doing a backup of VM-100 to "local", I can see that the size of the backup file is 1.5 GB (the total disk usage of the 16 GB root partition has increased from 3.6GB to 5.1GB). This backup is currently stored on the root partition at /var/lib/vz/dump.

I would like to keep the storage of the backups separate from the 16 GB root partition (but still on the same physical disk), thus keeping the 16 GB partition for the Proxmox OS only. This is because I don't like the idea of the root partition getting full if backups increase. Ideally, I would like to keep my 16 GB for the root, with maybe another 16 GB for backups, and the rest for VM disks. Would it make sense to carve out some new storage from the 83.65 GB LVM-Thin, and use this for backups? If so, how do you do this?

Note:
  • I am not concerned that my backups are on the same internal disk as the OS (I plan to copy the backups periodically to a connected external drive as well, for redundancy, but want a copy on the internal disk in case the external one fails)
  • I am not concerned about storage of ISO files (I plan to delete them immediately after use, and not store them)

Some outputs with disk information:

Code:
root@proxmox:~# pvs
  PV         VG  Fmt  Attr PSize    PFree
  /dev/sda3  pve lvm2 a--  <118.24g 14.75g
root@proxmox:~# vgs
  VG  #PV #LV #SN Attr   VSize    VFree
  pve   1   5   0 wz--n- <118.24g 14.75g
root@proxmox:~# lvs
  LV            VG  Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  data          pve twi-aotz-- 77.90g             4.98   1.70                           
  root          pve -wi-ao---- 16.00g                                                   
  swap          pve -wi-ao----  7.58g                                                   
  vm-100-disk-0 pve Vwi-aotz--  4.00m data        0.00                                   
  vm-100-disk-1 pve Vwi-aotz-- 32.00g data        12.13


Code:
root@proxmox:~# df -h
Filesystem            Size  Used Avail Use% Mounted on
udev                  3.8G     0  3.8G   0% /dev
tmpfs                 777M  948K  776M   1% /run
/dev/mapper/pve-root   16G  3.7G   12G  25% /
tmpfs                 3.8G   34M  3.8G   1% /dev/shm
tmpfs                 5.0M     0  5.0M   0% /run/lock
efivarfs              128K   73K   51K  60% /sys/firmware/efi/efivars
/dev/fuse             128M   16K  128M   1% /etc/pve
tmpfs                 777M     0  777M   0% /run/user/0


Code:
root@proxmox:~# fdisk -l
Disk /dev/sda: 119.24 GiB, 128035676160 bytes, 250069680 sectors
Disk model: TOSHIBA THNSNF12
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: gpt
Disk identifier: A6B9BBB2-89EF-4F40-B901-9B2B5ACF66E3

Device       Start       End   Sectors   Size Type
/dev/sda1       34      2047      2014  1007K BIOS boot
/dev/sda2     2048   2099199   2097152     1G EFI System
/dev/sda3  2099200 250069646 247970447 118.2G Linux LVM


Disk /dev/mapper/pve-swap: 7.58 GiB, 8141144064 bytes, 15900672 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


Disk /dev/mapper/pve-root: 16 GiB, 17179869184 bytes, 33554432 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


Disk /dev/mapper/pve-vm--100--disk--0: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 65536 bytes / 65536 bytes


Disk /dev/mapper/pve-vm--100--disk--1: 32 GiB, 34359738368 bytes, 67108864 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 65536 bytes / 65536 bytes
Disklabel type: gpt
Disk identifier: 24F2D7C1-CFAC-4E79-B9E4-4F3FDEADD112

Device                                   Start      End  Sectors  Size Type
/dev/mapper/pve-vm--100--disk--1-part1    2048    67583    65536   32M EFI System
/dev/mapper/pve-vm--100--disk--1-part2   67584   116735    49152   24M Linux filesystem
/dev/mapper/pve-vm--100--disk--1-part3  116736   641023   524288  256M Linux filesystem
/dev/mapper/pve-vm--100--disk--1-part4  641024   690175    49152   24M Linux filesystem
/dev/mapper/pve-vm--100--disk--1-part5  690176  1214463   524288  256M Linux filesystem
/dev/mapper/pve-vm--100--disk--1-part6 1214464  1230847    16384    8M Linux filesystem
/dev/mapper/pve-vm--100--disk--1-part7 1230848  1427455   196608   96M Linux filesystem
/dev/mapper/pve-vm--100--disk--1-part8 1427456 67108830 65681375 31.3G Linux filesystem

image.png
image(1).png
 
Okay I figured out how to do this.

After install, the installer creates a volume group called "pve". The volume group "pve" is split into x3 logical volumes (LVs) by default. On my system, it looks like this:

root LV 16 GiB = 17.18 GB
swap LV 7.58 GiB = 8.14 GB
data LV 77.9 GiB = 83.64 GB

By default, the "data" LV-Thin volume is 77.9 GiB on my system, so first job is to shrink this. Apparently, according to this post:
"LVM only supports the extension of thin pools, you cannot shrink them. Otherwise, you would have to backup the contents of the thin pool and then delete and recreate it with less space."
First, stop all VMs, back them up, then destroy them.

Then delete the data volume:
Code:
lvremove pve/data

Then create a new one, I have made it 50 GiB:
Code:
lvcreate -L 50G --name data pve
Then convert the new volume to a thin pool:
Code:
lvconvert --type thin-pool pve/data
Add the new thin pool back as a storage in Proxmox, so it appears in the GUI:
Code:
pvesm add lvmthin local-lvm --thinpool data --vgname pve --content rootdir,images
Now we have reduced the thin pool size, and have freed up some space on the local drive. We can create a new LV now for backups. I have made it 16 GiB:
Code:
lvcreate -L 16G --name backups_internal pve

Now create a file system on this new volume:
Code:
mkfs.ext4 /dev/pve/backups_internal

It appears correctly:
Code:
root@proxmox:~# lvs
  LV               VG  Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  backups_internal pve -wi-ao---- 16.00g                                                    
  data             pve twi-a-tz-- 50.00g             0.00   10.44                           
  root             pve -wi-ao---- 16.00g                                                    
  swap             pve -wi-ao----  7.58g

And finally mount it onto the host file system, and make sure it always mounts on boot up:
Code:
mkdir /mnt/backups_internal
mount -t ext4 /dev/pve/backups_internal /mnt/backups_internal/
echo '/dev/pve/backups_internal /mnt/backups_internal/ ext4 defaults 0 2' >> /etc/fstab
Now I have a 16 GiB partition mounted on the system:
Code:
root@proxmox:~# df -Th
Filesystem                       Type      Size  Used Avail Use% Mounted on
udev                             devtmpfs  3.8G     0  3.8G   0% /dev
tmpfs                            tmpfs     777M  1.1M  776M   1% /run
/dev/mapper/pve-root             ext4       16G  3.7G   12G  25% /
tmpfs                            tmpfs     3.8G   34M  3.8G   1% /dev/shm
tmpfs                            tmpfs     5.0M     0  5.0M   0% /run/lock
efivarfs                         efivarfs  128K   61K   63K  49% /sys/firmware/efi/efivars
/dev/fuse                        fuse      128M   16K  128M   1% /etc/pve
tmpfs                            tmpfs     777M     0  777M   0% /run/user/0
/dev/mapper/pve-backups_internal ext4       16G   24K   15G   1% /mnt/backups_internal
And it appears in the GUI storage, so can be used to set up backups:

1729004321999.png

This is nice now, because the backups are separate from the root partition, and so if it becomes full then no bad things can happen :)
 

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!