Share
Go down
dim

Compact OS

on Tue 6 Mar 2018 - 8:42
Even MS realized its own product bloatware and equipped Windows 10 with real time compression and called it Compact OS: [You must be registered and logged in to see this link.]
It's actually very effective but not nearly as good as WimLib's: https://wimlib.net/
interpretation that took it to a whole another level altogether with its own superior LXZ compression and made it available to Windows 7 too, with the assistance of wofadk.sys.
With the help of WinReducer I've managed as low as 800mb windows 7 x64 installations, without .net and about 1.5g with .net. 
With 3rd party drivers like Nvidia's monsters included. 
Loaded and booted from Ram with the help of Grub4dos: [You must be registered and logged in to see this link.]
also possible. 

If there's interest i could compile a sort of tutorial.
It's more complicated than it sounds.

Edit to add: links cause they didn't show


Last edited by dim on Tue 6 Mar 2018 - 16:03; edited 1 time in total
avatar
KrX

Re: Compact OS

on Tue 6 Mar 2018 - 9:39
hi,

yes a tutorial how to use wimlib would be great Wink ´

i think a lot of users would like to shrink their reduced iso more ;P
dim

Re: Compact OS

on Tue 6 Mar 2018 - 16:05
It's not about reducing the ISO even more, but about a compressed LIVE installed, working system.
dim

Procedure

on Wed 7 Mar 2018 - 10:22
Make sure Enterprise or Ultimate versions are used. 
(Others work too but need patching)

Make sure the Hyper-V component/drivers/services are kept 
(not sure about the drivers, never tested without them)

After finished customizing our installation, we feed the final WInreducer *.wim 
along with the AutoUnattend.xml, if there is one, 
to the WinNtSetup [You must be registered and logged in to see this link.] utility, 
that greatly simplifies installing windows in to a VHD, filling all necessary inputs accordingly:

. Select location of Windows installation files > c:\Reduced.wim
. Select location of the Boot drive >C: (doesn't mater for now) 
. Select location of the Installation drive > Press the [VHD >>>] button first

. [VHD >>>] > Create > Location > c:\Windows.VHD 
. Virtual hard disk size: 10GB (or whatever you feel like, it doesn't matter at this point)
. Allocation unit size: 2048 byte (Since is just small OS files, smaller Allocation saves space, 1024 byte also viable)
. Dynamically expanding: check
. [OK]

This should popup diskpart and create a VHD file that is then auto attached as some random letter drive
(assuming X: for now) 

. Select location of the Installation drive: should be filled with X:\ now
. Unattend: check if needed, browse and select the AutoUnattend.xml if there is one 
. drive letter preassignment: check if you installing in this same machine, otherwise not
. Mode: IMPORTANT: do not check anything there
. [Tweaks >>>] button: self explanatory, all those settings are already done by WinReducer if there was a need for them.

. [Setup]
. Boot code: Do Not update the boot code - NONE
. Leave everything else unchecked press [OK] (Should take awhile)
. Do not restart when finished > [Cancel]
. Exit WinNtSetup


Open a command prompt with admin privileges:

Code:
BCDBOOT X:\Windows /s X:


. Exit the prompt 

. Detach the VHD > use disk management (Start > Run > diskmgmt.msc > right click the X: Disk > Detach VHD )

. Use VirtualBox to make a new VM and add your C:\windows.VHD as a storage disk
. Boot your new VM to see if the VHD boots and Windows setup starts.  If it does let it finish and shut down windows and the VM

-  -  - WARNING - - - 

This part is for advanced users and can potentially harm your machine in to an un-bootable state. 
If you're not familiar editing your Windows boot menu use a Usb stick and experiment on it

. Download and run BootIce [You must be registered and logged in to see this link.]
 
 Assuming a USB stick without Boot record is going to be used. 
 Assuming letter F:


. Destination Disk > CRUCIAL: Select your USB stick drive from the drop down list
. [Process MBR] > Windows NT 5.x / 6.x MBR  > Install / Config 
. [Process PBR] > CRUCIAL: Select the F: dirve from the drop down list > BOOTMGR boot record (FAT/FAT32/NTFS/ExFAT)  > Install / Config 
. Leave BootIce running 
. Open a command prompt with admin privileges: 

Code:
BCDBOOT C:\Windows /s F:


Assuming you are using the same version of windows with the one installing 
both windows 7 for example  
otherwise we need to attach our VHD again and use: X:\Windows /s F: 
that's cause bootmgr is changed since Windows 8 and a windows 7 one cannot load a win 10 system

. Exit the prompt 
. Return to BootIce
. Third Tab [BCD] > Other BCD file > Browse and Select the F:\Boot\BCD
. Press [Easy mode]

. [ADD] > New VHD Boot Entry 
. Boot Device > Type > VHD 
. File > \Windows.vhd
. OS Title > SevenTen VHD Boot (or whatever)
. Test Mode: Check 
. No integrity checks: Check 
. [Save current system]
. [Save Globals]
. [Close]

. [Exit] BootIce

. Restart your machine > Enter your BIOS > adjust your boot drive sequence accordingly to boot from your USB stick first
. Boot the VHD 
. Windows Setup will find your new real machine devices, configure your OS to you liking, add 3rd party drivers, software, etc.

. OPTIONAL: For VHD Boot from RAM, FiraDisk [You must be registered and logged in to see this link.] driver must be installed 

. Reboot > Remove USB stick > Boot to your normal OS

- - - WINDOWS 7 ONLY - - -

. For windows 7 system WofADK.sys (Found inside WInNtSetup\Tools\(64-32)\DISM]) must be added and configured:
. Attach C:\Windows.VHD as drive X:
. Create and new cmd file with any name, like WofADK.cmd, with the following lines:

Code:
@echo off
SET TARGET=X:

cls
echo This batch will add registry settings for wofadk.sys
echo and will copy the file to the drive %TARGET%
echo.
pause

cls
echo Loading registry Hive -
echo.
reg.exe load HKLM\_SYSTEM %TARGET%\Windows\system32\config\system
echo.
echo.
echo.

echo Adding WofAdk registry settings - 
echo.
reg.exe add HKLM\_SYSTEM\ControlSet001\services\WofAdk /v Discription /t REG_SZ /d "WofAdk Mini-Filter Driver" /f
reg.exe add HKLM\_SYSTEM\ControlSet001\services\WofAdk /v DisplayName /t REG_SZ /d "WofAdk" /f
reg.exe add HKLM\_SYSTEM\ControlSet001\services\WofAdk /v ErrorControl /t REG_DWORD /d 1 /f
reg.exe add HKLM\_SYSTEM\ControlSet001\services\WofAdk /v Group /t REG_SZ /d "FSFilter Compression" /f
reg.exe add HKLM\_SYSTEM\ControlSet001\services\WofAdk /v Start /t REG_DWORD /d 0 /f
reg.exe add HKLM\_SYSTEM\ControlSet001\services\WofAdk /v SupportedFeatures /t REG_DWORD /d 3 /f
reg.exe add HKLM\_SYSTEM\ControlSet001\services\WofAdk /v Type /t REG_DWORD /d 2 /f
reg.exe add HKLM\_SYSTEM\ControlSet001\services\WofAdk /v DebugFlags /t REG_DWORD /d 0 /f
reg.exe add HKLM\_SYSTEM\ControlSet001\services\WofAdk /v AutoAttach /t REG_DWORD /d 1 /f
reg.exe add HKLM\_SYSTEM\ControlSet001\services\WofAdk /v Tag /t REG_DWORD /d 2 /f
reg.exe add HKLM\_SYSTEM\ControlSet001\services\WofAdk /v DependOnService /t REG_MULTI_SZ /d FltMgr /f
reg.exe add HKLM\_SYSTEM\ControlSet001\services\WofAdk /v ImagePath /t REG_EXPAND_SZ /d \SystemRoot\System32\drivers\wofadk.sys /f
reg.exe add "HKLM\_SYSTEM\ControlSet001\services\WofAdk\Instances" /v DefaultInstance /t REG_SZ /d "WofAdk Instance" /f
reg.exe add "HKLM\_SYSTEM\ControlSet001\services\WofAdk\Instances\WofAdk Instance" /v Altitude /t REG_SZ /d 40730 /f
reg.exe add "HKLM\_SYSTEM\ControlSet001\services\WofAdk\Instances\WofAdk Instance" /v Flags /t REG_DWORD /d 0 /f
echo.
echo.
echo.

echo Unloading registry Hive -
echo.
reg.exe unload HKLM\_SYSTEM
echo.
echo.
echo.

echo Copying wofadk.sys 
echo.
copy %~dp0wofadk.sys %TARGET%\Windows\System32\drivers
echo.
echo.
echo.
pause

. Save the file
. Copy WofADK.sys to the same folder 
. Copy reg.exe, found on any windows installation, to the same folder in case you have it removed from your system
. Run the cmd 

. Create a new WimBootCompress.ini file with the follwing lines:

Code:
; This is the inbox configuration file used for deploying or capture a
; WIMBoot system. Please do not remove this file because WIMCaptureImage 
; and WIMApplyImage will fail if WIM_FLAG_WIM_BOOT flag is specified.

[CompressionExclusionList]
ntoskrnl.exe

[PrepopulateList]
*winload.*
*winresume.*
\Windows\AppPatch\drvmain.sdb
\Windows\Fonts\vgaoem.fon
\Windows\Fonts\vgasys.fon
\Windows\INF\errata.inf
\Windows\System32\config\*
\Windows\System32\ntkrnlpa.exe
\Windows\System32\ntoskrnl.exe
\Windows\System32\bootvid.dll
\Windows\System32\ci.dll
\Windows\System32\hal*.dll
\Windows\System32\mcupdate_AuthenticAMD.dll
\Windows\System32\mcupdate_GenuineIntel.dll
\Windows\System32\pshed.dll
\Windows\System32\apisetschema.dll
\Windows\System32\api-ms-win*.dll
\Windows\System32\ext-ms-win*.dll
\Windows\System32\KernelBase.dll
\Windows\System32\drivers\*.sys
\Windows\System32\*.nls
\Windows\System32\kbd*.dll
\Windows\System32\kd*.dll
\Windows\System32\clfs.sys
\Windows\System32\bootstr.dll
\Windows\System32\CodeIntegrity\driver.stl
*bootstr.dll.mui
wof.sys
wofadk.sys

[ExclusionList]
\$bootdrive$
\$dwnlvldrive$
\$lsdrive$
\$installdrive$
\$Recycle.Bin\*
\bootsect.bak
\hiberfil.sys
\pagefile.sys
\ProgramData\Microsoft\Windows\SQM
\System Volume Information
\Users\*\AppData\Local\GDIPFONTCACHEV1.DAT
\Users\*\NTUSER.DAT*.TM.blf
\Users\*\NTUSER.DAT*.regtrans-ms
\Users\*\NTUSER.DAT*.log*
\Windows\Boot\*
\Windows\AppCompat\Programs\Amcache.hve*.TM.blf
\Windows\AppCompat\Programs\Amcache.hve*.regtrans-ms
\Windows\AppCompat\Programs\Amcache.hve*.log*
\Windows\CSC
\Windows\Debug\*
\Windows\Logs\*
\Windows\Panther\*.etl
\Windows\Panther\*.log
\Windows\Panther\FastCleanup
\Windows\Panther\img
\Windows\Panther\Licenses
\Windows\Panther\MigLog*.xml
\Windows\Panther\Resources
\Windows\Panther\Rollback
\Windows\Panther\Setup*
\Windows\Panther\UnattendGC
\Windows\Panther\upgradematrix
\Windows\Prefetch\*
\Windows\ServiceProfiles\LocalService\NTUSER.DAT*.TM.blf
\Windows\ServiceProfiles\LocalService\NTUSER.DAT*.regtrans-ms
\Windows\ServiceProfiles\LocalService\NTUSER.DAT*.log*
\Windows\ServiceProfiles\NetworkService\NTUSER.DAT*.TM.blf
\Windows\ServiceProfiles\NetworkService\NTUSER.DAT*.regtrans-ms
\Windows\ServiceProfiles\NetworkService\NTUSER.DAT*.log*
\Windows\System32\config
\Windows\System32\config\RegBack\*
\Windows\System32\config\*.TM.blf
\Windows\System32\config\*.regtrans-ms
\Windows\System32\config\*.log*
\Windows\System32\SMI\Store\Machine\SCHEMA.DAT*.TM.blf
\Windows\System32\SMI\Store\Machine\SCHEMA.DAT*.regtrans-ms
\Windows\System32\SMI\Store\Machine\SCHEMA.DAT*.log*
\Windows\System32\sysprep\Panther
\Windows\System32\winevt\Logs\*
\Windows\System32\winevt\TraceFormat\*
\Windows\Temp\*
\Windows\TSSysprep.log
\Windows\winsxs\poqexec.log
\Windows\winsxs\ManifestCache\*
\Windows\servicing\Sessions\*_*.xml
\Windows\servicing\Sessions\Sessions.back.xml

[CompressionFolderList]
\Windows\System32\WinEvt\Logs
\Windows\Installer

. Save the file 
. Copy WimBootCompress.ini to X:\Windows\system32\

. Detach X: (Use Disk Managment as usual)

- - - END OF WINDOWS 7 ONLY SECTION - - -


. Download WImLIb: [You must be registered and logged in to see this link.]
. Use Disk Management to attach your Windows.VHD (assuming drive X:)
. Open command prompt at WimLib folder:
 
Code:
wimcapture.cmd X:\ C:\WinTemp.wim --compress=none

(will take awhile)

. Leave the prompt open
. Detach X:
. Use Disk Management > Create New VHD > This is your final VHD - Name it whatever: SevenTen.vhd - size depends on your installation - Use 3G for start.
. Use smaller allocation size if you like, isn't going to save much.
. Format 
. Mark the partition as active
. Attach as X: (if it's not already as X:)

. At the open WimLib prompt:
 
Code:
wimlib-imagex.exe apply C:\WinTemp.wim 1 X:\ --compact=lzx 


That's the main gist of the whole deal here, that LZX switch. 
Will take quite awhile, and utilize all your CPU power. 
It might  also complain about some files cannot be compacted with LZX, it's benign, ignore it

. Take ownership of the BOOT folder, the bootmgr and the BOOTNXT file on the X: drive and delete all.
. Open a command prompt with admin privileges:

Code:
BCDBOOT X:\Windows /s X:


. Create a new cmd file call it Enum.cmd with the following lines:

Code:
@echo off
Setlocal

::Set path to bcdedit.exe (e.g. C:\Windows\System32\bcdedit.exe)
Set BCDEDIT=%Windir%\System32\bcdedit.exe

::Set path to BCD Store (e.g. C:\boot\BCD)
Set STORE=%1

%BCDEDIT% /store %STORE% /enum {default} /v
echo.
echo.

endlocal
pause
exit

. Save and close the file 

.Create a new cmd file call it Win64.cmd with the following lines:

Code:
@echo off
Setlocal

::Set path to bcdedit.exe (e.g. C:\Windows\System32\bcdedit.exe)
Set BCDEDIT=%Windir%\System32\bcdedit.exe

::Set path to BCD Store (e.g. C:\boot\BCD)
Set STORE=%1

%BCDEDIT% /store %STORE% /set {default} device boot
%BCDEDIT% /store %STORE% /set {default} osdevice boot
%BCDEDIT% /store %STORE% /set {default} path \Windows\system32\winload.exe
%BCDEDIT% /store %STORE% /set {default} systemroot \Windows
%BCDEDIT% /store %STORE% /set {default} detecthal yes
%BCDEDIT% /store %STORE% /set {default} TESTSIGNING ON
%BCDEDIT% /store %STORE% /deletevalue {default} winpe
%BCDEDIT% /store %STORE% /deletevalue {default} ems

echo.
echo.

endlocal
pause
exit

. Save and close the file 

- - - IN CASE OF x86 SYSTEM - - -

.Create a new cmd file call it Win32.cmd with the following lines:

Code:
@echo off
Setlocal

::Set path to bcdedit.exe (e.g. C:\Windows\System32\bcdedit.exe)
Set BCDEDIT=%Windir%\System32\bcdedit.exe

::Set path to BCD Store (e.g. C:\boot\BCD)
Set STORE=%1

%BCDEDIT% /store %STORE% /set {default} device boot
%BCDEDIT% /store %STORE% /set {default} osdevice boot
%BCDEDIT% /store %STORE% /set {default} path \Windows\system32\winload.exe
%BCDEDIT% /store %STORE% /set {default} systemroot \Windows
%BCDEDIT% /store %STORE% /set {default} detecthal yes
%BCDEDIT% /store %STORE% /deletevalue {default} winpe
%BCDEDIT% /store %STORE% /deletevalue {default} ems

echo.
echo.

endlocal
pause
exit


. Save and close the file 

. Put both files at X:\BOOT\
. Drag BCD on to both cmd files one at a time - you can use a command promt as well: 

Code:
X:\Boot\ENUM.cmd BCD



Code:
X:\Boot\WIN64.cmd BCD (or 32 that is)


. Use any wipe free space utility like CCleaner to wipe X: free space only
. Use any Defrag utility to Defrag X: as well

. Detach X: 

. Use BootIce to Add a new VHD Boot entry to your USB stick Boot Menu as previously, that points to the new SevenTen.vhd
. Restart and boot your LZX Compressed Live Windows Installation. 



- - - BOOTING THE VHD FROM RAM  - - - 

. Download Grub4Dos [You must be registered and logged in to see this link.]
. We can either install grub4dos to MBR or add it to boot.ini, pick any, both work fine.

. Option 1:
. Run BootIce > Destination Disk > CRUCIAL: Select your USB stick drive 
. [Process PBR] > CRUCIAL: Select your USB stick drive > GRUB4DOS 0.4.5c/0.4.6a (FAT/FAT32/NTFS/ExFAT) > Install / Config > [Close]
. [Process MBR] > GRUB4DOS 0.4.5c/0.4.6a (grldr.mbr) > Install / Config > [Close]

. Option 2:
. Go to your USB stick root folder and edit, or create if it's not there, the boot.ini file, with the following:

Code:
[boot loader]
timeout=30
default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Windows" /noexecute=optin /fastdetect
C:\grldr="Grub4Dos"


. Save and close boot.ini

. Copy grldr and menu.lst from grub4dos 7z to the root of your USB stick 
. Edit menu.lst adding the following:

Code:
color light-gray/black white/black light-gray/black light-gray/black 
timeout 30
default 1

title BOOTMGR (hd0,0)
root (hd0,0)
chainloader /bootmgr

title SevenTen
find --set-root --ignore-floppies --ignore-cd /SevenTen.vhd
map --mem /SevenTen.vhd (hd0)
map --hook
root (hd0,0)
chainloader /bootmgr
boot

title commandline
commandline

title quit
quit

title reboot
reboot

title halt
halt

. Reboot and boot from your USB stick 
. Select the grub4dos entry in the boot menu that will now appear
. Grub4Dos menu will appear defaulting in the second option > Press enter 

Depends whether the SevenTen.vhd is located in an SDD or HD will take some time to load in to RAM 
and due to a not yet implemented feature, it wont show the loading percent for a dynamic VHD
When the loading is finished the OS will boot itself normally
If it's Windows 7 arriving at the desktop a new Ram drive device detection prompt may appear and ask to restart. Ignore it and close the message box.


- - - END OF BOOTING FROM RAM - - - 

Remarks 

It wont probably happen the first time. 
I've spend countless hours, usually pulling my hair out to actually make it happen 
but once i did it was a piece of cake thereafter.

The obvious advantages of having your OS on a VHD is that we can have multiple OSes,
or various versions of the same OS, at our fingertips.
Adding removing drivers, software, making changes while keeping a backup VHD we can always revert to at any time
Only Hibernation isn't supported. Sleep does, as usual.

Booting from Ram is ideal for a virtually indestructible OS, as nothing can happen to it.
It will every time boot to its previous pristine state, while any permanent changes can added to it by booting the VHD from the hard disk as usual. 
Great for testing software or just have peace of mind in a 10x faster OS, since no Hard Drive calls are used.
A lot of faster than SDD too. Great avoiding unnecessary SSD wear also, with the constant Windows NFTS journaling, although isn't that much of a deal. 

The final VHD will need some extra space for the windows temp files that are created on the fly 
100 mb is the minimum i could suggest, always assuming that Prefetch, Superfetch, Readyboot 
and maybe other various windows loging are disabled by the WinReducer procedure already.
In the case of some applications that often use quite a lot of such space
consider using the set, setx or mklink commands to temporarily redirect the temp folders elsewhere


Code:
setx TEMP T:\Temp\Tmp
setx TMP T:\Temp\Tmp
setx /m TEMP T:\Temp\Tmp
setx /m TMP T:\Temp\Tmp

Where T: is some other drive.

I myself use ImDisk [You must be registered and logged in to see this link.] 
to make a ram drive for this purpose alone.

There's too many people to thank over there are reboot pro [You must be registered and logged in to see this link.] forum 
from which I collected and compiled this procedure.


Last edited by dim on Fri 16 Mar 2018 - 7:17; edited 8 times in total
avatar
KrX

Re: Compact OS

on Wed 7 Mar 2018 - 16:21
thank you, thats a nice tutorial. i will try it out as soon as i got some time
Back to top
Permissions in this forum:
You cannot reply to topics in this forum