Jump to content











Photo
* * * * * 1 votes

vMount

vhd

  • Please log in to reply
222 replies to this topic

#1 erwan.l

erwan.l

    Platinum Member

  • Developer
  • 3041 posts
  • Location:Nantes - France
  •  
    France

Posted 10 March 2014 - 07:27 PM

index.php?app=downloads&module=display&s

File Name: vMount
File Submitter: erwan.l
File Submitted: 10 Mar 2014
File Updated: 24 Apr 2019
File Category: Tools

A command line tool to handle VHD files.
Goal is to facilitate batches around VHD operations.

The tool uses MS Virtual Disk API (only under Windows 7).
The tool can also mount ISO files under Windows 8.

Command line is as follows :

 

vmount getvirtualdiskinfo path_to_vhd

vmount addfooter path_to_raw_file
vmount truncate path_to_file

vmount createfixedraw path_to_raw size(MB)
vmount createfixedvhd path_to_vhd size(MB)
vmount createdynamicvhd path_to_vhd size(MB)
vmount createchildvhd path_to_child path_to_parent
vmount attachvhd path_to_vhd
[NOLETTER]
vmount attachvhd path_to_iso
vmount detachvhd \\
.\PhysicalDriveX
vmount detachvhd disk_numX
vmount detachvhd path_to_vhd
vmount expandvhd path_to_vhd size
(MB)
vmount compactvhd path_to_vhd
vmount resizevhd path_to_vhd
vmount mergevhd path_to_child

vmount disks [filter]
vmount partitions [filter]
vmount assign x: \device\harddiskX\partitionY
vmount assign x:\ \\?\Volume{GUID}\
vmount assign x:\mount\ \\?\Volume{GUID}\
vmount assign x: \\ip\smb_share [username] [password]
vmount assign x: ip:/nfs_export [username] [password]
vmount remove x:
vmount remove mount_point(e.g x:\ or c:\mount\)
vmount volumes
vmount devices [filter]
vmount online disk_num
vmount offline disk_num
vmount ro disk_num
vmount rw disk_num
vmount attributes disk_num
vmount createdisk \\.\PhysicalDriveX MBR:GPT:RAW
vmount createpart \\.\PhysicalDriveX MBR [partnum] [startingoffset_in_bytes] [length_in_bytes] [boot:0:1]
vmount createpart \\.\PhysicalDriveX GPT [partnum] [startingoffset_in_bytes] [length_in_bytes]
vmount deletedisklayout \\.\PhysicalDriveX
vmount changediskid \\.\PhysicalDriveX MBR $11223344
vmount changediskid \\.\PhysicalDriveX GPT {11223344-1122-1122-AABB-112233445566}
vmount changepartidgpt \\.\PhysicalDriveX PARTNUM {11223344-1122-1122-AABB-112233445566}

vmount changeparttypegpt \\.\PhysicalDriveX part_numY {11223344-1122-1122-AABB-112233445566}
vmount changepartattributesgpt \\.\PhysicalDriveX part_numY $0000000000000000
vmount disklayout \\.\PhysicalDriveX

vmount deletepart \\.\PhysicalDriveX MBR:GPT PARTNUM
vmount setpartnumberonembr \\.\PhysicalDriveX PARTNUM
vmount backupdisksector \\.\PhysicalDriveX sector_num filename
vmount restoredisksector \\.\PhysicalDriveX sector_num filename

vmount convert2fixed path_to_vhd_or_vhdx_or_img path_to_vhd_or_vhdx
vmount convert2dynamic path_to_vhd_or_vhdx_or_img path_to_vhd_or_vhdx
vmount convert2raw path_to_vhd_or_vhdx path_to_img

 

Feedback / Requests appreciated.

Regards,
Erwan

Click here to download this file



#2 erwan.l

erwan.l

    Platinum Member

  • Developer
  • 3041 posts
  • Location:Nantes - France
  •  
    France

Posted 10 March 2014 - 07:32 PM

Hi Guys,

 

Find here a command line tool to perform the following tasks around VHD files :

 

-Create a fixed size VHD

-Create a dynamic size VHD

-Create a child VHD

-Attach (i.e mount) a VHD

-Detach (i.e unmount) a VHD

-Expand a VHD

-Merge a VHD

