Skip to content

Instantly share code, notes, and snippets.

@dieechtenilente
Created December 18, 2023 20:49
Show Gist options
  • Save dieechtenilente/204129bff2528a485bc4c226518049de to your computer and use it in GitHub Desktop.
Save dieechtenilente/204129bff2528a485bc4c226518049de to your computer and use it in GitHub Desktop.
Mount a qcow2 Image with LVM on Ubuntu/Debian

Enable kernel extension

modprobe nbd max_part=8

Mount qcow2-Image

qemu-nbd --connect=/dev/nbd0 /var/lib/image.qcow2

or if the image is read-onlyy (e.g. from a snapshot)

qemu-nbd --connect=/dev/nbd0 /var/lib/image.qcow2 --read-only

Scan for volume groups

vgscan

Get the correct partition/logical volume

fdisk -l /dev/nbd0

Mount the lv

mount -o ro,noload  /dev/ubuntu-vg/ubuntu-lv /mnt

Done.

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