📜 ⬆️ ⬇️

Free up hard disk space: WIMBoot

Today, stationary computers are beginning to slowly recede into the background. Their place is firmly occupied by laptops, and then go and tablet computers. The combination of mobility, high performance and high speed of obtaining information - all this is an undoubted advantage of tablets. However, the tablets have their own fly in the ointment: this is the small size of hard drives. If the disk is 16, 32 or even 64 GB, I don’t want to throw away valuable files on the installation files. With the release of Windows 8.1 Update, a solution to this problem appeared - WIMBoot is a new way to install the OS, providing more free space for the user.



Technology Overview


So, what is WIMBoot (Windows Image Boot)? This technology is designed for devices with a small amount of hard drives, with which it provides more space for user data and applications after installing the operating system. Immediately list the limitations when using WIMBoot:

What is the difference between WIMBoot and the usual Windows installation? In a typical Windows installation, each installation file is written to the disk twice: in compressed form in case of recovery and in unzipped form for use. Thus, the size of the space available to the user is reduced.
image
Standard partitioning scheme (without WIMBoot)


When installing Windows using WIMBoot, files are written to the hard disk only once and in compressed format. Next, the Pointer files, which refer to the compressed files in the image section, are applied to the Windows partition.

Partition diagram when using WIMBoot

')
What are the advantages of WIMBoot? From a technical point of view, the user will not notice the difference in the operation of the system. All user files will be visible and accessible without any transformations. At the same time, the place on the device will be much more. For example, with a typical installation of Windows 8.1 on a 16 GB hard disk, approximately 7 GB will be available to the user. In the case of installing the system from the WIMBoot image, the free space will increase, and about 12 GB will be available to the user.
Now we will try to create the WIMBoot image ourselves and deploy it. To do this, you need a Windows 8.1 Update image, Windows Assessment and Deployment Kit for Windows 8.1 and a Windows PE 5.1 ​​boot disk. To check the version of Windows PE in the wpeinit environment, you must run the registry editor ( regedit ) and check the following registration key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinPE 

If the WinPE version is 5.1, Windows PE may not be updated.
Start by installing the Windows ADK. To begin, install the following components from the Windows ADK for Windows 8.1: this is Deployment Image and Management and PE Environment ( download ). You can create a WIMBoot image both on a computer running Windows 8 and Windows 8.1, and on Windows Server 2012.
After the Windows ADK is installed, you need to run Deployment Image and Management as an administrator. It is with her and we have to work. Also, for convenience, we will use the following directory system:
 C:\Images – ,     C:\mount – ,      C:\MSU – ,       

Copy the install.wim file from the Windows 8.1 installation image to the C: \ Images directory.
Before describing in detail the process of creating a WIMBoot image, I will list the main steps that need to be done.
  1. Creating a WIMBoot image
    1. Creating a temporary copy of the Windows installation image
    2. Separate recovery image from main Windows image
    3. Image Optimization for WIMBoot
  2. Creating a WinPE 5.1 ​​Boot Disk
  3. Adding WIMBoot to the boot disk
  4. WIMBoot Deployment
    1. Formatting a hard disk using a WIMBoot partition scheme
    2. Adding Windows and Recovery Files
    3. WIMBoot folder protection

Further we will consider each of these steps in detail. At the end of the article as additional materials are detailed descriptions of the processes of updating the Windows image, the WinPE image, as well as instructions for checking the final WIMBoot image.

1. Creating a WIMBoot Image


Using updated Windows files, create a WIMBoot image.
1.1 Creating a temporary copy of the image for installing Windows

Copy the updated install.wim file to a new temporary file. This file will be used to install WIMBoot.
 Copy C:\Images\install.wim C:\Images\install_temp.wim 

Create a directory and mount the image there.
 md C:\mount\Windows Dism /Mount-Image /ImageFile:"C:\Images\install_temp.wim" /Index:1 /MountDir:C:\mount\Windows 

1.2 Separating the recovery image from the main Windows image

Move the Windows RE image ( winre.wim ) from the mounted directory. Add a few words about Windows RE. Windows Recovery Environment is an extensible recovery platform based on Windows PE. In the process of creating a WIMBoot image, the Windows RE image is recommended to separate from the main Windows image. Otherwise, the image will require approximately 200 MB of free hard disk space that will not be used. I also want to note that the winre.wim file is usually hidden, so it needs to be made visible.
 attrib –s -h C:\mount\Windows\Windows\System32\Recovery\winre.wim move C:\mount\Windows\Windows\System32\Recovery\winre.wim C:\images\winre.wim 

1.3 Image Optimization for WIMBoot

We optimize the image WIMBoot.
 Dism /Optimize-Image /Image:C:\mount\Windows /WIMBoot 