-List all physical drives (to identify VHD ones)

 

Tool was written in 5 mns out of CloneDisk source code.

 

The idea is to make life easier when dealing with VHD files from command line.

 

I am sure there are out there other ways or other tools similar to this but I needed a tool that could do all the above tasks at once :)

 

Now sharing...

 

Regards,

Erwan


  • Tokener likes this

#3 Tokener

Tokener

    Frequent Member

  • Developer
  • 378 posts

Posted 12 March 2014 - 11:43 AM

Dear erwan.l

 

This tool is really MIGHTY. 

:worship:

Thank you for sharing.

Sincerely T.



#4 erwan.l

erwan.l

    Platinum Member

  • Developer
  • 3041 posts
  • Location:Nantes - France
  •  
    France

Posted 12 March 2014 - 07:19 PM

Dear erwan.l

 

This tool is really MIGHTY. 

:worship:

Thank you for sharing.

Sincerely T.

 

Thanks ReTokener.

 

In the future, I may add WIM support to vMount as well.


  • Tokener likes this

#5 erwan.l

erwan.l

    Platinum Member

  • Developer
  • 3041 posts
  • Location:Nantes - France
  •  
    France

Posted 08 May 2014 - 08:47 PM

small update :

 

  • added:
  • optional filter parameter for (1) vmount disks and (2) vmount partitions to filter on (1) productid and (2) harddisk number.

 

vmount disks "virtual disk" will list only disks with productid "virtual disk".

vmount partitions harddisk0 will list only partitions for harddisk0.

 

/Erwan



#6 dickfitzwell

dickfitzwell

    Member

  • Members
  • 33 posts

Posted 15 July 2014 - 05:53 PM

I am having trouble with the detach command:

C:\DATA>vmount.exe
vmount v0.6 by erwan2212@gmail.com
vmount createfixed path size(MB)
vmount createdynamic path size(MB)
vmount createchild path parent
vmount attach path
vmount detach \\.\PhysicalDriveX
vmount expand path size(MB)
vmount merge path
vmount disks [filter]
vmount partitions [filter]
vmount mount x: \device\harddiskX\partitionX
vmount umount letter

C:\DATA>vmount.exe createdynamic c:\DATA\disk.vhd 2000
CreateVHD ok

C:\DATA>vmount.exe attach c:\DATA\disk.vhd
OpenVirtualDisk OK
AttachVirtualDisk OK

C:\DATA>vmount.exe disks
0       DISK    WD2500AAJS-75M0A        238417MB
1       DISK    Virtual Disk            1992MB

C:\DATA>vmount.exe detach \\.\physicaldrive1
detach_vhd:Range check error

C:\DATA>diskpart

Microsoft DiskPart version 6.1.7601
Copyright (C) 1999-2008 Microsoft Corporation.
On computer: TOWER

DISKPART> select vdisk file=c:\data\disk.vhd

DiskPart successfully selected the virtual disk file.

DISKPART> detach vdisk

DiskPart successfully detached the virtual disk file.

DISKPART> exit

Leaving DiskPart...

C:\DATA>

Additionally, when the VHD is created on a ramdisk (Imdisk or Softperfect), the detach fails even in DiskPart:

C:\DATA\>vmount.exe
vmount v0.6 by erwan2212@gmail.com
vmount createfixed path size(MB)
vmount createdynamic path size(MB)
vmount createchild path parent
vmount attach path
vmount detach \\.\PhysicalDriveX
vmount expand path size(MB)
vmount merge path
vmount disks
vmount partitions
vmount mount x: \device\harddiskX\partitionX
vmount umount letter

C:\DATA\>imdisk -a -o awe -s 4G -m #: -p "/fs:ntfs /q /y"
Creating device...
Created device 0: D: -> Image in memory
Formatting disk...
The type of the file system is RAW.
The new file system is NTFS.
QuickFormatting 4096M
Volume dismounted.  All opened handles to this volume are now invalid.
Creating file system structures.
Format complete.
       4.0 GB total disk space.
       4.0 GB are available.
Notifying applications...
Done.

C:\DATA\>vmount.exe createdynamic d:\disk.vhd 2000
CreateVHD ok

C:\DATA\>vmount.exe attach d:\disk.vhd
OpenVirtualDisk OK
AttachVirtualDisk OK

