Modify a Windows Image Using DISM
This topic details the changes you can make to mounted or applied Windows images with DISM.
Mounted images are WIM, VHD, or FFU files that are that maps the contents of the image to a directory so that you can make changes to the image using without booting into the image. You run run DISM commands against a mounted image, and can also perform common file operations, such as copying, pasting, and editing on a mounted image. Changes you make to the image are committed when you use DISM to unmount the image. To make changes to a mounted image, use DISM /image:
.
Applied images are WIM, VHD, or FFU files that are image files that have been applied to a specified partition. To make changes to an applied image, use DISM /image:
. See Applying an image to learn how to apply an image.
You can mount and modify multiple images on a single computer. For more information, see Deployment Image Servicing and Management (DISM) Best Practices.
Mount an image
You can mount an image using the /optimize option to reduce initial mount time. However, When using the /optimize option, processes that are ordinarily performed during a mount will instead be completed the first time that you access a directory. As a result, there may be an increase in the time that is required to access a directory for the first time after mounting an image using the /optimize option.
Open a command prompt with administrator privileges.
Note
If you are using a version of Windows other than Windows 8 or Windows 10, use the Deployment Tools Command Prompt that gets installed with the ADK.
Use DISM to mount the image
DISM /Mount-image /imagefile:<path_to_Image_file> {/Index:<image_index> | /Name:<image_name>} /MountDir:<target_mount_directory> [/readonly] /[optimize]}
Note
To mount a Windows image from a VHD or FFU file, you must specify
/index:1
.For more information about the options available for the /Mount-Image option in DISM, see DISM Image Management Command-Line Options.
Modify an Image
After you mount an image, you can use DISM to add and remove drivers, packages, language packs, enumerate drivers and packages, modify configuration settings, and more.
View and modify an image
You can create, view, and edit files on a mounted image, just as you would any other file on your PC. When you modify the files in a mounted image, those file changes get saved in the image. Note that although you can add application files and folders, you can't install applications directly into a mounted image in the same way that you would on a running PC. If you must add an application or a device, verify that you included all of the required files.
Add and remove drivers
See Add and remove drivers to an offline Windows image to learn how to work with drivers. Note that the DISM driver commands will only run against an offline image.
Add and remove packages
See Add or remove packages offline using DISM to learn how to work with packages.
Add or remove languages
See Add and remove language packs offline using DISM to learn how to work with languages.
Upgrade to a higher Windows edition
Any changes you make to a mounted image are also applied to each potential target edition of Windows. Each target edition is staged in the image. The changes will not be lost when you upgrade to a higher edition of Windows.
See Change the Windows image to a higher edition using DISM to learn how to change editions.
Reduce the Size of the Image
You can use DISM to reduce the footprint of a Windows image by cleaning up superseded components and resetting the base of the superseeded components.
At an elevated command prompt, run the following command to reduce the size of the image file:
Dism /Image:C:\test\offline /cleanup-image /StartComponentCleanup /ResetBase
Commit Changes to an Image
You can commit changes to an image without unmounting the image.
To commit changes:
At the administrator command prompt, type:
Dism /Commit-Image /MountDir:C:\test\offline
Use /CheckIntegrity to detect and track .wim file corruption when you commit changes to the image. When you apply or mount the image, use /CheckIntegrity again to stop the operation if file corruption was detected. /CheckIntegrity cannot be used with virtual hard disk (VHD) files.
Unmounting an Image
After you modify a mounted image, you must unmount it. If you mounted your image with the default read/write permissions, you can commit your changes. This makes your modifications a permanent part of the image.
If you modified an applied image, you don't have to do anything else. You'll see any changes you made when you boot the PC.
To unmount an image
Open a command prompt or the Deployment Tools Command Prompt with administrator privileges.
Use DISM to unmount the image.
Dism /Unmount-image /MountDir:<target_mount_directory> {/Commit | /Discard}
where
C:\test\offline
is the location of the mount directory. If you do not specify the parameters to unmount, this option lists all of the mounted images but does not perform the unmount action.Important
You must use either the /commit or /discard argument when you use the /unmount option.
Troubleshooting
If the DISM commands in this topic fail, try the following:
Make sure that you are using the Windows 10 version of DISM that is installed with the Windows ADK.
Don’t mount images to protected folders, such as your User\Documents folder.
If DISM processes are interrupted, consider temporarily disconnecting from the network and disabling virus protection.
If DISM processes are interrupted, consider running the commands from the Windows Preinstallation Environment (WinPE) instead.