Unmount the image
 Dism /Unmount-Image /MountDir:C:\mount\Windows /Commit 


2. Creating a WinPE 5.1 ​​Boot Disk


Create a working copy of Windows PE files. Two versions of x86 or amd64 are available .
 copype amd64 C:\WinPE_amd64 

If necessary, update WinPE 5.0 to WinPE 5.1. A detailed description of the update process, see the appendix.
The next step is to create a WinPE 5.1 ​​boot disk. There are several possible options. In the simplest version, you can write files to a regular USB flash drive. The size of the flash card is better to choose 16 GB or more, because It will be necessary to do some further manipulations with the image, for which additional space will be needed. You can create a bootable USB flash drive using the command:
 MakeWinPEMedia /UFD C:\WinPE_amd64 F: 

In my case, WIMBoot was tested on a Hyper-V virtual machine. To simulate the standard installation process of WIMBoot on a tablet from a flash drive, I will use a virtual hard disk and describe the process of creating it. To write a Windows PE image to VHD, we use the diskpart tool and enter the following commands:
 Diskpart create vdisk file=”C:\WinPE.vhdx” maximum=16000 attach vdisk create partition primary assign letter=V format fs=ntfs quick exit 

Next, write the WinPE files to the virtual disk we created.
 MakeWinPEMedia /UFD C:\WinPE_amd64 V: 

Run diskpart again and finish creating the disk.
 Diskpart select vdisk file=”C:\WinPE.vhdx” detach vdisk exit 


3. Adding WIMBoot to the boot disk


After the WinPE 5.1 ​​image has been created and the WIMBoot image has been prepared, you can close Deployment Image and Management. We will continue to work without it. Now you need to add the WIMBoot image files to the WinPE 5.1 ​​disk (copy the entire Images folder). Also, I recommend adding some diskpart scripts to the bootdisk , which will save us time when creating and deploying a WIMBoot image. These scripts are optional, you can add them later or not add to the image at all.
You can add WIMBoot to a boot disk on absolutely any computer or virtual machine, as long as they comply with the restrictions imposed by WIMBoot technology. I will continue to work with the virtual machine and create a second-generation virtual machine ( Generation 2 ) in Hyper-V, which supports UEFI technology. As an image for installing the operating system, I will point to the WinPE.vhdx virtual disk created earlier. I created a WinPE image with WIMBoot on a virtual machine with a hard disk size of 32 GB. And installing the system using WIMBoot already on a virtual machine with a hard disk size for the virtual machine being created will be 16 GB to simulate installation on a tablet with a small hard disk size. We load the virtual machine from the WinPE.vhdx disk and wait for the wpeinit utility to start (it may take a few minutes).
Use the diskpart utility to create hard disk partitions. You can run the script below with the command
 diskpart /s C:\Createpartition.txt 

You can check the location of the script file by running the diskpart utility and the list volume command. You must specify the path to the WinPE drive.
 rem == CreatePartitions.txt == select disk 0 clean convert gpt rem ==      == create partition primary size=300 format quick fs=ntfs label=”Windows RE tools” assign letter=”T” set id=”de94bba4-06d1-4d40-a16a-bfd50179d6ac” gpt attributes=0x8000000000000001 rem ==    == create partition efi size=100 format quick fs=fat32 label=”System” assign letter=”S” rem ==   MSR == create partition msr size=128 rem ==   Windows == create partition primary shrink minimum=10000 format quick fs=ntfs label=”Windows” assign letter=”W” rem ==     == create partition primary format quik fs=ntfs label=”Recovery image” assign letter=”R” set id=”de94bba4-06d1-4d40-a16a-bfd50179d6ac” gpt attributes=0x8000000000000001 list volume exit 

A small comment about the team
 set id=”de94bba4-06d1-4d40-a16a-bfd50179d6ac” gpt attributes=0x8000000000000001 

Using the above script does not allow the user to see recovery partitions through explorer, however, through the Disk Management Tools, the user can delete these partitions. To prevent the deletion of recovery partitions and use the above command.
After executing this script, you should see something like the following.

As a result, we got the following sections (MSR is a Microsoft backup section and is not displayed in the output of this command):

Next, perform the installation image. First, create a directory on the R drive and copy the installation image there.
 md R:\RI copy C:\Images\install.wim R:\RI\install.wim 

Apply the install.wim image to the Windows partition.
 dism /Apply-Image /ImageFile:R:\RI\install.wim /Index:1 /ApplyDir:W:\ 

Copy the recovery tools to the Windows RE partition.
 md T:\Recovery\WindowsRE attrib –s –h W:\windows\system32\recovery\winre.wim copy W:\windows\system32\recovery\winre.wim T:\Recovery\WindowsRE\winre.wim 

Copy the boot files from the Windows partition to the System partition. This step is needed in order to download a deployed image.
 bcdboot W:\Windows 

Register a Windows partition and a recovery partition
 W:\Windows\System32\reagentc /setosimage /path R:\RI /target W:\Windows /index 1 W:\Windows\System32\reagentc /setreimage /path T:\Recovery\WindowsRE /target W:\Windows 

Restart the computer. With a new boot, wait for the screen to start setting.

When it appears, you must press the CTRL + SHIFT + F3 combination to restart the computer in audit mode. After that, the computer will start the system under the account of the local administrator. In a Windows 8.1 environment, you will need to run a command prompt with Administrator rights and clean up the image. Cleaning the image will free up additional disk space.
 dism /Cleanup-Image /Online /StartComponentCleanup 

After that, using the Sysprep command, we will prepare the computer for use and complete the work.
 C:\Windows\System32\Sysprep\sysprep /generalize /shutdown /oobe 

Start the computer again in WinPE mode. I recommend running the diskpart utility and the list volume command. You must have letters assigned to the Windows disk and to the WinPE disk. All other sections are hidden.

Create a directory for temporary files C: \ Recycler \ Scratch and re-capture the image, but with the option WIMBoot.
 DISM /Capture-Image /WIMBoot /ImageFile:"D:\Images\install_wimboot.wim" /CaptureDir:C: /Name:"WIMBoot Enterprise_x64 with 8.1 Updates" /ScratchDir:C:\Recycler\Scratch 

After the command is completed, we can turn off the computer. Now on our virtual disk or on a flash drive there is a WIMBoot installation image.

4. Deploy WIMBoot


Now it remains only to test the WIMBoot image and make sure that the size of the files occupied by Windows will decrease. As mentioned earlier, the installation will use a second-generation virtual machine that supports UEFI technology with a hard disk capacity of 16 GB. As the installation disk, use the WinPE.vhdx virtual disk and start the virtual machine.
4.1 Formatting a hard disk according to the WIMBoot partition scheme

Let's wait for the wpeinit environment to start , run the diskpart utility and the list volume command. If the letter C is assigned to the WinPE partition, I recommend reassigning it with the following commands.
 select volume=0 assign letter=”D” exit 

Now, using the diskpart utility and the script below, we create partitions for installation. Run the script with the command
 diskpart /s D:\WimCreatePartition.txt 


 rem == WimCreatePartition.txt == select disk 0 clean convert gpt rem ==    == create partition efi size=100 format quick fs=fat32 label=”System” rem ==   MSR == create partition msr size=128 rem ==   Windows == create partition primary shrink minimum=5000 format quick fs=ntfs label=”Windows” assign letter=”” rem ==     == create partition primary format quick fs=ntfs label=”Images” assign letter=”M” set id=”de94bba4-06d1-4d40-a16a-bfd50179d6ac” gpt attributes=0x8000000000000001 list volume exit 

As a result, we should get the following result:

4.2 Adding Windows and Recovery Files

Create a folder “Windows Images” in the Images section. The folder name must be “Windows Images”.
 md "M:\ Windows Images \" 

Copy the Windows image from the WinPE disk to the Windows Images folder and rename it to install.wim , if necessary.
 copy D:\Images\install_update1.wim "M:\Windows Images\install.wim" 

Apply a Windows image to a Windows partition using the / WIMBoot command . Before this, we create a directory for temporary files to avoid problems with short file names.
 md C:\Recycler\Scratch DISM /Apply-Image /ImageFile:"M:\Windows Images\install.wim" /ApplyDir:C: /Index:1 /WIMBoot /ScratchDir:C:\Recycler\Scratch 

Create download files and configure them to work in the Windows partition.
 C:\Windows\System32\bcdboot C:\Windows 

Copy the Windows Recovery Environment Image to the Images folder
 md M:\Recovery\WindowsRE echo f | xcopy D:\Images\winre.wim M:\Recovery\WindowsRE\winre.wim /h 

Register a Windows recovery environment partition.
 C:\Windows\System32\Reagentc /SetREImage /Path M:\Recovery\WindowsRE /Target C:\Windows 

4.3 WIMBoot folder protection

It remains to protect the sections of Windows images and verify the results. To set the attribute "read only" in the environment wpeinit run the following commands
 icacls "M:\Windows Images" /inheritance:r /T icacls "M:\Windows Images" /grant:r SYSTEM:(R) /T icacls "M:\Windows Images" /grant:r *S-1-5-32-544:(R) /T 

Now you just have to start the computer and see a nice picture:

What happened? Now the free disk on the Windows partition has become more. This is due to the fact that the Windows partition now contains pointer files that refer to Windows images. In this case, the user does not feel the difference in the work: all his files are working normally.

In conclusion, I want to additionally note that if there is a need to add any additional settings to the WIMBoot image, this can be done before the WIMBoot folders are protected. Further information on WIMBoot can be found on TechNet .