C:\DATA\>vmount.exe disks
0       DISK    WD2500AAJS-75M0A        238417MB
1       DISK    Virtual Disk            1992MB

C:\DATA\>vmount.exe detach \\.\physicaldrive1
detach_vhd:Range check error

C:\DATA\>diskpart

DISKPART> list disk

  Disk ###  Status         Size     Free     Dyn  Gpt
  --------  -------------  -------  -------  ---  ---
  Disk 0    Online          232 GB   192 GB
  Disk 1    Online         2000 MB  2000 MB

DISKPART> select vdisk file=d:\disk.vhd

DiskPart successfully selected the virtual disk file.

DISKPART> detach vdisk

Virtual Disk Service error:
The virtual disk is already detached.


DISKPART> exit

Leaving DiskPart...

C:\DATA>


#7 erwan.l

erwan.l

    Platinum Member

  • Developer
  • 3041 posts
  • Location:Nantes - France
  •  
    France

Posted 15 July 2014 - 07:52 PM

Strange, i could not reproduce the error for now :(

 

Which architecture do you have?

32 bits or 64 bits?

 

In the first case, is it a standard disk hosting the vhd or a virtual one (imdisk or else) ?

 

Just to be safe, I made one tiny correction in vmount (32 bits version).

Download it again and give it a try.

Also, just to be sure, run it as administrator.

 

Thx,

Erwan



#8 dickfitzwell

dickfitzwell

    Member

  • Members
  • 33 posts

Posted 15 July 2014 - 08:23 PM

Strange, i could not reproduce the error for now :(

 

Which architecture do you have?

32 bits or 64 bits?

 

In the first case, is it a standard disk hosting the vhd or a virtual one (imdisk or else) ?

 

Just to be safe, I made one tiny correction in vmount (32 bits version).

Download it again and give it a try.

Also, just to be sure, run it as administrator.

 

Thx,

Erwan

 

I am on W7-64.

 

I was using vmount (32) and the new vmount (32) still fails.  BUT I tried the vmount64.exe and it detaches for VHD located on a HD.  However, detach still fails on ramdisk.  The is no "DetachVHD" error, but no "DetachVHD OK" either.

c:\DATA>r:\vmount.exe createdynamic c:\DATA\disk.vhd 2000
CreateVHD ok

c:\DATA>r:\vmount.exe attach c:\DATA\disk.vhd
OpenVirtualDisk OK
AttachVirtualDisk OK

c:\DATA>r:\vmount.exe disks
0       DISK    WD2500AAJS-75M0A        238418MB
1       DISK    Virtual Disk            2000MB

c:\DATA>r:\vmount.exe detach \\.\physicaldrive1
detach_vhd:Range check error

c:\DATA>r:\vmount64.exe detach \\.\physicaldrive1
DetachVHD OK

C:\DATA>imdisk -a -o awe -s 3G -m #: -p "/fs:ntfs /q /y"
Creating device...
Created device 0: D: -> Image in memory
Formatting disk...
The type of the file system is RAW.
The new file system is NTFS.
QuickFormatting 3072M
Creating file system structures.
Format complete.
       3.0 GB total disk space.
       3.0 GB are available.
Notifying applications...
Done.

c:\DATA>r:\vmount64.exe createdynamic d:\disk.vhd 2000
CreateVHD ok

c:\DATA>r:\vmount64.exe attach d:\disk.vhd
OpenVirtualDisk OK
AttachVirtualDisk OK

c:\DATA>r:\vmount64.exe disks
0       DISK    WD2500AAJS-75M0A        238417MB
1       DISK    Virtual Disk            1992MB

c:\DATA>r:\vmount64.exe detach \\.\physicaldrive1

c:\DATA>

BOOTICEx86 1.3.2 will successfully detach the VHD though.


Edited by dickfitzwell, 15 July 2014 - 08:24 PM.


#9 erwan.l

erwan.l

    Platinum Member

  • Developer
  • 3041 posts
  • Location:Nantes - France
  •  
    France

Posted 15 July 2014 - 08:25 PM

Oki that's good feedback : vmount64 succeeds where vmount32 fails.

Sidenote, on windows x64, I would stick to vmount64.

 

About detach against a ram drive, will give it a try.

 

edit : are you using latest imdisk 1.8.3?



#10 erwan.l

erwan.l

    Platinum Member

  • Developer
  • 3041 posts
  • Location:Nantes - France
  •  
    France

Posted 15 July 2014 - 08:41 PM

Ok, found the reason why I cannot detah a vhd on a imdisk drive : GetVolumePathNamesForVolumeNameA for \Device\ImDisk0 failed.

 

I retrieve the hostvolumename (provided by the ms vhd GetStorageDependencyInfo api).

From there, I retrieve the logical drive (x:\) which I concatenate to the DependentVolumeRelativePath (\folder\filename.vhd).

With this full path name, I can then open the vhd and detach it.

 

Seems ImDisk does not provide a volumename (I believe there is a discussion somewhere about this on this forum).

I recall this is normal behavior from ImDisk. 

 

Now, I wonder how bootice does it :)

There are for sure other ways to retrieve a logical drive from a device name.

 

Edit : latest vmount (32bits version) will now display the GetVolumePathNamesForVolumeNameA  error (for ImDisk for instance).

 

Edit : discussion around ImDisk and volumenames.



#11 dickfitzwell

dickfitzwell

    Member

  • Members
  • 33 posts

Posted 15 July 2014 - 08:48 PM

Oki that's good feedback : vmount64 succeeds where vmount32 fails.

Sidenote, on windows x64, I would stick to vmount64.

 

About detach against a ram drive, will give it a try.

 

edit : are you using latest imdisk 1.8.3?

I know, but it's easier to code batch files that will work in both x86/x64 with vmount.exe (32).

Imdisk 1.8.4 but the problem is the same on a ramdisk created by Softperfect Ramdisk.

Additionally, I think the ramdisk issue has to do with the path vmount uses to link to Disk Management.

For example, D:\ being a ramdisk:

attaching using DiskPart then detaching with Disk Management gui asks for confirmation with the path "d:\disk.vhd" which succeeds.

attaching using vmount/vmount64 then detaching with Disk Management gui asks for confirmation with the path "\Device\ImDisk0\disk.vhd" which fails.  Then attempting to detach with DiskPart says d:\disk.vhd is already detached.

Interestingly, attaching with BOOTICEx86 gui then detaching with Disk Management gui asks for confirmation with the path "\Device\ImDisk0\disk.vhd" which fails also.  But using BOOTICEx86 gui detach command succeeds?!  Strange.



#12 erwan.l

erwan.l

    Platinum Member

  • Developer
  • 3041 posts
  • Location:Nantes - France
  •  
    France

Posted 15 July 2014 - 08:51 PM

I know, but it's easier to code batch files that will work in both x86/x64 with vmount.exe (32).

Imdisk 1.8.4 but the problem is the same on a ramdisk created by Softperfect Ramdisk.

Additionally, I think the ramdisk issue has to do with the path vmount uses to link to Disk Management.

For example, D:\ being a ramdisk:

attaching using DiskPart then detaching with Disk Management gui asks for confirmation with the path "d:\disk.vhd" which succeeds.

attaching using vmount/vmount64 then detaching with Disk Management gui asks for confirmation with the path "\Device\ImDisk0\disk.vhd" which fails.  Then attempting to detach with DiskPart says d:\disk.vhd is already detached.

Interestingly, attaching with BOOTICEx86 gui then detaching with Disk Management gui asks for confirmation with the path "\Device\ImDisk0\disk.vhd" which fails also.  But using BOOTICEx86 gui detach command succeeds?!  Strange.

 

About bootice, does it effectively unmount it or just say it does (which are different things :) ).

 

