kpartx-like tool for Windows?

1

0

I am trying to mount an encrypted (TrueCrypt/VeraCrypt) volume from inside a .vmdk file (VMware disk). Is there any tool in Windows (7 through 10) or a third-party tool that'd let me attach the disk in order for the Volume Manager to discover the volumes on it, such that TrueCrypt/VeraCrypt subsequently show these volumes for selection?

Please note that I'm aware of the ability to mount volumes from inside a .vmdk file. But this is not what I am asking. Because the mounting has to be done by TrueCrypt/VeraCrypt I need to be able for these programs to "see" the volume. So the .vmdk should be made available in a similar fashion to how any partitioned physical disk would be made available ("attached") to a Windows system.


Of course I am referring to the kpartx -a ... functionality.

0xC0000022L

Posted 2017-09-12T16:29:24.447

Reputation: 5 091

2It's not clear to me what you're asking. Are you saying that you encrypted a partition (or drive) of a virtual disk with TrueCrypt/VeraCrypt, or you have TrueCrypt/VeraCrypt encrypted container (a .tc/.hc file) that resides on a virtual disk? I presume you mean the former. I have not tested it myself, but have you tried mounting the .vmdk as a drive on the host first? – jamesdlin – 2017-09-14T19:52:37.793

@jamesdlin I don't have a container/file, but a partition/volume. Yes, I have tried it and VMware will only let me mount the volumes inside the .vmdk. Obviously you can't mount an encrypted volume directly but instead have to use TrueCrypt/VeraCrypt. kpartx on Linux (as well as losetup) lets you connect images containing partition tables and partitions and makes them available to the system this way. This is the functionality I'd need, because I need TrueCrypt/VeraCrypt to be able to see the partitions so that I can mount the partition/volume via it. – 0xC0000022L – 2017-09-15T08:34:36.483

Essentially the issue with this kind of volumes is that they need to be known to the volume manager prior to being mounted by TrueCrypt/VeraCrypt. – 0xC0000022L – 2017-09-15T08:39:20.527

Not that it helps, but as I see it, the problem is VeraCrypt will only enumerate physical disks/partitions to mount, so even if you mount the partition in the .vmdk with VMware's disk mounting tool, it won't be listed by VeraCrypt. Doh. – jamesdlin – 2017-09-15T11:05:11.723

Is it feasible to do the mounting from the host, then share the mounted volume? – harrymc – 2018-07-31T15:46:17.503

@harrymc not sure what you mean. But I am actually after being able to mount such a volume contained inside a VMDK from the host (i.e. the Windows system on which VMware Workstation runs). The missing link at this point seems to be to make the VMDK available in some fashion so that the volume mount manager can see the contained volume. – 0xC0000022L – 2018-07-31T16:13:41.730

Do you mean that your problem is that you have mounted a TrueCrypt/VeraCrypt volume in the VM and you want to expose it to the host or to the network, which is just the opposite of Shared Folders? If the volume is file-based, why can't you share the file itself and mount it on the host? Or do you want the mounted volume available in both host and guest in parallel? Is sharing the volume as a network share an acceptable solution? – harrymc – 2018-07-31T19:00:58.593

1@harrymc No, I have a Windows host and to stress the main point let's assume that I have not even installed VMware Workstation on it. Now I have a VMDK file which contains a number of volumes (i.e. partitions). I want to be able to see the volumes from the VMDK as devices on my Windows host in order to hand it to VeraCrypt and mount the encrypted volume. That is: any tool that attempts to mount the contained volume automatically is of no help as it would "see" the volume merely as raw. So it would perhaps get a drive letter but be inaccessible to Explorer and VeraCrypt for mounting. – 0xC0000022L – 2018-07-31T19:22:42.843

1

If you wish to just mount a vmdk file see for example these solutions, although you can only mount one partition at a time.

– harrymc – 2018-07-31T20:02:57.047