I hope the information will be useful!

application


Install Update: WinPE 5.0 -> WinPE 5.1
Let's move on to creating WinPE and updating it. Basically, you can first simply create WinPE, try to download the target computer with it and check its version. However, here I will give the whole process of creating an image.
A working copy of the Windows PE files must first be created.
Mount the Windows PE image
 Dism /Mount-Image /ImageFile:"C:\WinPE_amd64\media\sources\boot.wim" /index:1 /MountDir:"C:\WinPE_amd64\mount" 

Add service packs to your Windows PE image. The set of service packs is the same as was used to update the Windows 8.1 image can be downloaded here . It is important when downloading the package KB2919355 also download packages KB2919355 , KB2932046 , KB2934018 , KB2937592 , KB2938439 , and KB2959977 . Packages must be installed in order and separately.
 Dism /Add-Package /PackagePath:C:\MSU\Windows8.1-<Package>-<arch>.msu /Image:C:\mount\Windows /LogPath:AddPackage.log 

We optimize the image
 Dism /Image::\WinPE_amd64\mount /Cleanup-Image /StartComponentCleanup /ResetBase 

Unmount the Windows PE image
 Dism /Unmount-Image /MountDir:"C:\WinPE_amd64\mount" /commit 

Export and convert a Windows PE image to a new wim file
 Dism /Export-Image /SourceImageFile:C:\WinPE_amd64\media\sources\boot.wim /SourceIndex:1 /DestinationImageFile:C:\WinPE_amd64\media\sources\boot2.wim 

Replace the boot.wim file with the new boot2.wim file
 del C:\WinPE_amd64\media\sources\boot.wim rename C:\WinPE_amd64\media\sources\boot2.wim boot.wim 


WIMBoot Image Verification
And now I will give the commands to check the WIMBoot image that must be run in the wpeinit environment.
  • Check for System, MSR, Windows, and Images

 diskpart select disk 0 select partition 3 assign letter C select partition 4 assign letter M list partition exit 

Expected Result:

  • Checking the attributes of the Images section

 diskpart select disk 0 select partition 4 detail partition exit 

Expected Result:

  • Scanning files in the Images section and recovery files

 dir "M:\Windows Images" dir M:\Recovery\WindowsRE 

Expected Result:


  • In a Windows Recovery Environment, the location of a valid recovery image must be correctly specified.

 C:\Windows\System32\Reagentc /Info /Target C:\Windows 

Expected Result:



Installing updates on a Windows 8.1 image
Mount the Windows Image
 md C:\mount\Windows Dism /Mount-Image /ImageFile:"C:\Images\install.wim" /Index:1 /MountDir:C:\mount\Windows 

Install updates KB2919442 and KB2919355 . These packages are available for various processor architectures: x86 , x64 and arm . Download packages here . Update packages must be installed in order and separately.
 Dism /Add-Package /PackagePath:C:\MSU\Windows8.1-<Package>-<arch>.msu /Image:C:\mount\Windows /LogPath:AddPackage.log 

Hereinafter - the name of the package, and - the processor architecture.
Mount the image of Windows RE
 md C:\mount\WinRE Dism /Mount-Image /ImageFile:"C:\mount\Windows\Windows\System32\Recovery\winre.wim" /Index:1 /MountDir:C:\mount\WinRE 

Update the WinRE image using the same packages that were used when updating the Windows image
 Dism /Add-Package /PackagePath:C:\MSU\Windows8.1-<Package>-<arch>.msu /Image:C:\mount\WinRE /LogPath:AddPackage.log 

Additionally, we perform a cleanup of the image in order to remove some elements and reduce the final size of the image. This step is optional, but it can be performed only at this stage: after launch, it will be impossible to clean the image.
 Dism /Cleanup-Image /Image:C:\mount\WinRE /StartComponentCleanup /ResetBase 

Now you can unmount the Windows RE image.
 Dism /Unmount-Image /MountDir:C:\mount\WinRE /Commit 

To see the changes in the file size, the image must be exported.
 Dism /Export-Image /SourceImageFile:C:\mount\Windows\Windows\System32\Recovery\winre.wim /SourceIndex:1 /DestinationImageFile:C:\Images\winre_updated.wim 

After export, you need to replace winre.wim with a new version.
 attrib –s -h C:\mount\Windows\Windows\System32\Recovery\winre.wim Del C:\mount\Windows\Windows\System32\Recovery\winre.wim copy C:\Images\winre_updated.wim C:\mount\Windows\Windows\System32\Recovery\winre.wim 

After the updates are installed, you can unmount the Windows image
 Dism /Unmount-Image /MountDir:C:\mount\Windows /Commit 

Source: https://habr.com/ru/post/230757/


All Articles