I could add an option to detact a vhd based on its full path (if you know it).

 

About the range error in vmount32, i'll fix it : just need to revive my x64 test machine.



#13 dickfitzwell

dickfitzwell

    Member

  • Members
  • 33 posts

Posted 15 July 2014 - 08:57 PM

About bootice, does it effectively unmount it or just say it does (which are different things :) ).

 

I could add an option to detact a vhd based on its full path (if you know it).

 

About the range error in vmount32, i'll fix it : just need to revive my x64 test machine.

 

BOOTICEx86 successfully attaches/detaches anywhere the vhd is located, verified in Disk Management gui as opposed to just saying it does.

 

Must be some kind of brute force method ;) he uses.

 

If you're not familiar with BOOTICEx86, detach does require the VHD path rather than physical drive number, must be why it succeeds.


Edited by dickfitzwell, 15 July 2014 - 09:01 PM.


#14 erwan.l

erwan.l

    Platinum Member

  • Developer
  • 3041 posts
  • Location:Nantes - France
  •  
    France

Posted 15 July 2014 - 09:11 PM

BOOTICEx86 successfully attaches/detaches anywhere the vhd is located, verified in Disk Management gui as opposed to just saying it does.

 

Must be some kind of brute force method ;) he uses.

 

If you're not familiar with BOOTICEx86, detach does require the VHD path rather than physical drive number, must be why it succeeds.

 