@harrymc thanks for the pointers, except for OSFMount I had tried all of them. I just tried OSFMount and it has the same issue. All of these tools attempt to mount the partitions from the disk rather than simply making the disk available in a fashion that will make the contained partitions/volumes visible to VeraCrypt. Well, actually OSFMount lets me also mount the entire disk instead of individual volumes, but the result is that it's seen as an unformatted (or raw) disk as well. In conclusion VeraCrypt cannot mount the contained volume this way. – 0xC0000022L – 2018-07-31T20:22:36.003

I think we are getting nearer to understanding the problem. Is this a VeraCrypt rawdisk? – harrymc – 2018-07-31T20:33:02.823

It's an encrypted volume which VeraCrypt understands how to mount, yes. Alas, because there's seemingly no way to attach the VMDK as a disk (as opposed to attaching individual volumes contained therein), which is a different device stack, I have no way of accessing that encrypted volume on Windows other than by attaching it as virtual disk to some VM and running that VM. It really is inside my question, even after re-reading it now. But I just found something that may provide the solution. If it works, I'll post my own answer Q&A-style. – 0xC0000022L – 2018-07-31T20:53:09.603

1

This might help : Install the Virtual Disk Development Kit (VDDK) which may install the utility vmware-mount [driveletter:] [path-to-vmdk] [options].

– harrymc – 2018-07-31T21:17:02.393

Maybe the downvote was because your post is too short and hard to understand. It has taken me a long time to understand the problem. You might try to clarify and perhaps give more details. – harrymc – 2018-07-31T21:26:09.260

@0xC0000022L - You shouldn't accuse people of downvoting your question, because in this case, you are accusing the incorrect person. A single downvote should be treated as an anomaly anyways. – Ramhound – 2018-07-31T21:26:36.430

@Ramhound I wasn't accusing, I was assuming. Wrongly, as it seems. But again, I don't care about the downvote, because - from where I stand - it arose from a misunderstanding of my question. No matter who downvoted. Besides I'm grateful harrymc inquired like that, as it motivated me to research anew on my own. – 0xC0000022L – 2018-07-31T21:50:18.660

All I know is your entire comment about the downvote came off as extremely rude – Ramhound – 2018-07-31T22:01:04.283

@harrymc I apologize if you were offended by my comment above. That was seriously not my intent. – 0xC0000022L – 2018-07-31T22:14:44.783

