Mounting a VM disk outside of Proxmox (in Debian)

anderstn

Member
Dec 22, 2020
23
0
6
35
Hi

Firstly sorry if this is a question that has been asked before. I tried using the search feature on the forum and also Google just in case, but didn't find a question that was this specific.

My server went down and I had to replace the motherboard. Proxmox does not like some aspect of the new board and I really don't have time or money to buy another one right now so temporarily I would like to set up some of the VM's using other options that work with the hardware I have. However I need to grab some configuration files from these VM's. Hence I am wondering if I can mount these disks somehow in a Debian live environment and grab the files I need.
 
Hi,
that depends on the disk format and what filesystems are on the disk.

For raw with a filesystem, you can just directly mount it with mount /path/to/image /path/to/mount/point.

If there are partitions, you can install kpartx and do:
Code:
root@pve8a1 ~ # kpartx -av /path/to/image
add map loop0p1 (252:23): 0 2095104 linear 7:0 2048
root@pve8a1 ~ # mount /dev/mapper/loop0p1 /path/to/mount/point
After being done and unmounting, do
Code:
root@pve8a1 ~ # kpartx -dv /path/to/image
del devmap : loop0p1
loop deleted : /dev/loop0
to clean up.

For qcow2, you can do
Code:
modprobe nbd
qemu-nbd -c /dev/nbd0 /path/to/image.qcow2
mount /dev/nbd0 /path/to/mount/point
# or for partition number 1
mount /dev/nbd0p1 /path/to/mount/point
Use fdisk -l /dev/nbd0 to check what the partitions are. After you're done, use qemu-nbd -d /dev/nbd0 to clean up.
 
  • Like
Reactions: fba
That's a great summary thanks. Do I see which of these file systems is in use via "fdisk -l" or file extensions? Alternatively can I just try the various options without the commands themselves messing up anything if it's the wrong type?
 
That's a great summary thanks. Do I see which of these file systems is in use via "fdisk -l" or file extensions? Alternatively can I just try the various options without the commands themselves messing up anything if it's the wrong type?
To see information about filesystems, wipefs /path/to/partition/or/image is best (scary name I know, but doesn't remove anything without additional flags). Mount will also try to detect the filesystem type and simply fail if it can't do anything sensible.

EDIT: Another alternative is lsblk -f /path/to/device e.g. lsblk -f /dev/loop0 and lsblk -f /dev/nbd0 in the examples above.
 
Last edited:

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!