Open VHD files like archives

Thread split from Open VHD within lister


Is this topic about double clicking a *.vhd file and browsing its content?
I just tried that, but i get a 7-zip requester ".. cannot be opened as archive".
I installed latest 7zip and opened the *.vhd directly in there, it worked.
I was of the impression DO could do the same, since it's using the 7zip handler?

As far as I can remember, VHD support hasn't been plumbed in. (Maybe it didn't exist in 7-Zip back when most of the work was done on that? Not sure.) But if 7-Zip supports it, it should be possible to extend that to Opus.

What's the easiest way to create a test VHD file?

I did with the help of the integrated disk management, in the "Action" menu there is "Create VHD", it wants size and path and will behave as a virtual disk. For 7zip to open the corresponding *.vhd file, the VHD needs to be in detached mode (so it's not locked) it will disappear from disk management then and would need reattach (same "Action" menu) to be available as a virtual drive again.

I spent a few hours today looking at this and I've decided not to do it, at least for now.

The issue is that VHD files may contain multiple partitions, which are like nested archives as far as 7z.dll is concerned. When there is only partition, it's simple enough (we can act as if that partition is the archive), but when there are multiple partitions it gets complicated.

It's not impossible, so we might revisit this in the future, but I don't think it's really worth it when you can already mount and open VHD files by simply double-clicking them, by default. (Windows will mount them as real drives which you can read and write from any program.)

Given that, opening them as archives instead of mounting them would only really be a small convenience (mainly that you don't have to unmount them when you're done), and is also an inconvenience (you'd only be able to access them from Opus, not from everything).

1 Like

Yes, ok. Thank you for looking into this! o)
I wasn't aware windows would mount these files on double click. It does not on my system (7zip comes up with an error message, but I can open VHDs in it manually). There probably is something different in regards to assigned programs for *.vhd here, not sure how to reset to default though to get the native behaviour.
Right clicking a VHD also gives a context menu entry "Mount as ImDisk Virtual Disk", not sure where this comes from, is this a windows native dialog for these kind of files? Rather looks like another 3rd party tool for me, but Taskmanager shows some "rundll.. " type of launch.
image

Multi partition VHDs were not supported by 7zip either (I read somewhere), but maybe they do in the latest version, I have not played much with VHDs yet. I was in a process of investigation. o) I had the idea they could help managing larger filesystem structures in some way (mountpoints, dynamic sizes etc.), but right now this seems more trouble than just using links/junctions to merge multiple sources into a single browseable filesystem.

It does in Windows 10 at least. From the screenshot it looks like you're on Windows 95. :slight_smile: :slight_smile: :slight_smile:

2 Likes

In Win7 .vhd-files can be mounted via batch file.

Mount

@ECHO OFF
TITLE Mount VHD
ECHO Mount VHD
ECHO Written by: Jason Faulkner
ECHO SysadminGeek.com
ECHO.
ECHO.

SETLOCAL

SET DiskPartScript="%TEMP%\DiskpartScript.txt"

ECHO SELECT VDISK FILE="%~1" > %DiskPartScript%
ECHO ATTACH VDISK >> %DiskPartScript%

DiskPart /s %DiskPartScript%

ENDLOCAL

Unmount

@ECHO OFF
TITLE Unmount VHD
ECHO Unmount VHD
ECHO Written by: Jason Faulkner
ECHO SysadminGeek.com
ECHO.
ECHO.

SETLOCAL

SET DiskPartScript="%TEMP%\DiskpartScript.txt"

ECHO SELECT VDISK FILE="%~1" > %DiskPartScript%
ECHO DETACH VDISK >> %DiskPartScript%

DiskPart /s %DiskPartScript%

ENDLOCAL

The SendTo menu is a good place for both batch files.

(Original website not available anymore)

There are some buttons I use here, hope it will be helpful.

Mount VDISK:

(echo select vdisk file={filepath$} 
echo attach vdisk
)  | diskpart

Unmount Vdisk:

(echo select vdisk file={filepath$} 
echo detach vdisk
)  | diskpart

Create VHD:

@externalonly
set vdiskname={dlgstring|Please enter the virtual disk [NAME]:|my_vdisk}
set vdiskext={dlgchoose|Please select the virtual disk [FORMAT]:|default:VHD+VHDX}
set vdisksize={dlgstring|Please enter the virtual disk [SIZE]:|25600}
set vdisktype={dlgchoose|Please select the virtual disk [TYPE]:|default:Expandable+Fixed}
set vdiskvolume={dlgstring|Please enter the virtual disk will mount to [LETTER]:|O}
set vdisklabel={dlgstring|Please enter the disk partition [LABEL]:|NewVolume}
(echo create vdisk file={sourcepath$}\%vdiskname%.%vdiskext% maximum=%vdisksize% type=%vdisktype%
echo select vdisk file={sourcepath$}\%vdiskname%.%vdiskext%
echo attach vdisk
echo create partition primary
echo assign letter=%vdiskvolume%
echo format quick label=%vdisklabel%
echo exit >nul
)  | diskpart
echo.
pause

Create VHD automatically:

(echo create vdisk file={sourcepath$}\My_New_VDisk.vhd maximum=25600 type=expandable
echo select vdisk file={sourcepath$}\My_New_VDisk.vhd
echo attach vdisk
echo create partition primary
echo assign letter=O
echo format quick label=NewVolume
echo exit >nul
)  | diskpart
pause>nul

Create differencing disks:

(echo create vdisk file={sourcepath$}\{file$|noext}-child.{filepath$|ext} parent={filepath$} 
echo exit >nul
)  | diskpart
pause>nul
1 Like

Just FWIW - I have a some VHD's

First I have them 'Automount'
(see How to Auto-Mount VHD or VHDX File at Startup in Windows 10

then I created a simple shortcut to those drives on the desktop.

When clicking on them a pop-up will show up prompting for a password.

Works fine.

SnagIt-05052024 162533