Skip to content

Instantly share code, notes, and snippets.

@ILMostro
Forked from shamil/mount_qcow2.md
Created April 16, 2022 21:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ILMostro/fa0d690d92d1f947a0820310512f1d28 to your computer and use it in GitHub Desktop.
Save ILMostro/fa0d690d92d1f947a0820310512f1d28 to your computer and use it in GitHub Desktop.
How to mount a qcow2 disk image

How to mount a qcow2 disk image

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/somepoint/

Step 5 - After you done, unmount and disconnect

umount /mnt/somepoint/
qemu-nbd --disconnect /dev/nbd0
rmmod nbd
@ILMostro
Copy link
Author

ILMostro commented Apr 16, 2022

== To clear a windows (10/8/7) password ==

Mount the main (usually biggest) partition

mount /dev/nbd0p2 /mnt/winblo

Change to the appropriate directory

cd /mnt/winblo/Windows/System32/config/

List the available users in the SAM database

chntpw -l SAM

Use chntpw to clear the password

chntpw -i SAM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment