Mounting vmdk on linux

Mount VMWare Disk Images Under Linux

Is it still possible to mount VMWare disk images under Linux? I found the following two articles, both of them recommend to use kpartx -av diskimage-flat.vmdk . However both the articles are old and, when I try it on my Ubuntu Utopic 14.10, it no longer works any more.

$ sudo kpartx -av MyWin81.vmdk $ sudo ls /dev/mapper/loop* | wc -l ls: cannot access /dev/mapper/loop*: No such file or directory 0 

Disclosure: My VMWare disk image IS a flat disk image. Furthermore (before you recommend loop mount), it is a multi-partition disk image, with first partition being Window8 and next two in Linux. It is the next two Linux partitions that I’m more interested to work on. Can someone confirm please? Thanks. Mount Flat VMWare Disk Images Under Linux http://cromoteca.com/en/blog/mountflatvmwarediskimagesunderlinux/ Mount a VMware virtual disk (.vmdk) file on a Linux box http://www.commandlinefu.com/commands/view/12554/mount-a-vmware-virtual-disk-.vmdk-file-on-a-linux-box UPDATE: vmware-mount looks very promising, but I can’t get it working yet:

$ vmware-mount -p Win81.vmdk VixDiskLib: Invalid configuration file parameter. Failed to read configuration file. Nr Start Size Type Id Sytem -- ---------- ---------- ---- -- ------------------------ 1 2048 78643200 BIOS 7 HPFS/NTFS 2 78645248 6039552 BIOS 83 Linux 3 84684800 41144320 BIOS 83 Linux % vmware-mount Win81.vmdk 1 /mnt/tmp1/ VixDiskLib: Invalid configuration file parameter. Failed to read configuration file. Failed to mount partition 1 of disk 'Win81.vmdk' on '/mnt/tmp1/': Insufficient permissions to perform this operation % vmware-mount -L VixDiskLib: Invalid configuration file parameter. Failed to read configuration file. No mounted disks. $ vmware-mount | head -3 VixDiskLib: Invalid configuration file parameter. Failed to read configuration file. VMware DiskMount Utility version 6.0.0, build-2496824 Usage: vmware-mount diskPath [partition num] mountPoint 

NB, the 2nd and 3rd command is run directly as root , yet I get «Insufficient permissions to perform this operation«?

Источник

Overview

vmdk ’s, the underlying filesystem commonly used in vmware , can be mounted on a Linux server using the qemu utilities. In this example, I downloaded an ova , unarchived it, and retrieved the vmdk files. Once exposed, I am able to mount the filesystems embedded within the vmdk .

In this example, the ova is a virtual “appliance” which prohibits access a low level root shell. By mounting the vmdk file system directly, we can take a peek at the hidden secrets the vendor keeps under lock and key.

Details

sudo apt install qemu-utils 

Load the network block device module:

jemurray@home-server:~/ib$ sudo modprobe nbd 

Create the network block devices from the vmdk image:

jemurray@home-server:~/ib$ sudo qemu-nbd -r -c /dev/nbd1 ./vnios-disk.vmdk 

Examine the images qemu created:

jemurray@home-server:~/ib$ ls -al /dev/nbd1p* brw-rw---- 1 root disk 43, 33 Jan 9 14:28 /dev/nbd1p1 brw-rw---- 1 root disk 43, 34 Jan 9 14:28 /dev/nbd1p2 brw-rw---- 1 root disk 43, 35 Jan 9 14:28 /dev/nbd1p3 brw-rw---- 1 root disk 43, 36 Jan 9 14:28 /dev/nbd1p4 brw-rw---- 1 root disk 43, 37 Jan 9 14:28 /dev/nbd1p5 brw-rw---- 1 root disk 43, 38 Jan 9 14:28 /dev/nbd1p6 brw-rw---- 1 root disk 43, 39 Jan 9 14:28 /dev/nbd1p7 

Create mount points for the new filesystems:

jemurray@home-server:~/ib$ mkdir p1 jemurray@home-server:~/ib$ mkdir p2 jemurray@home-server:~/ib$ mkdir p3 jemurray@home-server:~/ib$ mkdir p4 jemurray@home-server:~/ib$ mkdir p5 jemurray@home-server:~/ib$ mkdir p6 jemurray@home-server:~/ib$ mkdir p7 

Attempt to mount each individual directory:

jemurray@home-server:~/ib$ sudo mount /dev/nbd1p1 ./p1 mount: /home/jemurray/ib/p1: WARNING: device write-protected, mounted read-only. jemurray@home-server:~/ib$ sudo mount /dev/nbd1p2 ./p2 mount: /home/jemurray/ib/p2: WARNING: device write-protected, mounted read-only. jemurray@home-server:~/ib$ sudo mount /dev/nbd1p3 ./p3 NTFS signature is missing. Failed to mount '/dev/nbd1p3': Invalid argument The device '/dev/nbd1p3' doesn't seem to have a valid NTFS. Maybe the wrong device is used? Or the whole disk instead of a partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around? jemurray@home-server:~/ib$ sudo mount /dev/nbd1p4 ./p4 mount: /home/jemurray/ib/p4: WARNING: device write-protected, mounted read-only. jemurray@home-server:~/ib$ sudo mount /dev/nbd1p5 ./p5 mount: /home/jemurray/ib/p5: WARNING: device write-protected, mounted read-only. jemurray@home-server:~/ib$ sudo mount /dev/nbd1p6 ./p6 mount: /home/jemurray/ib/p6: WARNING: device write-protected, mounted read-only. jemurray@home-server:~/ib$ sudo mount /dev/nbd1p7 ./p7 mount: /home/jemurray/ib/p7: unknown filesystem type 'swap'. 
jemurray@home-server:~/ib/p1$ ls -al total 104 drwxr-xr-x 23 root root 4096 Oct 8 12:42 . drwxrwxr-x 9 jemurray jemurray 4096 Jan 9 14:31 .. drwxr-xr-x 2 root root 4096 Oct 8 12:41 bin drwxr-xr-x 4 root root 4096 Oct 8 12:42 boot drwxr-xr-x 4 root root 4096 Oct 8 12:41 dev drwxr-xr-x 29 root root 4096 Oct 8 12:42 etc drwxr-xr-x 2 root root 4096 Oct 8 12:41 home drwxr-xr-x 7 root root 4096 Oct 8 12:42 lib drwx------ 2 root root 16384 Oct 8 12:58 lost+found drwxr-xr-x 5 root root 4096 Oct 8 12:41 media drwxr-xr-x 2 root root 4096 Oct 8 12:41 mnt 

Источник

Читайте также:  Права на папку linux 777

How to mount VMDK-image in Linux

Понадобилось мне Windows в эмуляторе VirtualBox поставить, выбрал VMDK. Теперь хочу вытащить файлы оттуда, подмонтировав VMDK-образ в Дебиане. Пока вижу такой путь: qemu-img convert . && mount -o ro,loop .

Есть ли какой-то другой способ? Утилита xmount, по-моему, такого не умеет.

# qemu-img --help qemu-img version 1.1.2 . Supported formats: vvfat vpc vmdk vdi sheepdog raw host_cdrom host_floppy host_device file qed qcow2 qcow parallels nbd iscsi dmg tftp ftps ftp https http cow cloop bochs blkverify blkdebug

у тебя qemu за сентябрь 2012 года.

В общем, я решил простым способом — конвертировал образ в raw, затем

# fdisk -l hdd.raw # mount -o loop,ro,offset= hdd.raw VBox/

Просто интересовали какие-то прямые способы без конвертации. Я нашёл упоминание, что есть проприетарные утилиты для этого под Windows, MacOS (от VMWare).

Странно, что ты не вбил заголовок треда в гугл, вопрос сформулирован абсолютно правильно. И самый первый линк в выдаче дал

sudo mount vmware-server-flat.vmdk /tmp/test/ -o ro,loop=/dev/loop1,offset=32768 -t ntfs

Mount a VMware virtual disk (.vmdk) file on a Linux box

Assumes XP/2000/2003. For Server 2008+ try offset=105,906,176 You can find this number in the System Information utility under Partition Starting Offset. UEFI based boxes you want partition 2 since the first is just the boot files (and FAT). This works with (storage side) snapshots which is handy for single file restores on NFS mounted VMware systems

И кучу альтернативных вариантов, без ожидания кучи времени на конвертацию.

И кстати, за это я не люблю Дебиан, полный древними ископаемыми. Взглянув на версии софта, так и хочется заменить «ШГ» на «УГ» рядом со словом Debian на твоей аве.

Читайте также:  Ia32 libs astra linux

fehhner ★★★★★ ( 24.11.16 02:15:16 MSK )
Последнее исправление: fehhner 24.11.16 02:18:08 MSK (всего исправлений: 1)

Источник

Mounting VMDK disk image

I have a single vmware disk image file with vmdk extension I am trying to mount this and explore all of the partitions (including hidden ones). I’ve tried to follow several guides, such as : http://forums.opensuse.org/showthread.php/469942-mounting-virtual-box-machine-images-host I’m able to mount the image using vdfuse

vdfuse -w -f windows.vmdk /mnt/ 
# ll /mnt/ total 41942016 -r-------- 1 te users 21474836480 Feb 28 14:16 EntireDisk -r-------- 1 te users 1569718272 Feb 28 14:16 Partition1 
mount -o loop,ro /mnt/Partition1 mnt2/ 

