Location of Disk Images in Local-LVM

aithorusa

New Member
Jan 17, 2021
3
1
1
27
I'm a beginner and a newbie still learning the ropes. Please excuse my inability to grasp some key concepts quickly and my lack of knowledge.
I want to find out where the raw, qcow2 or vhd files are stored in a local-lvm storage. I used WinSCP to look at the contents and dev/pve contains "shortcuts" of the disk files. However, when I download them, they are not in any readable format.
In "local" Dump, ISO Image and Container template is stored and it shows me the path too (/var/lib/vz/). In local-lvm, the disk image and container is stored however there is no path there. How can I get the vhd or qcow of the VMs stored in local-lvm?
 
Last edited:
Hi, what method are you using to download the images?
These files on local-lvm are actually block devices on the system, so you would first need to copy the contents into an image file that you could then download, if that's your goal.

You could use thedd command [1,2] to achieve this (note: shutdown the relevant VM first).

First, find the path of the disk with the command:
pvesm path local-lvm:vm-<VMID>-disk-<NUM>

Then use dd to copy its contents to a file, for example
dd if=/dev/pve/vm-1140-disk-0 of=~/vm-1140-disk-0.raw

[1] https://man7.org/linux/man-pages/man1/dd.1.html
[2] https://www.geeksforgeeks.org/dd-command-linux/
 
Last edited:
Hi, what method are you using to download the images?
These files on local-lvm are actually block devices on the system, so you would first need to copy the contents into an image file that you could then download, if that's your goal.

You could use thedd command [1,2] to achieve this (note: shutdown the relevant VM first).

First, find the path of the disk with the command:
pvesm path local-lvm:vm-<VMID>-disk-<NUM>

Then use dd to copy its contents to a file, for example
dd if=/dev/pve/vm-1140-disk-0 of=~/vm-1140-disk-0.raw

[1] https://man7.org/linux/man-pages/man1/dd.1.html
[2] https://www.geeksforgeeks.org/dd-command-linux/
That is quite useful, thank you very much.

I was downloading the block files using WinSCP and saving them in my PC. However, that wasn't really getting me anywhere since they're not readable like that. Your method did get me the raw file which I can now use in a converter and have it in VHD format.

I've come across this but I haven't quite grasped the concept yet: mounting the LVM volumes. Will mounting the lvm volumes in /dev/pve make it more feasible and efficient to get the .raw files of the volumes? If so, how can I mount them? I need about 15 .raw or .vhd files of the VMs that are running in Proxmox at the moment.

Once again, thank you very much for your reply.
 
Another option would be to go to hardware view of your VMs and use the move disk button to (temporarily) move the disk images to a directory based storage (for example, "local"). Depending on your choice (in the dialogue that opened when you clicked the button) of output format your disk images will then be available as raw, qcow2 or vmdk on the path of your directory storage (/var/lib/vz/images for "local"). However, with this way you have to pay more attention to attach and detach the correct disks than with dylanw's method.
 
Last edited:
  • Like
Reactions: supotnickiy
Another option would be to go to hardware view of your VMs and use the move disk button to (temporarily) move the disk images to a directory based storage (for example, "local"). Depending on your choice (in the dialogue that opened when you clicked the button) of output format your disk images will then be available as raw, qcow2 or vmdk on the path of your directory storage (/var/lib/vz/images for "local"). However, with this way you have to pay more attention to attach and detach the correct disks than with dylanw's method.
I tried doing that and when I use qemu.img convert to change it to vhd, the size is cut to almost half. I have a 10GB qcow2 file which is reduced to almost 6GB. If my assumption is right, it has something to do with sparse and how lvm volumes are stored. If so, how can I make sure that I don't lose anything and the vhd's size remains the same so that when I attach it again, I still get a 10GB VM
 
  • Like
Reactions: supotnickiy
Sorry for my delayed response. May I ask what your end goal is or why it is that you need to copy all the raw files? Could it be that cloning [1] or backup [2] is what you're trying to achieve?

I've come across this but I haven't quite grasped the concept yet: mounting the LVM volumes. Will mounting the lvm volumes in /dev/pve make it more feasible and efficient to get the .raw files of the volumes? If so, how can I mount them? I need about 15 .raw or .vhd files of the VMs that are running in Proxmox at the moment.
The purpose of mounting is generally to attach filesystems [3] to your machine. If you mean that you want to add an existing LVM volume group to the system, redhat provide a guide on that [4]. Otherwise the block devices in the lvm aren't something located in a filesystem. Thus, there is no way to simply mount an LVM volume and access some directory containing images.

I have a 10GB qcow2 file which is reduced to almost 6GB. If my assumption is right, it has something to do with sparse and how lvm volumes are stored. If so, how can I make sure that I don't lose anything and the vhd's size remains the same so that when I attach it again, I still get a 10GB VM
Yes exactly. This size reduction will not result in lost data, it's just a case that it's only storing used data.

[1] https://pve.proxmox.com/pve-docs/pve-admin-guide.html#qm_copy_and_clone
[2] https://pve.proxmox.com/pve-docs/pve-admin-guide.html#chapter_vzdump
[3] https://tldp.org/LDP/sag/html/filesystems.html
[4] https://access.redhat.com/documenta...logical_volume_manager_administration/vg_move
 
  • Like
Reactions: supotnickiy

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!