How long can a .wim stay mounted when using DISM API?

AZBruno 116 Reputation points
2022-01-20T01:35:58.57+00:00

I'm writing an app with a GUI to build a custom WinPE and working on the layer above the DISM api.

Although I understand the need to initialize the API, mount images, create sessions, shutdown the API, etc., my question has to do with the lifespan of a mounted image.

I currently can see creating a session, doing a session operation and closing the session all within a single method. But, is it possible to do this...

Initialize Dism api
Mount an image
Shutdown Dism API

and then later ...
Initialize Dism
Create a session on the previously mounted image
Perform an action (e.g. Add Driver)
Close session
Shutdown Dism API

and repeat.

In don't want to unmount and remount the image as that's very time consuming. But the docs I've read don't give me a clear picture of what happens when an image is mounted (other than the usual unpacking to a directory), and how DISM may know that an image must be remounted or is corrupted. I could possibly avoid multiple Initialize/Shutdown sequences if that would be beneficial.

TIA,
Bruno

Windows 10 Setup
Windows 10 Setup
Windows 10: A Microsoft operating system that runs on personal computers and tablets.Setup: The procedures involved in preparing a software program or application to operate within a computer or mobile device.
1,908 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Sean Liming 4,511 Reputation points
    2022-01-20T16:46:31.253+00:00

    Accidently, I have left a .WIM file mounted and rebooted or shutdown the system between unmounting the .wim file. I don't think there is a time limit. There can be a challenge unmounting the .WIM file, and I have had to do a cleanup-wim to free up the .WIM file to be mounted again.

    0 comments No comments

  2. Limitless Technology 39,371 Reputation points
    2022-01-21T10:25:12.497+00:00

    Hi there,

    Operating Systems treat disks as objects that can be trusted not to change state suddenly. When reading or writing files, the OS expects the files to remain accessible and not suddenly disappear in mid-read or mid-write. If a file is open, a program reading the file expects to be able to return to it and continue reading.

    A disk image is a "virtual disk" which when mounted (say it activated or linked to PC), pretends to be a hard disk. When unmounted, it stays as a dormant file. This is done by the DISM commands.

    Here are some links to dig more info regarding this.

    Modify a Windows image using DISM
    https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/mount-and-modify-a-windows-image-using-dism?view=windows-11

    -------------------------------------------------------------------------------------------------------------------------------------

    --If the reply is helpful, please Upvote and Accept it as an answer--

    0 comments No comments