But that gives me the error ‘mount: you must specify a filesystem type’ In trying to find the correct type I tried

dd if=/mnt/EntireDisk | file - which outputs a ton of information but of note is: /dev/stdin: x86 boot sector; partition 1: . FATs . 
mount: wrong fs type, bad option, bad superblock . etc 

Did you try ntfs? Did you try fdisk /mnt/EntireDisk or gparted /mnt/EntireDisk and looking at the partitions there? Do they show up correctly?

fdisk returned: ‘WARNING: GPT detected on ‘. ‘. The util fdisk doesnt support GPT’. gparted is able to show me there are 4 partitions but all fail to initalize. It lists several required packages for ntfs and fat32 that i might need so I’ll install those and see if it gets me anything

Also, you might want to move this question over to serverfault.com, I bet you would get more help there as this isn’t really a software dev or computer science question.

I saw a lot of solution, but finally I use the simple solution: add the VMDK file to an existed linux VM. Boot to that VM and mount the partition normally. You can use GUI tool to mount (such as gnome-disks in gnome) or mount command line

6 Answers 6

For newer Linux systems, you can use guestmount to mount the third partition within a VMDK image:

guestmount -a xyz.vmdk -m /dev/sda3 --ro /mnt/vmdk 

Alternatively, to autodetect and mount an image (less reliable), you can try:

guestmount -a xyz.vmdk -i --ro /mnt/vmdk 

Do note that the flag —ro simply mounts the image as read-only; to mount the image as read-write, just replace it with the flag —rw .

Читайте также:  Отключить контроллер usb linux

Installation

guestmount is contained in following packages per distro:

  • Ubuntu: libguestfs-tools
  • OpenSuse: guestfs-tools
  • CentOS / Fedora: libguestfs-tools-c

Troubleshooting

error: could not create appliance through libvirt

$ guestmount -a file.vmdk -i --ro /mnt/guest libguestfs: error: could not create appliance through libvirt. Try running qemu directly without libvirt using this environment variable: export LIBGUESTFS_BACKEND=direct Original error from libvirt: Cannot access backing file '/path/to/file.vmdk' of storage file '/tmp/libguestfssF6WKX/overlay1.qcow2' (as uid:107, gid:107): Permission denied [code=38 int1=13] 

Solution: use LIBGUESTFS_BACKEND=direct , as suggested:

LIBGUESTFS_BACKEND=direct guestmount -a file.vmdk -i --ro /mnt/guest 

fusermount: user has no write access to mountpoint

LIBGUESTFS_BACKEND=direct guestmount -a file.vmdk -i --ro /mnt/guest/ fusermount: user has no write access to mountpoint /mnt/guest libguestfs: error: fuse_mount failed: /mnt/guest/, see error messages above 

Solution: use sudo , or change file permissions on the mountpoint

Источник

How to mount a virtual hard disk?

Have you searched Google? It abounds with guides on mounting VMDK, VDI, VHD, and raw disk image files on Ubuntu.

4 Answers 4

Linux and other Unix-like hosts can mount images created with the raw format type using a loopback device. From a root login (or using sudo), mount a loopback with an offset of 32,256.

mount -o loop,offset=32256 /path/to/image.img /mnt/mountpoint 

For other types of qemu images, you can use qemu-nbd

modprobe nbd max_part=16 qemu-nbd -c /dev/nbd0 image.qcow2 partprobe /dev/nbd0 mount /dev/nbd0p1 /mnt/image 

Plus, usually, you can convert image from one format to another.

raw - (default) the raw format is a plain binary image of the disc image, and is very portable. On filesystems that support sparse files, images in this format only use the space actually used by the data recorded in them. cloop - Compressed Loop format, mainly used for reading Knoppix and similar live CD image formats cow - copy-on-write format, supported for historical reasons only and not available to QEMU on Windows qcow - the old QEMU copy-on-write format, supported for historical reasons and superseded by qcow2 qcow2 - QEMU copy-on-write format with a range of special features, including the ability to take multiple snapshots, smaller images on filesystems that don't support sparse files, optional AES encryption, and optional zlib compression vmdk - VMware 3 & 4, or 6 image format, for exchanging images with that product vdi - VirtualBox 1.1 compatible image format, for exchanging images with VirtualBox. 

I found this solution for (VirtualBox) .VDI when I searched, on this website:

modprobe nbd max_part=16 qemu-nbd -c /dev/nbd0 /path/to/some.vdi mount -o loop /dev/nbd0p1 /mnt # do stuff umount /mnt qemu-nbd -d /dev/nbd0 rmmod nbd 

The same as «Qemu’s way» commands. No borders!

Источник

Оцените статью
Adblock
detector