[Tutorial] Saving Space on SSDs with WIMBoot (For Windows 8.1U1) -- Synopsis -- If you are building a computer and would like to save space on your SSD (or would like to install Windows on an SSD that is as small as 16GB), this tutorial shows you how to set up WIMBoot- a new feature in Windows 8.1U1 that shrinks the size of a Windows install to less than 7GB (compared to 12GB-16GB) This is only compatible with UEFI computers. -- Words of Warning -- Installing WIMBoot requires you to completely reinstall Windows. The benefit to using WIMBoot is that it allows you to more easily set up the Windows Refresh functionality (allowing you to reset your computer without having to reinstall your drivers), and frees up an extra 5GB-9GB of space (excellent for people running SSDs that are 64GB or smaller!) Please have lots of patience while doing this; if you have never deployed Windows manually before, the steps below will require quite a learning curve, and you'll have to follow the steps very closely. If you need help, or are not clear on the instructions, post on this topic and I will reply to you in order to clear things up. If you have suggestions for making this tutorial more clear and concise, please feel free to say so! What you will need to install Windows 8.1U1 with WIMBoot: 1. A Windows 8.1 Pro Update 1 ISO 2. Windows ADK for 8.1 Update 3. A USB drive that's 8GB or larger. Here's the outline of how to create a WIMBoot Install: -- [Part 1] Creating a WIMBoot Image --(Click this link for Microsoft's full guide) 1. Copy Install.wim from your Windows 8.1 Update 1 ISO. (Located in the "sources" folder) 2. Export Index 1 from Install.wim. Index 1 is Pro while Index 2 is Core (AKA Home) Code: Dism /Export-Image /SourceImageFile:C:\PathToInstallDotWim\install.wim /SourceIndex:1 /DestinationImageFile:C:\WhereYouWantTheImage\install_wimboot.wim 3. Move Winre.wim out of install.wim Code: md C:\Mount\Windows md C:\Images Dism /Mount-Image /ImageFile:"C:\Images\install.wim" /Index:1 /MountDir:C:\mount\Windows attrib –s -h C:\mount\Windows\Windows\System32\Recovery\winre.wim move C:\mount\Windows\Windows\System32\Recovery\winre.wim C:\images\winre.wim 4. Optimize the image for WIMBoot Code: Dism /Optimize-Image /Image:C:\mount\Windows /WIMBoot 5. Finally, unmount the image. Code: Dism /Unmount-Image /MountDir:C:\mount\Windows /Commit -- [Part 2] Creating a WinPE 5.1 USB Drive (or ISO! USB drives are better, IMO) -- 1. Download the updates for Windows 8.1 Update 1 KB2919355 KB2919442 (Yes, you need to download all the .MSU packages) 2. Move the .MSU packages you just downloaded to C:\MSU. You can use another directory but must edit your commands as necessary. 3. Copy WinPE 5.0 somewhere (Or use the location provided) Code: copype amd64 C:\WinPE_amd64 4. Mount the WinPE 5.0 image Code: Dism /Mount-Image /ImageFile:"C:\WinPE_amd64\media\sources\boot.wim" /index:1 /MountDir:"C:\WinPE_amd64\mount" 5. Apply the updates to WinPE 5.0 Code: Dism /Add-Package /PackagePath:C:\MSU\Windows8.1-KB2919442-x64.msu /Image:C:\WinPE_amd64\mount /LogPath:AddPackage.log Dism /Add-Package /PackagePath:C:\MSU\Windows8.1-KB2919355-x64.msu /Image:C:\WinPE_amd64\mount /LogPath:AddPackage.log Dism /Add-Package /PackagePath:C:\MSU\Windows8.1-KB2932046-x64.msu /Image:C:\WinPE_amd64\mount /LogPath:AddPackage.log Dism /Add-Package /PackagePath:C:\MSU\Windows8.1-KB2934018-x64.msu /Image:C:\WinPE_amd64\mount /LogPath:AddPackage.log Dism /Add-Package /PackagePath:C:\MSU\Windows8.1-KB2937592-x64.msu /Image:C:\WinPE_amd64\mount /LogPath:AddPackage.log Dism /Add-Package /PackagePath:C:\MSU\Windows8.1-KB2938439-x64.msu /Image:C:\WinPE_amd64\mount /LogPath:AddPackage.log Dism /Add-Package /PackagePath:C:\MSU\Windows8.1-KB2959977-x64.msu /Image:C:\WinPE_amd64\mount /LogPath:AddPackage.log 6. Clean up the image to decrease the space it takes up. Code: Dism /image:c:\WinPE_amd64\mount /Cleanup-Image /StartComponentCleanup /ResetBase 7. Unmount the image. Code: Dism /Unmount-Image /MountDir:"C:\WinPE_amd64\mount" /commit 8. Create the WinPE USB drive! (Change F: to the drive letter of the flash drive!) Code: MakeWinPEMedia /UFD C:\WinPE_amd64 F: -- [Part 3] Installing WIMBoot to your device -- Outline: Clean the drive, partitition it, and apply install.wim. Part 3.1 Preparing the drive for WIMBoot At this point you will want to boot from the WinPE USB drive you just created. Install.wim and Winre.wim can either be put on the USB drive, a network drive, or an external hard drive. Launch DiskPart and issue the following commands: (It is easier to add the commands to a .txt file and run "diskpart /s script.txt") a. Select the Disk (If you don't know the disk number, type in "list disk" and select the disk you are planning on install to) Code: Select Disk 0 b. Create the System partition. Code: create partition efi size=100 format quick fs=fat32 label="System" c. Create the MSR Partition Code: create partition msr size=128 d. Create the Windows partition [code]create partition primary format quick fs=ntfs label="Windows" assign letter=C Part 3.2 Applying the Windows Install File Use the command prompt in WinPE to issue the following commands. a. Create the required folders for install.wim and winre.wim, and the Scratch folder. Code: md "C:\Recycler\Scratch\" md "C:\Recycler\WIMs\ md "C:\Reycler\WinRE\" b. Copy install.wim to C:\Reycler\WIMs\ Code: copy D:\Images\install.wim C:\Reycler\WIMs\install.wim c. Apply install.wim to C:\ (WIM_SKIP_WIMBOOT_CHECK=1 is required) Code: SET WIM_SKIP_WIMBOOT_CHECK=1 dism /Apply-Image /ImageFile:"C:\Recycler\WIMs\install.wim" /ApplyDir:C: /Index:1 /WIMBoot /ScratchDir:C:\Recycler\Scratch d. Create the boot file for Windows. Code: C:\Windows\System32\bcdboot C:\Windows e. Copy winre.wim to C:\Recycler\WinRE\ and set it as hidden. Code: echo f|xcopy D:\Images\winre.wim C:\Recycler\WinRE\winre.wim /h -- Part 4: Adding your drivers to Windows and preparing to create custom.wim-- Part 4.1: Install your drivers, clean up the install, and capture custom.wim Once have you booted to Windows, you will be at the OOBE screen (Out of Box Environment). To install your drivers without creating a user account, you will need to enter Audit Mode. To do this, simply press CTRL+SHIFT+F3 at the OOBE screen. Windows will reboot and automatically log in as the Administrator account. At this point, you can use the computer. You are going to want to install all of the drivers for your computer, plus any applications that you want to have installed if you decide to reset the system at a later time. Keep in mind that you cannot change this afterwards, whatever you install now will be installed whenever you reset the PC. The only way to change it later is to start this process over from the beginning. Once you have added all of your drivers and programs, run the following commands: Code: Dism /Online /Cleanup-Image /StartComponentCleanup DISM /Capture-CustomImage /CaptureDir:C: /ScratchDir:C:\Recycler\Scratch And once you have entered the above commands, prepare the system for OOBE and shut it down with the following command: Code: C:\Windows\System32\Sysprep\Sysprep /OOBE /shutdown /generalize Part 4.2: Reboot back into WinPE and finalize the installation. For this part, you are going to want to use the script provided. The basic overview of the script is that it calculates the size required for the Images partition, creates the partition, copies the files over, and assigns all the files to your Windows installation. This script is directly from Microsoft's WIMBoot deployment guide. I did not create it myself. Code: goto __start /************************************************************* Sample Script: CalculateAndCreateWIMBootPartition.cmd Use this script to calculate the size needed for the WIMBoot Images partition after applying your final factory settings. Prerequisites: - Boot the PC into Windows PE 5.1 - The primary hard drive (disk 0) has three partitions: 1. System partition (ESP) 2. MSR 3. Windows partition - the rest of disk 0 - install.wim is in this partition - install.wim has been applied to this same partition - Complete the final factory floor customization - Capture custom.wim, and store it in the Windows partition, in the same folder as install.wim - Customize winre.wim, and store it in the Windows partition After this script is run: - The primary hard drive (disk 0) has four partitions: 1. System partition (ESP) 2. MSR 3. Windows partition (calculated) 4. Images partition (calculated) The Images partition will include: - install.wim, custom.wim, winre.wim - Any other OEM tools/scripts - 50 MB of additional free space **************************************************************/ REM The script starts here :__start @echo off echo %date%-%time%:: Start of script %0 ,,, if "%1" equ "" ( echo This script calculates the size needed for the Images partition and sets it up. echo Usage: echo CalculateAndCreateWIMBootPartition.cmd ^<letter of Windows volume^> ^<path to install.wim and custom.wim^> ^<path to winre.wim^> ^<additional free space to be added to Images partition in megabytes. If no additional space is needed, use 0.^> echo Example: echo CalculateAndCreateWIMBootPartition C: C:\Recycler\WIMs\ C:\Recycler\WIMs 300 exit /b 0 ) REM --- Constants used to calculate free space --- REM Overhead Ratio: assume 6 MB overhead per 1000 MB size set /a NTFS_OVERHEAD_RATIO=500/497 REM Per-Partition Overhead: 5 MB per partition set /a NTFS_OVERHEAD_BASE=5 REM Megabytes-to-Millions Ratio: REM This ratio converts values from megabytes to millions of bytes, approximately. set /a mega_million_ratio=205/215 REM --------- Constants ------------- REM Drive letter of the Windows partition. Example: C: set user_volume=%1 REM Path that contains install.wim and custom.wim. Example: C:\Recycler\WIMs\ set wimfile_path=%2 REM Path that contains winre.wim. Example: C:\Recycler\WIMs set winre_wim_path=%3 REM Additional size to be added to Images partition in megabytes. Example: 300 set more_size=%4 echo Check input Windows volume {%user_volume%} is accessible: echo dir %user_volume%\ /a dir %user_volume%\ /a if not exist %user_volume%\ ( echo %user_volume%\ not found. Exiting script. pause exit /b 3 ) echo Check if the install.wim and custom.wim files {%wimfile_path%} are accessible: echo dir %wimfile_path%\ /a dir %wimfile_path%\ /a if not exist %wimfile_path%\install.wim ( echo %wimfile_path%\install.wim not found. Exiting script. pause exit /b 3 ) if not exist %wimfile_path%\custom.wim ( echo %wimfile_path%\Custom.wim not found. Exiting script. pause exit /b 3 ) echo Check if the winre.wim file {%winre_wim_path%} is accessible: echo dir %winre_wim_path%\ /a dir %winre_wim_path%\ /a if not exist %winre_wim_path%\winre.wim ( echo %winre_wim_path%\winre.wim not found. Exiting script. exit /b 3 ) echo --------- Calculate install.wim size ,,, for %%A in (%wimfile_path%\install.wim) do ( set install_wim_file_bytes=%%~zA echo install.wim is [%install_wim_file_bytes%] bytes. ) set /a install_wim_file_MB=%install_wim_file_bytes:~0,-6%+0 echo After cutting off last 6 digits = [%install_wim_file_MB%] set /a install_wim_file_MB=%install_wim_file_MB%*205/215 echo Final approximate size: [%install_wim_file_MB%] MB echo --------- Calculate custom.wim size ,,, for %%A in (%wimfile_path%\custom.wim) do ( set custom_wim_file_bytes=%%~zA echo custom.wim is [%custom_wim_file_bytes%] bytes. ) set /a custom_wim_file_MB=%custom_wim_file_bytes:~0,-6% echo After cutting off last 6 digits = [%custom_wim_file_MB%] set /a custom_wim_file_MB=%custom_wim_file_MB%*205/215 echo Final approximate size: [%custom_wim_file_MB%] MB echo --------- Calculate {%winre_wim_path%\winre.wim} size ,,, for %%A in (%winre_wim_path%\winre.wim) do ( set winre_wim_file_bytes=%%~zA echo winre.wim is [%winre_wim_file_bytes%] bytes. ) set /a winre_wim_file_MB=%winre_wim_file_bytes:~0,-6% echo After cutting off last 6 digits = [%winre_wim_file_MB%] set /a winre_wim_file_MB=%winre_wim_file_MB%*205/215 echo Final approximate size: [%winre_wim_file_MB%] MB echo Calculate Images partition size ,,, echo Adding 50MB free space to input size {%more_size%}. This ensures Images partition have 50MB free space. set /a more_size=%more_size%+50 set /a wim_partition_size_MB=%install_wim_file_MB%+%custom_wim_file_MB% echo Size sum of install.wim and custom.wim = {%wim_partition_size_MB%} MB set /a wim_partition_size_MB=%wim_partition_size_MB%+%winre_wim_file_MB% echo Total size of the 3 .WIM files = {%wim_partition_size_MB%} MB set /a wim_partition_size_MB=%wim_partition_size_MB%+%more_size% echo Size after adding specified space and 50MB = {%wim_partition_size_MB%} MB set /a wim_partition_size_MB=%wim_partition_size_MB%+%NTFS_OVERHEAD_BASE% set /a wim_partition_size_MB=%wim_partition_size_MB%*500/497 echo Final Images partition size = {%wim_partition_size_MB%} MB echo Remove the hibernation file, if it exists. icacls C:\hiberfil.sys /grant everyone:f del C:\hiberfil.sys /ah echo Find out if we are in BIOS mode, or UEFI mode,,, echo reg query HKLM\System\CurrentControlSet\Control /v PEFirmwareType reg query HKLM\System\CurrentControlSet\Control /v PEFirmwareType for /f "tokens=2*" %%X in ('reg query HKLM\System\CurrentControlSet\Control /v PEFirmwareType') DO (SET _Firmware=%%Y) if %_Firmware%==0x1 ( echo The PC is booted in BIOS mode. Note: BIOS is not supported for WIMBoot. Exiting script. pause exit /b 3 ) if %_Firmware%==0x2 echo The PC is booted in UEFI mode. echo Create a diskpart script to shrink Windows partition {%user_volume%} by desired size of {%wim_partition_size_MB%} ,, set wim_partition_letter=M: echo. > %~dp0dps.txt echo list disk >> %~dp0dps.txt echo list volume >> %~dp0dps.txt echo select disk 0 >> %~dp0dps.txt echo list partition >> %~dp0dps.txt echo select volume %user_volume% >> %~dp0dps.txt echo list partition >> %~dp0dps.txt echo list volume >> %~dp0dps.txt echo shrink minimum=%wim_partition_size_MB% >> %~dp0dps.txt echo list partition >> %~dp0dps.txt echo list volume >> %~dp0dps.txt echo create partition primary size=%wim_partition_size_MB% >> %~dp0dps.txt rem BIOS ONLY (Does not apply to WIMBoot): echo set id=27 OVERRIDE NOERR >> %~dp0dps.txt echo set id=de94bba4-06d1-4d40-a16a-bfd50179d6ac OVERRIDE NOERR >> %~dp0dps.txt if %_Firmware%==0x2 ( echo gpt attributes=0x8000000000000001 >> %~dp0dps.txt ) echo list volume >> %~dp0dps.txt echo list partition >> %~dp0dps.txt echo format quick fs=ntfs label=images >> %~dp0dps.txt echo assign letter=%wim_partition_letter% >> %~dp0dps.txt echo list volume >> %~dp0dps.txt echo list partition >> %~dp0dps.txt echo exit >> %~dp0dps.txt echo =================== the script has: type %~dp0dps.txt echo ================================== echo %date%-%time%:: Running diskpart /s %~dp0dps.txt ,,, diskpart /s %~dp0dps.txt echo dir %wim_partition_letter%\ dir %wim_partition_letter%\ md "%wim_partition_letter%\Windows Images" md "%wim_partition_letter%\Recovery\WindowsRE" robocopy %wimfile_path%\ "%wim_partition_letter%\Windows Images"\ *wim /z echo dir %wim_partition_letter%\ dir %wim_partition_letter%\ echo dir "%wim_partition_letter%\Windows Images" dir "%wim_partition_letter%\Windows Images" echo dir %winre_wim_path%\winre.wim dir %winre_wim_path%\winre.wim echo robocopy %winre_wim_path%\ %wim_partition_letter%\Recovery\WindowsRE\ winre.wim robocopy %winre_wim_path%\ %wim_partition_letter%\Recovery\WindowsRE\ winre.wim ) rem Register Windows RE echo %date%-%time%:: %user_volume%\Windows\System32\reagentc.exe /setreimage /path %wim_partition_letter%\Recovery\WindowsRE /target %user_volume%\Windows %user_volume%\Windows\System32\reagentc.exe /setreimage /path %wim_partition_letter%\Recovery\WindowsRE /target %user_volume%\Windows echo %date%-%time%:: Running Dism /english /logpath=%wimfile_path%\dism.log /scratchdir=%wimfile_path%\ /get-wimbootentry /path=%user_volume%\ piping into %~dp0temp.txt ,,, dism /english /logpath=%wimfile_path%\dism.log /scratchdir=%wimfile_path%\ /get-wimbootentry /path=%user_volume%\ 1> %~dp0temp.txt 2>&1 type %~dp0temp.txt set output_text=%~dp0temp.txt find /i "install.wim" %output_text% if %errorlevel% neq 0 ( echo The file: install.wim not found. Script failed, exiting. pause exit /b %errorlevel% ) echo Found install.wim, good. for /f "skip=4 tokens=1,2,3,4,5" %%a in (%output_text%) do ( if /i "%%a %%b %%c %%d" equ "Data Source ID :" ( set ds_id_install_wim=%%e ) if /i "%%~nxd" equ "install.wim" ( set wimfile_install_wim=%%~nxd & goto _end_for1 ) ) :_end_for1 echo dsid=%ds_id_install_wim% echo wim=%wimfile_install_wim% find /i "custom.wim" %output_text% if %errorlevel% neq 0 ( echo The file: custom.wim is not found. Script failed, exiting. pause exit /b 2 ) echo Found custom.wim, for /f "skip=4 tokens=1,2,3,4,5" %%a in (%output_text%) do ( if /i "%%a %%b %%c %%d" equ "Data Source ID :" ( set ds_id_custom_wim=%%e ) if /i "%%~nxd" equ "custom.wim" ( set wimfile_custom_wim=%%~nxd & goto _end_for2 ) ) :_end_for2 echo dsid=%ds_id_custom_wim% echo wim=%wimfile_custom_wim% echo %date%-%time%:: Running Dism /logpath=%wimfile_path%\dism.log /scratchdir=%wimfile_path%\ /update-wimbootentry /path=%user_volume%\ /imagefile="%wim_partition_letter%\Windows Images\install.wim" /datasourceID=%ds_id_install_wim% ,,, dism /logpath=%wimfile_path%\dism.log /scratchdir=%wimfile_path%\ /update-wimbootentry /path=%user_volume%\ /imagefile="%wim_partition_letter%\Windows Images\install.wim" /datasourceID=%ds_id_install_wim% echo %date%-%time%:: Running Dism /logpath=%wimfile_path%\dism.log /scratchdir=%wimfile_path%\ /update-wimbootentry /path=%user_volume%\ /imagefile="%wim_partition_letter%\windows images\custom.wim" /datasourceID=%ds_id_custom_wim% ,,, dism /logpath=%wimfile_path%\dism.log /scratchdir=%wimfile_path%\ /update-wimbootentry /path=%user_volume%\ /imagefile="%wim_partition_letter%\Windows Images\custom.wim" /datasourceID=%ds_id_custom_wim% if %errorlevel% neq 0 ( echo ERROR: Dism failed. Exiting script. pause exit /b %errorlevel% ) echo Setting permissions (ACLS) on "%wim_partition_letter%\Windows Images" ,,, icacls "%wim_partition_letter%\Windows Images" /grant:r SYSTEM:(F) /T icacls "%wim_partition_letter%\Windows Images" /inheritance:r /T icacls "%wim_partition_letter%\Windows Images" /grant:r *S-1-5-32-544:(R) /T icacls "%wim_partition_letter%\Windows Images" /grant:r SYSTEM:(R) /T echo %date%-%time%:: All done. Errorlevel={%errorlevel%} dir %wim_partition_letter%\ /s /a echo *************** PLEASE MAKE SURE TO BOOT THE OS echo IN ORDER TO LET NEW WIMBOOT ENTRIES TAKE EFFECT ***************** echo ------- After booted to the OS, you can delete the .wim files under echo {%wimfile_path%} to regain space on Windows partition {%user_volume%} echo ---------------- Add the following code to a scipt, which I called "Finalize.cmd". Then, run the following command from WinPE: Code: Finalize.cmd C: C:\Recycler\WIMs\ C:\Recycler\WinRE 0 Boot Windows again, and you're almost done. Once you have created a user, you can delete the C:\Reycler\WIMs\ and C:\Recycler\WinRE\ folders. Do not delete these folders before you boot Windows! You're done! You have succesfully deployed Windows 8.1 Update 1 with WIMBoot and saved between 5GB-9GB of space on your SSD.
Is no one interested in this? A few notes: This allows installations on SSDs/eMMCs as small as 16GB, and leaves 64GB SSDs with 50GB+ of free space! This is compared to ~40GB.
It is not necessary to re-install Windows to do the WIMBoot procedure. Google "WIMBoot ipaqman" to find a simplified procedure to do a WIMBoot on a Dell Venue 8 Pro. The simplified procedure is automated and is designed for a standard 32 bit Windows with only a C drive on the SSD/eMMC drive. I have done this procedure with a fresh Windows re-install and with my five month old Windows installation with Metro apps and office applications. I did this to my Dell Venue 8 Pro tablet and gained 12 GB of disk space. I have even run the procedure again on a WIMBooted installation. As was mentioned, a PC Reset will re-install Windows as it was WIMBooted. In my case, a re-install will put back my five month old Windows. The only way I can reset my Windows to stock is to boot from a WinPE USB drive that has a WIMBoot from a factory stock setup. I have found no performance change or battery use change after the WIMBoot. With this simplified procedure, you need only make sure that your Windows is 8.1 update 1, then run sysprep /oobe /shutdown. Then reboot to the WinPE USB drive and wait two hours or so.
Either way, good info guys. Might give this all a whirl next time I reinstall Windows. I've read about this before but never tried it in practice.
I have built truly one-click software which converts any pre-existing Windows 8.1 Update 1 system to WIMBoot. This tool is called DoubleSpace and is available from zipmagic dot co slash doublespace.html. You will not need external storage, a Windows PE environment, manually created images - or anything of the sort - to use DoubleSpace. DoubleSpace runs in one-click, and all you need to choose is compression strength - 4 are available, between MaxSpeed - MaxSpace. You can even recompress a disk that has been previously compressed. I trust you will enjoy using the tool as much as I enjoyed building it. I welcome any feedback!
AMAZING thread. Looking forward to read it all and learn. But before doing it , I 'd have to say THANKS to Derragon (and maybe zipmagic? I'll try the tool too)