good idea.

version 0.7 now online. (updated x32 bits only)

 

2 syntaxes for detach :

  vmount detach \\.\PhysicalDriveX
  vmount detach x:\test.vhd (if you know the full path to your vhd)

  • Tokener likes this

#15 dickfitzwell

dickfitzwell

    Member

  • Members
  • 33 posts

Posted 16 July 2014 - 07:54 AM

 

good idea.

version 0.7 now online. (updated x32 bits only)

 

2 syntaxes for detach :

  vmount detach \\.\PhysicalDriveX
  vmount detach x:\test.vhd (if you know the full path to your vhd)

 

 

Syntax in new version (x32 bits only) works as expected on both HD and ramdisk.  Thank you.



#16 erwan.l

erwan.l

    Platinum Member

  • Developer
  • 3041 posts
  • Location:Nantes - France
  •  
    France

Posted 20 July 2014 - 04:25 PM

Both x32 and x64 updated to versions 0.7.

 

Syntax updated :

 

vmount createfixed path_to_vhd size(MB)
vmount createdynamic path_to_vhd size(MB)
vmount createchild path_to_child path_to_parent
vmount attach path_to_vhd
vmount attach path_to_iso (win8.1 only)
vmount detach \\.\PhysicalDriveX (x32 version does not work here under x64)
vmount detach path_to_vhd
vmount expand path_to_vhd size(MB)
vmount merge path_to_child
vmount disks [filter]
vmount partitions [filter]
vmount mount x: \device\harddiskX\partitionX
vmount umount letter

  • Tokener likes this

#17 Tokener

Tokener

    Frequent Member

  • Developer
  • 378 posts

Posted 04 September 2014 - 08:47 AM

Dear Erwan.I

 

Thanks for updating, but where can the tool be downloaded?

Even downloading v.0.6, (newest release) the helpfile states: vmount v0.1 by erwan2212@gmail.com

Is there a chance to assign a versionnumber to file itself?

 

Btw, could you please post a "real life" command line for "mount" command?

Need this to understand the sense of "mount". :unsure:

 

Regards T.



#18 erwan.l

erwan.l

    Platinum Member

  • Developer
  • 3041 posts
  • Location:Nantes - France
  •  
    France

Posted 04 September 2014 - 05:29 PM

Dear Erwan.I

 

Thanks for updating, but where can the tool be downloaded?

Even downloading v.0.6, (newest release) the helpfile states: vmount v0.1 by erwan2212@gmail.com

Is there a chance to assign a versionnumber to file itself?

 

Btw, could you please post a "real life" command line for "mount" command?

Need this to understand the sense of "mount". :unsure:

 

Regards T.

 

I have updated the help.txt.

I have updated reboot.pro download section to reflect the correct version (0.7).

 

Here comes a real life example :

>vmount partitions
C: [SYSTEME]    NTFS            \harddisk0\partition1   152625MB
>vmount mount x: \device\harddisk0\partition1
x: mount ok
 
"mount" is not to be confusing with attaching a VHD.
"mount" uses the Ms Windows DefineDosDevice.


#19 Tokener

Tokener

    Frequent Member

  • Developer
  • 378 posts

Posted 04 September 2014 - 11:08 PM

Hi erwan.l

Thanks a lot for the fast reply.

I see: mount is the Pendant to "substitute" a folder.
What confused me was how to interpret "\device\".


I Tried the following on Win7x64:

vmount64.exe createdynamic "B:\111.vhd" 1000
CreateVHD ok

