Windows uses Dism backup operating system shortcut command system backup

foreword

       Before, I used Chuyu’s open-source Diss++ tool. The tool is very powerful, but you can’t choose to exclude folders or files when exporting the image , which makes the exported *.wim file very large, and the young hard disk has suffered. capacity it should not bear

  

Table of contents

foreword

Solve the problem

    Steps

@command <——If you don’t understand, you can copy it (replace other parameters) <—— Look here for shortcut operations

Command explanation:

Extend to create an incremental backup 

@config file section

Appendix 1: Some Available Options

Appendix 2: Specific usage of /ScratchDir command

Image Example - Precautions

Precautions for System Backup in PE Mode 

Precautions for FirPE installation

Related Links


Solve the problem

       You can easily understand that Dism is the command line "deployment image service and management tool" of Microsoft windows system

That is to say, the backup system can use commands, and you can use the relevant documents to realize functions such as excluding folders. Here, some commands for restoring (release, installation) the system are not introduced. When restoring, you can directly use the Dism++ tool to restore

    Steps

              @command part (executed with administrator privileges)

               1. Specify dism parameters on the command line (including excluding folders, etc.)

               2. Generate a bat file for easy use

              @Configuration file part (configuration file name can be arbitrary)

               1. Note that the path uses a relative path

               2. You can use wildcard Chinese file names (support with spaces)

3. Select ANSI encoding                when saving the file (Windows Chinese recognition)

              @Special reminder that Dism backup must be used in WinPE mode and keep the foreground while running (see the end of PE download)

@command <——you can copy if you don’t understand (other parameters are replaced)

       Open the notepad and paste it (pay attention to changing the path) and save it as a *.bat file (run with administrator privileges)

Dism.exe /Capture-Image /ImageFile:C:win11.wim /CaptureDir:C:\ /Name:Win11PRO /Description:Heart-Yang-2022-7-28 /CheckIntegrity /Compress:max /Bootable /ConfigFile:C:\config.txt

  Note here that the parameters are separated by spaces (modify by yourself) 

Command explanation:

    /Capture-Image - specifies a capture image

    /ImageFile: - Specifies the image file path            

    /CaptureDir: - Specifies the capture directory

    /Name: - specifies the name, this item cannot be omitted

    /Description: - Specifies the description. The description is to illustrate the specific situation of this backup, we use the time here and this item can be omitted

   /ScratchDir: - Specifies the path to the scratch directory (must be local), if no scratch directory is specified, the \Windows\%Temp% directory will be used This directory must exist

      

  /Compress to specify the type of compression used for capture when exporting the image to a new WIM file

        OPTIONS /Compress:{fast|max|none} 

         fast general compression speed is fast max maximum compression speed is slow none uncompressed image file size is large

   /ConfigFile: Specify the configuration file path (the actual configuration file path must be placed here) I put the system disk path here

Extend to create an incremental backup 

Just change Capture-Image to Append-Image (other things remain unchanged, or remove redundant parameters)

Dism /Capture-Image /ImageFile:C:win11.wim /CaptureDir:C:\ /Name:Win11PRO /Description:Heart-Yang-2022-7-28 /CheckIntegrity /Compress:max /Bootable /ConfigFile:C:\config.txt

Important: Make sure there is enough disk space available to run the /Append-Image option. If you run out of disk space during image attach, the .wim file may become corrupted

@config file section

       Create a new text file (*.txt) that you can directly copy the ones I often use, or add it according to your needs, and save it as

ANSI-encoded files (special attention)

[ExclusionList]

\$ntfs.log

\hiberfil.sys

\pagefile.sys

\swapfile.sys

"\System Volume Information"

\RECYCLER

\Windows\CSC

\Software\WSL

\Software\NOX

\Users\Administrator\AppData\Local\Nox

\Software\Telegram Desktop\tdata\user_data

\Users\Administrator\Documents\Virtual Machines  

\Users\Administrator\Documents\Recordings

\Users\Administrator\AppData\Local\Temp

\Users\Administrator\AppData\Flash Player

[CompressionExclusionList]

*. mp3

*.dmp

*.cab

*.gid

*.chk

*.old

*.tmp

\WINDOWS\inf\*.pnf

