TurnKey Linux Virtual Appliance Library

Mounting vmdk to access the filesystem of a VM

Hello,

I am trying to accesss the file system of a turnkey. There a vmware-mount utility that is easy to use as

mkdir mount_test
vmware-mount turnkey-wordpress-11.2-lucid-x86.vmdk 1 mount_test
 

once it is mounted i was expecting to see the standard file system structure i.e /usr/ /home /bin etc but instead I see :
 


/grub
/lost+found
config-2.6.32-33-generic-pae
initrd.img-2.6.32-33-generic-pae
System.map-2.6.32-33-generic-pae
vmlinuz-2.6.32-33-generic-pae

the grub folder seems to have some linux commands

I suppose that the generic-pae files are some type of images that I also have to mount in order to access the actual files in the file system. It seems that some are the the linux kernel image, but propably some of the gereric-pae is the actual file system image.

Since I am not that experience, If anyone understands something, and can enlight me even a litle bit I would very thankfull.

Thanks in advance

Kostas


Alon Swartz's picture

If all you want is access to the rootfs, use ISO and TKLPatch

I've never used vmware-mount before, so I can't give you any tips. All I can say is its going to be a little difficult to get to the rootfs, as the VM builds contain a raw disk, which has 2 partitions, one for the boot partition and the other for the rootfs. Additionally, the rootfs is setup with LVM, having 2 VG's, one for the root, and the other swap. Everything is possible, but is it worth the effort?

Bottom line, if all you want is access to the rootfs, I'd suggest you get the ISO build, and use TKLPatch to unpack it:

apt-get update
apt-get install tklpatch
tklpatch-extract-iso /path/to/iso

When TKLPatch extracts the ISO, it will generate a cdroot (bootloader and compressed rootfs), and rootfs (the uncompressed root filesystem).

Hope the above helps.

how to

Hello Alon,

Thank you very much for your fast reply and directions.


I was able to get in the file system of the vm by just following your post up to this point :

mount /dev/mapper/$(basename $loopdev)p1 turnkey-core.mount

(http://www.turnkeylinux.org/blog/convert-vm-iso)

Wow !

Thank you for your help


mount vmdk with LVM

Hello,

if the vm's vmdk also has ..." LVM having 2 VG's, one for the root, and the other swap"...,you can access the filesystem with the following :

sudo su
cd vm
qemu-img convert -f vmdk turnkey-wordpress-11.3-lucid-x86.vmdk -O raw turnkey-core.raw

loopdev=$(losetup -s -f turnkey-core.raw)
kpartx -a $loopdev
mkdir rootfs

lvscan
#  ACTIVE            '/dev/turnkey/root' [17,00 GiB] inherit <---
#  ACTIVE            '/dev/turnkey/swap_1' [512,00 MiB] inherit

mount /dev/turnkey/root rootfs
cd rootfs

 

thanks to these posts:

http://www.turnkeylinux.org/blog/convert-vm-iso
http://pissedoffadmins.com/?p=481


Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account, used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <p> <span> <div> <h1> <h2> <h3> <h4> <h5> <h6> <img> <map> <area> <hr> <br> <br /> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <em> <b> <u> <i> <strong> <font> <del> <ins> <sub> <sup> <quote> <blockquote> <pre> <address> <code> <cite> <strike> <caption>

More information about formatting options

Leave this field empty. It's part of a security mechanism.
(Dear spammers: moderators are notified of all new posts. Spam is deleted immediately)