doc: documented how to mount a qcow2 image

This commit is contained in:
missytake 2024-12-04 14:43:13 +01:00
parent ec8ff87799
commit c26102b3f6
Signed by: missytake
GPG key ID: 04CC6658320518DF

View file

@ -303,3 +303,41 @@ Finally, I ran `mkfs.ext4`
to create an ext4 file system
in the encrypted partition.
# mount qcow2 VM disk images
This is a quick guide to mounting a qcow2 disk images on your host server. This is useful to reset passwords,
edit files, or recover something without the virtual machine running.
**Step 1 - Enable NBD on the Host**
```
modprobe nbd max_part=8
```
**Step 2 - Connect the QCOW2 as network block device**
```
qemu-nbd --connect=/dev/nbd0 /var/lib/vz/images/100/vm-100-disk-1.qcow2
```
**Step 3 - Find The Virtual Machine Partitions**
```
fdisk /dev/nbd0 -l
```
**Step 4 - Mount the partition from the VM**
```
mount /dev/nbd0p1 /mnt
```
**Step 5 - After you are done, unmount and disconnect**
```
umount /mnt/somepoint/
qemu-nbd --disconnect /dev/nbd0
rmmod nbd
```