Share via


Modify a Windows image using DISM

You can make changes to offline mounted or applied Windows images without booting into the operating system you're going to modify.

Mounted images are WIM, VHD, or FFU files that have their contents mapped to a folder. Changes to mounted images are made from either a technician PC, or from WinPE. You run run DISM commands against a mounted image, as well as run common file operations such as copying, pasting, and renaming on a mounted image. To save changes you make to the image, use the /commit option 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 image files that have been applied to a specified partition. Offline changes to an applied image are usually performed from WinPE. To make changes to an applied image, use DISM /image:.

Important

When you apply an image that you're going to recapture, apply the image to the root folder of a drive. If you recapture an image that wasn't applied to the root of a drive, the image will inherit the parent folder's security descriptors and might not be the same as what would be captured if the image was applied to the root of a drive. 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.

Modify an image offline: Start with an image file (either .wim or .ffu format). Mount the file using DISM. It appears as a group of folders. Modify it using DISM, adding drivers, languages, and more. Use DISM to unmount and commit the changes back to the original image file. Apply it to new devices.

Make your image ready for modification

Before you can make changes to your image, you'll have to mount or apply the image depending on your scenario.

Mount an image

Tip

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. This may increase the time that's required to access a directory the first time after mounting an image using the /optimize option.

  1. Open a command prompt with administrator privileges.

  2. 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.

Apply an image

See Apply an image to learn how to apply an image.

Modify an image

You can use DISM to modify a mounted or applied image. You can 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 and then committed to the image when the images gets unmounted

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.

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 an image

You can use DISM to reduce the footprint of a Windows image by cleaning up superseded components, resetting the base of the superseeded components, and then exporting the image to a new image file.

  • 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    
    Dism /Unmount-Image /MountDir:C:\test\offline /Commit
    Dism /Export-Image /SourceImageFile:C:\Images\install.wim /SourceIndex:1 /DestinationImageFile:C:\Images\install_cleaned.wim
    

Commit changes to an image

Mounted image

You can commit changes to an image without unmounting the image.

  • 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.

Applied image

Changes to applied images are saved, and you don't need to take any steps to commit the changes you've made.

Unmounting an image

Note

This only applies to mounted images. Applied images don't need to be unmounted.

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.

  1. Open a command prompt or the Deployment and Imaging Tools Environment with administrator privileges.

  2. 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

See Repair a Windows Image.

If the DISM commands in this topic fail, try the following:

  1. Make sure that you are using the Windows 10 version of DISM that is installed with the Windows ADK.

  2. Don’t mount images to protected folders, such as your User\Documents folder.

  3. If DISM processes are interrupted, consider temporarily disconnecting from the network and disabling virus protection.

  4. If DISM processes are interrupted, consider running the commands from the Windows Preinstallation Environment (WinPE) instead.

DISM Image Management Command-Line Options

Service a Windows Image Using DISM