T
T
tyoma_koder2022-03-17 08:42:32
QEMU
tyoma_koder, 2022-03-17 08:42:32

How to unpack all files from qcow2?

Installed qemu, I can't figure out how to unpack all files from qcow2

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2022-03-18
@jcmvbkbc

qcow2 is a block device representation format, it has no files, it can have a filesystem or partitions with filesystems. You can turn qcow2 into a regular raw image with qemu-img : qemu-img dd -O raw if=file.qcow2 of=file.raw.
The resulting raw image can be analyzed by standard means. If there is one file system, you can simply mount it via loop: mkdir fs ; sudo mount file.raw fs. If there is a partition table, you can use some kpartx to create devices for each of the partitions and mount the ones you need:

$ mkdir fs ; sudo kpartx -av file.raw 
add map loop0p1 (254:4): 0 65536 linear 7:0 2048
add map loop0p2 (254:5): 0 2029568 linear 7:0 67584
$ sudo mount /dev/mapper/loop0p2 fs

Naturally, if on some LVM or LUKS partitions you have to do additional gestures to get to the files.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question