Migrate larger disk from local-lvm to another zfs disk

0buntu

New Member
Oct 2, 2021
8
0
1
30
Hello dears,

I have a VM with the disk capacity of 1TB. Mistakenly, I increased the disk size to 4.6TB while thinking am reducing it, which the local-lvm disk that this VM exist on is 390GB.
my request for support are
1. I want to reduce this VM size back to 1TB
2. I want to migrate this disk after reducing to a 1TB zfs disk.
Refer to picture below
1633450831847.png
 

Attachments

  • 1633450628666.png
    1633450628666.png
    53.7 KB · Views: 5
Hi,
shrinking a disk is not supported via the UI. You'll need to use qemu-img for that and make sure that within the VM, the disk is completely unused (no partition/file system) beyond the size you want to shrink it to! From the qemu-img man page:
Code:
       resize [--object OBJECTDEF] [--image-opts] [-f FMT] [--preallocation=PREALLOC] [-q] [--shrink] FILENAME [+ | -]SIZE
              Change the disk image as if it had been created with SIZE.

              Before using this command to shrink a disk image, you MUST use file system and partitioning tools inside the VM to reduce allocated file systems and partition sizes accordingly.  Failure to do so will result in data loss!

              When shrinking images, the --shrink option must be given. This informs qemu-img that the user acknowledges all loss of data beyond the truncated image's end.
Maybe try it out on some dummy disk first to get familiar with it.

To move the disk afterwards you can use the Move Disk button in the UI (when you select the VM and its Hardware panel). But from the screenshot it seems like the ZFS storage is already nearly full. Do you have enough space there?
 
Another problem is, I cannot find the actual disk location, the actual disk file to resize. my zfs is not full, infact I created it before this post.
 
Sorry, I confused the local and local-lvm storage. For LVM (thin), you need to use lvreduce rather than qemu-img. You can use lvs to list the existing volumes. The rest of what I wrote still applies, make sure the disk has no partition/file system beyond the space you reduce it to and best to try it out on a dummy volume first.
 
See for example here. Since the logical volume does not only contain a single file system, I don't think the --resizefs option will work. Instead, you need to resize the file-systems and partitions within the VM first.
 

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!