This is the mail archive of the
mailing list for the Cygwin project.
Issue creating directories in a VHD volume
- From: David Lee <mailtolky at gmail dot com>
- To: cygwin at cygwin dot com
- Date: Wed, 29 Jun 2016 11:14:22 +0800
- Subject: Issue creating directories in a VHD volume
- Authentication-results: sourceware.org; auth=none
I found some issues while trying to create directories to a volume on
a virtual disk (VHD).
-- SETUP --
* Windows 7 SP1 x64
* Cygwin 2.5.2 x86 installed and run under C:\Cygwin
* 100 MB Virtual Disk on D:\Test.vhd
* VHD has a 100 MB simple volume formatted as NTFS
* Tests were done under an account the joined the Local Administrators group.
-- TEST 1 --
1. I used Disk Management Console (diskmgmt.msc) to:
a. Attach the VHD using Disk Management Console (GUI) (diskmgmt.msc).
b. Mount the volume under C:\Cygwin\tmp\mount (Cygwin saw it as /tmp/mount).
2. Then I tried to create a directory in /tmp/mount inside bash:
3. Result: success (note: elevation was not needed).
-- TEST 2 --
Same procedure but used the diskpart.exe console utility instead.
1. It fired up a UAC prompt and I accepted it.
2. I created another directory: mkdir /tmp/mount/67890.
3. Result: success (note: although diskpart.exe was elevated, the bash
prompt itself wasn't.)
-- TEST 3 --
I wrote a simple utility in C/C++ to attach the VHD (using Win32 API
such as OpenVirtualDisk() and AttachVirtualDIsk()).
Source was attached with this message (demo.c)
1. I fired up an *elevated* Command Prompt.
2. Ran the utility to attach the DISK. Result: success.
3. Mounted the volume under C:\Cygwin\tmp\mount, either diskmgmt.msc
4. Inside a bash prompt (no elevation), typed mkdir /tmp/mount/abcde
5. Result: permission denied (no directory was created).
6. In a Command Prompt (no elevation), the following SUCCEED:
Any help is appreciated on why I got the 'permission denied' message.
* rename to demo.c and compile under cygwin as
* i686-w64-mingw32-gcc demo.c -lVirtDisk
#define _WIN32_WINNT 0x601
#define VHDPATH L"D:\\test.vhd"
vst.DeviceId = VIRTUAL_STORAGE_TYPE_DEVICE_VHD;
vst.VendorId = VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT;
rc = OpenVirtualDisk (
(VIRTUAL_DISK_ACCESS_MASK) (VIRTUAL_DISK_ACCESS_ATTACH_RW | VIRTUAL_DISK_ACCESS_DETACH),
if (rc != ERROR_SUCCESS)
fwprintf (stderr, L"OpenVirtualDisk() failed, rc = %lu\n", rc);
params.Version = ATTACH_VIRTUAL_DISK_VERSION_1;
rc = AttachVirtualDisk (
(ATTACH_VIRTUAL_DISK_FLAG)(ATTACH_VIRTUAL_DISK_FLAG_NO_DRIVE_LETTER | ATTACH_VIRTUAL_DISK_FLAG_PERMANENT_LIFETIME),
if (rc != ERROR_SUCCESS)
fwprintf (stderr, L"AttachVirtualDisk() failed, rc = %lu\n", rc);
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple