Decreasing disk size

jlgarnier

Member
May 25, 2021
29
2
23
Auriol, France
Dear Community,

I have a OpenMediaVault VM with 2 disks, the second one being used for media storage. I've changed this for an external USB drive (being able to share the drive with friends) and I now want to reduce the size of the vm-100-disk-1. Is there any method other than removing and recreating the disk?

Moreover, preparing the remove/recreate operation, I made weeks ago a backup on the disk-1 content. I remember I ssh'ed into the machine, found a vm-100-disk-1 folder and simply copying all files and folders to a my machine. Now, I wanted to make an update of these files but I just CAN'T find this folder anymore! And the VM still works fine! What's this wizardry? Can you please tell where the VM disks data are supposed to be stored onto the host machine?

Thanks in advance for any help!
 
One would need to see the output of this to tell you
Bash:
qm config 100
cat /etc/pve/storage.cfg
 
Dear Community,

I have a OpenMediaVault VM with 2 disks, the second one being used for media storage. I've changed this for an external USB drive (being able to share the drive with friends) and I now want to reduce the size of the vm-100-disk-1. Is there any method other than removing and recreating the disk?

Moreover, preparing the remove/recreate operation, I made weeks ago a backup on the disk-1 content. I remember I ssh'ed into the machine, found a vm-100-disk-1 folder and simply copying all files and folders to a my machine. Now, I wanted to make an update of these files but I just CAN'T find this folder anymore! And the VM still works fine! What's this wizardry? Can you please tell where the VM disks data are supposed to be stored onto the host machine?

Thanks in advance for any help!
Usually the vm disks are in LVM volume
Try in the shell
Code:
lvs
Alternativaly you can use a grep filter
Code:
lvs | grep 100
But like @Impact said, needs to see /etc/pve/storage.cfg to be sure how the storage layout.
 
One would need to see the output of this to tell you
Bash:
qm config 100
cat /etc/pve/storage.cfg
Thanks for your quick answer! Here are the outputs:
Code:
qm config 100

agent: 1
balloon: 4096
boot: order=scsi0;net0
cores: 4
memory: 8192
name: OMV
net0: virtio=52:45:69:61:DE:CC,bridge=vmbr0,firewall=1
numa: 0
onboot: 1
ostype: l26
scsi0: data:vm-100-disk-0,size=88G
scsi1: data:vm-100-disk-1,size=1T
scsihw: virtio-scsi-pci
smbios1: uuid=1c4088b5-3b36-4ed1-954b-25cad5c1919c
sockets: 1
usb0: host=0bc2:231a
vmgenid: 6b88eecc-e9e1-47d0-86ce-2cd065027af6

and
Code:
cat /etc/pve/storage.cfg

dir: local
        path /var/lib/vz
        content rootdir,images,vztmpl,iso
        prune-backups keep-last=5,keep-monthly=3
        shared 0

zfspool: data
        pool data
        blocksize 64k
        content images,rootdir
        mountpoint /data
        nodes LAB-server1
        sparse 1

lvmthin: local-lvm
        thinpool data
        vgname pve
        content images,rootdir
        nodes LAB-server1

dir: backups
        path /mnt/pve/backups
        content backup
        prune-backups keep-weekly=3
        shared 0
 
Since the data storage is of type ZFS the VM's disk will be of type ZVOL (block device), not a file. Check zfs list -t vol -ospace. If you want to shrink it I'd suggest you attach and boot the gparted iso and shrink the VM's file system and partition with it. Afterwards you can use zfs set volsize=xxG .... Make sure you have backups and make the partition a bit smaller than the virtual disk for now.
 
Last edited:
Thanks guys!

Actually, what is surprising is that I managed to copy the whole disk-1 content as it was a genuine HDD some weeks ago! It means, at that time (and I blame on myself for not remembering how ‍♂️), I found a path to the disk and launched a common cp command to backup all data. I didn't change anything since I made this backup so why can't I find this path again?

By the way, I'll try the gparted method. I rephrase the process, so I don't make any mistake:
  • I find the gparted iso image and upload it to PVE.
  • I attach this image to the OMV VM: don't know how...
  • I start the VM and boot on the gparted image.
  • I use the tool to shrink the disk-1 partition.
  • I shut the VM down.
  • SSH into the system and launch the zfs set volsize=256G command. I guess I should add the target drive to the command parameters...
  • I don' understand the last instruction "make the partition a bit smaller than the virtual disk for now": do you mean I should process in multiple steps, shrinking the partition by a few GB first?
Thanks again for your help!
 
  • I start the VM and boot on the gparted image.
  • I use the tool to shrink the disk-1 partition.
No! Before shrinking the partition you have to shrink the filesystem. If not, you'll damage the filesystem!
edit: or maybe gparted will take care for the filesystem as well... I don't remember.
Disclaimer: I haven't verified other steps, just spotted this one.
 
Last edited:
Basically you want volsize to be larger than the partition inside to avoid rounding differences and such. Otherwise you might destroy the data. You attach the iso on the Hardware tab.