I was not offended (in truth I didn't even understand that you meant me). I think that you should also try ImDisk virtual disk driver whose usage for mounting vmdk is demoed here.

– harrymc – 2018-08-01T11:23:56.133

1Windows can mount VHD and VHDX file natively. Can you try converting the vmdk to vhdx file and mount it? – phuclv – 2018-08-03T04:43:44.693

@phuclv That was my first thought seeing this question, and it seems to work assuming OP is happy to continue using the VHDs in VMware (which is possible). If you'd like to flesh out that comment into an answer, let me know and I'll delete mine. – Bob – 2018-08-06T02:21:17.443

Answers

2

NB: since I placed a bounty I'll gladly award the bounty to anyone who can provide a functional alternative to what I am demonstrating in my answer below (commercial or not). Because the reputation gets subtracted from me either way.


Out of the four solutions linked by harrymc in a comment (thanks!), I had already tried the first three. The fourth, a freeware called OSFMount also didn't help me. What's worse, the linked article uses misleading terminology:

[...] here are 4 ways to get it mounted in Windows as a disk drive.

The proper terminology would be to get it mounted as a volume. In fact the mounting part implies that. Roughly one could say that disks get attached, while volumes (== partitions on disks) get mounted. But my guess is that due to the fact that terminology varies between OSs and not everyone is a kernel mode developer with knowledge about the Windows storage driver architecture terminology has gotten fuzzy.

The shell extension installed by VMware calls it Map Virtual Disk, although it would be more aptly named Mount Volume inside Virtual Disk (or similar). Besides, the context menu (via shell extension) only provides an alternative route to the second presented solution, which uses the VMware Workstation GUI to invoke the dialog to Map Virtual Disks.

Regardless, terminology is key here. Which is also why it took so long to come up with a result for this question. Too many people use misleading terminology, which "pollutes" search results.

However, since I placed a bounty, I also researched anew if there was a solution. I ended up on the excellent reboot.pro forum in this thread and from there found a mentioning of Arsenal Image Mounter. Apparently written, in large parts, by Olof Lagerkvist of LTR Data (creator of ImDisk), Arsenal Image Mounter includes a storport driver, which is exactly the thing I was looking for.

The steps were:

  1. Installing the driver
  2. ... and using ArsenalImageMounter.exe from an older revision

... allowed to attach the VMDK file as a SCSI disk to Windows. This also caused the volumes to be auto-mounted (much like is done when you attach a partitioned USB disk), but the important part was that the volume was now visible to VeraCrypt for mounting.

This satisfies the requirements I put up in my question.

The steps in screenshots looked as follows (after installing the Arsenal Image Mounter driver):

Options before the disk gets attached

(Terminology here is also a bit fuzzy, because this tool apparently provides both attaching an image file as SCSI disk and mounting volumes therein.)

Image file attached as SCSI disk

And the result in the disk management snap-in of Windows 10 looks like this:

Windows 10 disk management

The relevant parts are that Disk 3 is the (VMDK) image file appearing as actual disk to the system and VeraCrypt is able to see that RAW volume which had been automatically assigned the drive letter H: (and subsequently opened up the dialog to format said volume). The relevant parts are highlighted in the last screenshot.

0xC0000022L

Posted 2017-09-12T16:29:24.447

Reputation: 5 091

2

You can approach this problem from the other direction, as phuclv commented.

Basically:

  • Windows natively supports attaching VHDs as disks. These behave just like any physical disk.
    • This means VeraCrypt can see them as just another disk.
  • It's possible to convert VMDK disks into VHD disks (and vice-versa).
    • Additionally, recent versions of VMware Workstation let you directly use a VHD disk, though you do lose its Defragment/Compact functionality.

So a possible solution, completely avoiding third-party tools, is to use VHD as your virtual disk format and attach it natively in Windows.


You'll want to make sure you only have the disk attached in one place at a time, i.e. detach from Windows before booting the VM, and shut down the VM before attaching on Windows. Doing otherwise is ... a bad idea.

  1. To start with, you need to get a VHD. If you do not have any existing disk, you can create one through the Disk Management => Action => Create VHD menu option. Alternatively, the diskpart create command does the same thing.

    Screenshot of Disk Management menu

    If you have an existing VMDK you want to use, you can convert it using a PowerShell module provided by Microsoft. Some more step-by-step instructions here.

  2. Assuming you still want to attach the disk in VMware, you'll need to remove the old storage device with the VMDK disk and add a new storage device (preferably on the same controller type) with an "existing disk" pointing towards the VHD disk. You will need to select "All Files" in the browse dialog, otherwise it will only show VMDK files. Now, on the VMware side, everything should work more or less as it did with the VMDK disk.

  3. Now you just need to attach the VHD on Windows' side. You can again do this from the Disk Management => Action => Attach VHD menu, or using diskpart attach.

  4. VeraCrypt should now see these disks. They should be indistinguishable from a physical disk.

    Screenshot of Disk Management and VeraCrypt

Bob

Posted 2017-09-12T16:29:24.447

Reputation: 51 526

1

An alternative solution is via the donation-ware of ImDisk virtual disk driver.

Use ImDisk for mounting vmdk as follows :

  • After installation you will find the ImDISK Virtual Disk Driver in the Windows Control Panel.
  • Click File / Mount new virtual disk
  • Select the vmdk file and a drive letter and click OK
  • The disk is now available in Windows.
  • If Windows asks to format the disk, click Cancel

I have the tested the procedure on Windows 10 64-bit and it seems to work, even though the release dates from August 2016.

harrymc

Posted 2017-09-12T16:29:24.447

Reputation: 306 093