chacham15
chacham15

Reputation: 14251

How do I extract a file out of a virtual disk?

Given a block of data (which the filesystem thinks is the whole drive) and the type of filesystem (fat32, ntfs, ext3) I would like to know how to extract files out of that block of data. Any ideas on how to do this?

Upvotes: 1

Views: 1097

Answers (2)

cdhowie
cdhowie

Reputation: 168988

You ultimately have two options:

  1. Mount the filesystem contained in the virtual disk image on the host machine. Tools like losetup can be helpful to accomplish this.
  2. Find an appropriate library that will allow you to poke at the volume in userspace. Basically, you want a user-mode filesystem driver that will let a program inspect the directory structure and extract files. You might be able to repurpose parts of fuse-ext2 and ntfs-3g.

This all assumes that the virtual disk is just a flat image file, not a specialized container like VMDK or VDI. If it is, you'll either need to extract the flat image or find a library that is capable of providing the flat content to other libraries.

Upvotes: 2

glglgl
glglgl

Reputation: 91017

You mount it to some point using

mount image /mount/point -o loop,ro

and access the files in it. Afterwards, you can unmount again.

But I do not understan what this has to do with C or C++.

Upvotes: 0

Related Questions