vmount64.exe attach B:\111.vhd (Where B: is ImDisk RamDrive)
OpenVirtualDisk OK
AttachVirtualDisk OK

vmount64.exe disks "virtual disk"
4       DISK    Virtual Disk            40000MB
5       DISK    Virtual Disk            1000MB

vmount64.exe detach \\.\PhysicalDrive5
GetVolumePathNamesForVolumeNameA for \Device\ImDisk0 failed,0


What causes this error?
Did I get the syntax wrong?
ImDisk.exe is placed in \system32.
ImDisk FileVersion: 1.8.4.40

Is there a version conflict?

 

Thanks in advance T.
 



#20 erwan.l

erwan.l

    Platinum Member

  • Developer
  • 3041 posts
  • Location:Nantes - France
  •  
    France

Posted 05 September 2014 - 06:03 AM

Hi erwan.l
Thanks a lot for the fast reply.
I see: mount is the Pendant to "substitute" a folder.
What confused me was how to interpret "\device\".
I Tried the following on Win7x64:
vmount64.exe createdynamic "B:\111.vhd" 1000
CreateVHD ok
vmount64.exe attach B:\111.vhd (Where B: is ImDisk RamDrive)
OpenVirtualDisk OK
AttachVirtualDisk OK
vmount64.exe disks "virtual disk"
4       DISK    Virtual Disk            40000MB
5       DISK    Virtual Disk            1000MB
vmount64.exe detach \\.\PhysicalDrive5
GetVolumePathNamesForVolumeNameA for \Device\ImDisk0 failed,0
What causes this error?
Did I get the syntax wrong?
ImDisk.exe is placed in \system32.
ImDisk FileVersion: 1.8.4.40
Is there a version conflict?
 
Thanks in advance T.


Because imdisk does not list as a physicaldisk, you need to use the second detach syntax pointing to the vhd you want to detach.
See posts from dickfitzwell above.



#21 Tokener

Tokener

    Frequent Member

  • Developer
  • 378 posts

Posted 05 September 2014 - 08:22 AM

Thanks for the fast reply erwan

 

 

As dickfitzwell stated:

 

Syntax in new version (x32 bits only) works as expected on both HD and ramdisk.  Thank you.

I hoped it would work on 64-bit also.

But no big problem.

 

vmount rocks! :thumbsup:  

 

T.



#22 erwan.l

erwan.l

    Platinum Member

  • Developer
  • 3041 posts
  • Location:Nantes - France
  •  
    France

Posted 05 September 2014 - 08:26 AM

Thanks for the fast reply erwan

 

 

As dickfitzwell stated:

I hoped it would work on 64-bit also.

But no big problem.

 

vmount rocks! :thumbsup:  

 

T.

 

Normally, using x32 binaries under x64 o.s is not an issue, except for a few API (i have issues with pointers on x32 vs x64...).

Hence, the x64 version for vmount for x64 o.s.



#23 Tokener

Tokener

    Frequent Member

  • Developer
  • 378 posts

Posted 05 September 2014 - 08:49 AM

Any chance to implement a version number to file itself?

It would be easier to identify files.

 

Is there a way to retrieve the path of the attached vhd-file if you just know the Drive-Letter of a virtual disk?



#24 erwan.l

erwan.l

    Platinum Member

  • Developer
  • 3041 posts
  • Location:Nantes - France
  •  
    France

Posted 08 September 2014 - 09:33 PM

Any chance to implement a version number to file itself?
It would be easier to identify files.
 
Is there a way to retrieve the path of the attached vhd-file if you just know the Drive-Letter of a virtual disk?


Next version will have file version.

Yes it should be possible to retrieve the vhd path based on virtual disk letter.
Next version could propose such an option.
  • Tokener likes this

#25 Beems

Beems
  • Members
  • 1 posts
  •  
    United Arab Emirates

Posted 18 December 2014 - 07:51 PM

I haven't tested "mounting" yet, but when attempting to unmount an existing VHD, I receive an error:

 

COMMAND: VMOUNT64.exe DETACH C:\Secure.vhdx
STDOUT: OpenVHD failed,1392

COMMAND: VMOUNT64.exe UMOUNT S:\
STDOUT: NULL

 

Any ideas?







Also tagged with one or more of these keywords: vhd

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users