Appendix 1: Some Available Options

    /Verify - Specifies verification. Used to check for errors and file duplication.

    /CheckIntegrity - Used to detect and track corruption of .wim files when they are used in capture, unmount, export, and commit operations. Used to stop DISM if it detects corruption of the .wim file during apply and mount operations.

    /ScratchDir: - Specifies the path to the scratch directory. This directory must exist. This directory must be local.

    /Compress: - Used to specify the type of compression to use for the initial capture operation. [/Compress:{fast|max|none}]

    The maximum option provides the best compression, but takes longer to capture the image.

    The fast option provides faster image compression, but produces larger files than those compressed with the maximum option, which is the default compression type used when no parameters are specified.

    The none option does not compress the captured image.

      

    /Bootable Use /Bootable to mark a Windows PE volume image as bootable.

    The recovery option exports a one-click reset image. The resulting file is significantly smaller, which in turn greatly reduces the amount of disk space required to save a push-key reset image on the recovery drive. Object files must be specified with an .esd extension.

    /ConfigFile: - Specifies the location of the image capture and compression command exclude list configuration file.

    Default exclusion list (some of my favorites are added here) - By default, the DISM.exe tool will exclude the following files:  

[ExclusionList]

\$ntfs.log

\hiberfil.sys

\pagefile.sys

\swapfile.sys

"\System Volume Information"

\RECYCLER

\Windows\CSC

\Software\WSL

\Software\NOX

\Users\Administrator\AppData\Local\Nox

\Software\Telegram Desktop\tdata\user_data

\Users\Administrator\Documents\Virtual Machines  

\Users\Administrator\Documents\Recordings

\Users\Administrator\AppData\Local\Temp

\Users\Administrator\AppData\Flash Player

[CompressionExclusionList]

*. mp3

*.dmp

*.cab

*.gid

*.chk

*.old

*.tmp

\WINDOWS\inf\*.pnf

============================================= [CompressionExclusionList] = Compression Exclusion List

Appendix 2: Specific usage of /ScratchDir command

    When creating or manipulating a Windows image, you should use the /ScratchDir option with DISM to create a scratch directory on a different drive. The temporary directory is useful for many DISM operations, including capturing an image, installing language packs, updating, or installing or removing Windows features from a Windows image. Expand some files to this temporary directory before applying them to the Windows image.

   /ScratchDir: - Specifies the path to the scratch directory

    Specifies a temporary directory to extract the service files from. This directory must exist.

    Specifies a temporary directory to use when extracting files for temporary use during serving. This directory must be local.

    After the installation is complete, the contents of this directory are no longer needed and can be deleted.

    If you do not set a scratch directory path with the /ScratchDir option, Windows PE will create a 32-MB scratch directory by default.

    If no temporary directory is specified, the \Windows\%Temp% directory is used, with subdirectory names of hexadecimal values ​​randomly generated each time DISM is run. Items in the staging directory are deleted after each operation.

    As a best practice, you should use the /ScratchDir option and instead specify the directory on another partition that has enough space to support any image management and servicing operations you perform.

    The problem of insufficient space in the temporary directory when running the DISM command usually occurs in the case of PE operation. The following is the complete command used in the backup and restore command /ScratchDir.

    Take the initial backup as an example (for example: back up the system of the C partition to the Win8BF folder of the D partition, the backup file name is Win8Pro.wim, and the designated temporary directory is D:\Temp):

    Dism /Capture-Image /ImageFile:D:\Win8BF\Win8Pro.wim /ScratchDir:D:\Temp /CaptureDir:C:\ /Name:Win8Pro-1 /Description:0000-00-00

    Note: A Temp folder must be created on the D disk first, and the D disk must have sufficient free space.

    Take restore as an example (for example: restore the second backup in D:\Win8BF\Win8Pro.wim to C partition, specify the temporary directory as D:\Temp):

Dism /Apply-Image /ImageFile:D:\Win8BF\Win8Pro.wim /Index:2 /ScratchDir:Z:\virtual machine sharing /ApplyDir:C:\

Image Example - Precautions

Precautions for System Backup in PE Mode 

Precautions for FirPE installation

 

Related Links

       Firpe download FirPE Project – perhaps the most suitable WinPE system for young people~

       Microsoft Dism Command Help  DISM Image Management Command Line Options | Microsoft Docs

       Comprehensive and detailed explanation of DISM commands  https://answers.microsoft.com/zh-hans/windows/forum/all/%E7%94%A8-dism/a3ea0d10-036c-41ff-8bb9-350c2bda525b

Supongo que te gusta

Origin blog.csdn.net/qq_41095608/article/details/126053334
Recomendado
Clasificación