How to install Windows to allow shrinking the Windows partition easier in the future


hsehestedt

Well-known member
Guru
VIP
Local time
11:59 PM
Posts
5,179
Location
Texas, USA
OS
Win11 Pro 25H2 (RTM+)
If you ever need to shrink your Windows partition for any reason without the use of third-party software, you may have noticed that even with very little data on a disk, you generally cannot shrink the volume nearly as much as you might have expected. For example, if you have a 512GB SSD and there is only about 60GB space used in your Windows partition, you still find that you cannot make the partition smaller than about 250GB (this is just an example, real numbers will be different). One reason for this is that when you format a partition, Windows creates various pieces of metradata on the volume and some of that gets stored roughly in the center of the volume.

Yesterday, this idea hit me: What if I initially make my Windows partition tiny, say like 10GB, and I format it. Now, Windows creates the disk structures, and because the drive is only 10 GB in size, it puts some of that data only about 5GB into the volume. Now, right after having created it, perfom an "extend" operation to grow that partition and volume. Note that when you do this, Microsoft does NOT relocate the metadata. It remains just a few GB into this partition. The result? Under most circumstances, you should be able to shrink that partition by a lot more.

I tested my idea today and it worked perfectly.

I realize that doing this may be a pain in the neck for some people because it means creating the partitions prior to installing Windows. But, if you are automating Windows installing it becomes ridiculously easy. I only had to add two entries to my unattended answer file to make this change.
 

My Computers My Computers

  • At a glance

    Win11 Pro 25H2 (RTM+)Intel i7-14650HX32 GBNo GPU - Built-in Intel Graphics
    OS
    Win11 Pro 25H2 (RTM+)
    Computer type
    PC/Desktop
    Manufacturer/Model
    Acemagic
    CPU
    Intel i7-14650HX
    Memory
    32 GB
    Graphics Card(s)
    No GPU - Built-in Intel Graphics
    Sound Card
    Integrated
    Monitor(s) Displays
    Varies as machine will often be moved to locations with different monitors
    Screen Resolution
    Varies
    Hard Drives
    1 x 1TB Gen 4 NVMe SSD
    PSU
    120W Power Brick
    Keyboard
    Corsair K70 Max RGB Magnetic Keyboard
    Mouse
    Logitech MX Master 3
    Internet Speed
    1Gb Up / 1 Gb Down
    Browser
    Edge
    Antivirus
    Windows Defender
  • At a glance

    Win11 Pro 25H2 (RTM+)Intel i7-1255U16 GBIntel Iris Xe Graphics
    Operating System
    Win11 Pro 25H2 (RTM+)
    Computer type
    Laptop
    Manufacturer/Model
    Lenovo ThinkBook 13x Gen 2
    CPU
    Intel i7-1255U
    Memory
    16 GB
    Graphics card(s)
    Intel Iris Xe Graphics
    Sound Card
    Realtek® ALC3306-CG codec
    Monitor(s) Displays
    13.3-inch IPS Display
    Screen Resolution
    WQXGA (2560 x 1600)
    Hard Drives
    2 TB 4 x 4 NVMe SSD
    PSU
    USB-C / Thunderbolt 4 Power / Charging
    Keyboard
    Backlit, spill resistant keyboard
    Mouse
    Buttonless Glass Precision Touchpad
    Internet Speed
    1Gb Up / 1Gb Down
    Browser
    Edge
    Antivirus
    Windows Defender
    Other Info
    WiFi 6e / Bluetooth 5.1 / Facial Recognition / Fingerprint Sensor / ToF (Time of Flight) Human Presence Sensor
Been doing that for years with win7 installations. Not as small as 10gb, I used to do 40-60gb . Haven't bothered with it more recently.
 

My Computers My Computers

  • At a glance

    Win7,Win11i7-97002x16gb 3600mhz
    OS
    Win7,Win11
    Computer type
    PC/Desktop
    CPU
    i7-9700
    Motherboard
    gigabyte b365m ds3h
    Memory
    2x16gb 3600mhz
    Monitor(s) Displays
    benq gw2480
    PSU
    bequiet pure power 11 400CM
    Cooling
    cryorig m9i
  • At a glance

    win7,win11i5-84002x8gb 3200
    Operating System
    win7,win11
    Computer type
    PC/Desktop
    CPU
    i5-8400
    Motherboard
    gigabyte b365m ds3h
    Memory
    2x8gb 3200
    PSU
    xfx pro 450
1. You cannot shrink a volume if there are page file or file blocks which are marked as unmovable, blocking the resize.

It might be you have a lot of RAM, and Windows defaults to ~1.5x page file and positions the page file's blocks roughly where you can't shrink past it. One test would be to disable the page file in the install image (by modding the offline image's registry hive), and seeing if you're allowed to resize the same volume down.

2. Unless you know how to customize an image and add some scripting, you can't have dynamically sized disk layouts. Either you have a "best guess" fixed layout, or use some form of partition extension in the unattended file.

This is where the old "recovery partition comes before the Windows partition" problem started. Back in the old days, WinRE was never too large in size and didn't wildly require more disk space over time. For simplicity, it was easier to assign a fixed Recovery right after the reserved partition, and extend the Windows volume to the disk's end.

But now, MS advises we place the Recovery after Windows, so the Windows volume can be shrunk to grow the Recovery. If we don't do this, then Windows is liable to create a second Recovery and abandon the original Recovery we created at install time (wasting disk space).

Ideally you have some script which does the disk math, and assigns a fixed size EFI and reserved partitions, and figures out how far back to place the recovery partition. Without some scripting, you can't do that do. If you have a small starting Windows volume, it doesn't solve the problem of knowing where to locate the Recovery. Unless you know exactly the disk size in advance, and it's always going to be unchanged in total disk size.

A fixed layout may work for you, but it's not universal for other folks.
 

My Computer My Computer

At a glance

Windows 7
OS
Windows 7
Ideally you have some script which does the disk math, and assigns a fixed size EFI and reserved partitions, and figures out how far back to place the recovery partition.

The easy way (no calculations needed, perfect layout every single time):

Assume you want the recovery tools partition to be 1GB.

Create the EFI and MSR partition. Create the Windows partition without specifying a size. It will occupy all remaining space on the drive. Shrink it by 1GB. Create another partition without specifying a size. It will be exactly 1GB in size. Use the usual commands to make that last partition a recovery partition.

Easy!
 

My Computers My Computers

  • At a glance

    Win11 Pro 25H2 (RTM+)Intel i7-14650HX32 GBNo GPU - Built-in Intel Graphics
    OS
    Win11 Pro 25H2 (RTM+)
    Computer type
    PC/Desktop
    Manufacturer/Model
    Acemagic
    CPU
    Intel i7-14650HX
    Memory
    32 GB
    Graphics Card(s)
    No GPU - Built-in Intel Graphics
    Sound Card
    Integrated
    Monitor(s) Displays
    Varies as machine will often be moved to locations with different monitors
    Screen Resolution
    Varies
    Hard Drives
    1 x 1TB Gen 4 NVMe SSD
    PSU
    120W Power Brick
    Keyboard
    Corsair K70 Max RGB Magnetic Keyboard
    Mouse
    Logitech MX Master 3
    Internet Speed
    1Gb Up / 1 Gb Down
    Browser
    Edge
    Antivirus
    Windows Defender
  • At a glance

    Win11 Pro 25H2 (RTM+)Intel i7-1255U16 GBIntel Iris Xe Graphics
    Operating System
    Win11 Pro 25H2 (RTM+)
    Computer type
    Laptop
    Manufacturer/Model
    Lenovo ThinkBook 13x Gen 2
    CPU
    Intel i7-1255U
    Memory
    16 GB
    Graphics card(s)
    Intel Iris Xe Graphics
    Sound Card
    Realtek® ALC3306-CG codec
    Monitor(s) Displays
    13.3-inch IPS Display
    Screen Resolution
    WQXGA (2560 x 1600)
    Hard Drives
    2 TB 4 x 4 NVMe SSD
    PSU
    USB-C / Thunderbolt 4 Power / Charging
    Keyboard
    Backlit, spill resistant keyboard
    Mouse
    Buttonless Glass Precision Touchpad
    Internet Speed
    1Gb Up / 1Gb Down
    Browser
    Edge
    Antivirus
    Windows Defender
    Other Info
    WiFi 6e / Bluetooth 5.1 / Facial Recognition / Fingerprint Sensor / ToF (Time of Flight) Human Presence Sensor
You said "using an unattended file". Still need to call an outside script or command.
 

My Computer My Computer

At a glance

Windows 7
OS
Windows 7
It's three files that are evil that will stop windows from shrinking the volume . Page file, swap file and hibernation file.
What i did was disable paging/swap/hibernate then reboot... deleting the files... shrink the volume.. enable them again.. and reboot.
I shirked the system drive to only have 5GB free, so it was bootable... if i ever needed that windows install again.
 

My Computers My Computers

  • At a glance

    Linux: Debian, Kali-linux, Alma, Win:7,10IoT,...i3, i5 and i7 From 2gen to 9th gen... Server ...
    OS
    Linux: Debian, Kali-linux, Alma, Win:7,10IoT,2012R
    Manufacturer/Model
    HP Elitebook 840, AsusX53, Aspire E1-572. AsusUX32A, HP Pro3130mt+3010mt, HP Proliant ML150, 3xCustom-PC, i3, i5, i7
    CPU
    i3, i5 and i7 From 2gen to 9th gen... Server dual Xenon
    Hard Drives
    Sata, M.2, SAS
  • At a glance

    Retro: 2003server.XPpro, Win2000, Win98SE, Wi...Oldest intel 8088 up to P4 dual core
    Operating System
    Retro: 2003server.XPpro, Win2000, Win98SE, Win95, Win3.11, MS-DOS, IBM-DOS
    Manufacturer/Model
    Commodore, AST, Fujitsu, Compaq, etc etc. etc Around 15 desktops and 20 laptops in the collection
    CPU
    Oldest intel 8088 up to P4 dual core
    Hard Drives
    MFM, IDE, SCSI
It's three files that are evil that will stop windows from shrinking the volume . Page file, swap file and hibernation file.
What i did was disable paging/swap/hibernate then reboot... deleting the files... shrink the volume.. enable them again.. and reboot.
I shirked the system drive to only have 5GB free, so it was bootable... if i ever needed that windows install again.
Those can be disabled before the install, if you modify the offline image's registry. So the page or hibernation file is never created. After the system is installed then you could re-enable them in the registry and reboot.
 

My Computer My Computer

At a glance

Windows 7
OS
Windows 7
You said "using an unattended file". Still need to call an outside script or command.

I put commands in the autounattend, nothing more. It simply uses diskpart. Example:

<RunSynchronousCommand wcm:action="add">
<Order>4</Order>
<Path>cmd.exe /c echo select disk 0 &gt; X:\diskpartUEFI.txt</Path>
</RunSynchronousCommand>

All the commands are piped to a text file used as a diskpart script.
 

My Computers My Computers

  • At a glance

    Win11 Pro 25H2 (RTM+)Intel i7-14650HX32 GBNo GPU - Built-in Intel Graphics
    OS
    Win11 Pro 25H2 (RTM+)
    Computer type
    PC/Desktop
    Manufacturer/Model
    Acemagic
    CPU
    Intel i7-14650HX
    Memory
    32 GB
    Graphics Card(s)
    No GPU - Built-in Intel Graphics
    Sound Card
    Integrated
    Monitor(s) Displays
    Varies as machine will often be moved to locations with different monitors
    Screen Resolution
    Varies
    Hard Drives
    1 x 1TB Gen 4 NVMe SSD
    PSU
    120W Power Brick
    Keyboard
    Corsair K70 Max RGB Magnetic Keyboard
    Mouse
    Logitech MX Master 3
    Internet Speed
    1Gb Up / 1 Gb Down
    Browser
    Edge
    Antivirus
    Windows Defender
  • At a glance

    Win11 Pro 25H2 (RTM+)Intel i7-1255U16 GBIntel Iris Xe Graphics
    Operating System
    Win11 Pro 25H2 (RTM+)
    Computer type
    Laptop
    Manufacturer/Model
    Lenovo ThinkBook 13x Gen 2
    CPU
    Intel i7-1255U
    Memory
    16 GB
    Graphics card(s)
    Intel Iris Xe Graphics
    Sound Card
    Realtek® ALC3306-CG codec
    Monitor(s) Displays
    13.3-inch IPS Display
    Screen Resolution
    WQXGA (2560 x 1600)
    Hard Drives
    2 TB 4 x 4 NVMe SSD
    PSU
    USB-C / Thunderbolt 4 Power / Charging
    Keyboard
    Backlit, spill resistant keyboard
    Mouse
    Buttonless Glass Precision Touchpad
    Internet Speed
    1Gb Up / 1Gb Down
    Browser
    Edge
    Antivirus
    Windows Defender
    Other Info
    WiFi 6e / Bluetooth 5.1 / Facial Recognition / Fingerprint Sensor / ToF (Time of Flight) Human Presence Sensor
Those can be disabled before the install, if you modify the offline image's registry. So the page or hibernation file is never created. After the system is installed then you could re-enable them in the registry and reboot.
I have never tested that.. But i understand what you mean :-)
I mostly just modify to rip out unwanted things before install.. But i never had that in my thought before. Often when i do install windows, i plan on using it, so i make the system partition in the size larger then i might need the next years.. Then when i reach a point where i feel i have no use for it, but its good to keep just in case.. Then i make it as small as possible but still usable.. so my other system can use that space instead. :-)

But i will keep it in mind, as a good note to have in my cheat-sheet :-)
 

My Computers My Computers

  • At a glance

    Linux: Debian, Kali-linux, Alma, Win:7,10IoT,...i3, i5 and i7 From 2gen to 9th gen... Server ...
    OS
    Linux: Debian, Kali-linux, Alma, Win:7,10IoT,2012R
    Manufacturer/Model
    HP Elitebook 840, AsusX53, Aspire E1-572. AsusUX32A, HP Pro3130mt+3010mt, HP Proliant ML150, 3xCustom-PC, i3, i5, i7
    CPU
    i3, i5 and i7 From 2gen to 9th gen... Server dual Xenon
    Hard Drives
    Sata, M.2, SAS
  • At a glance

    Retro: 2003server.XPpro, Win2000, Win98SE, Wi...Oldest intel 8088 up to P4 dual core
    Operating System
    Retro: 2003server.XPpro, Win2000, Win98SE, Win95, Win3.11, MS-DOS, IBM-DOS
    Manufacturer/Model
    Commodore, AST, Fujitsu, Compaq, etc etc. etc Around 15 desktops and 20 laptops in the collection
    CPU
    Oldest intel 8088 up to P4 dual core
    Hard Drives
    MFM, IDE, SCSI
i always partition the disk before a clean install 250GB C:drive the rest as a Home partition for everything else.
it maybe worth while mentioning that Windows likes a partition size of about 128GB for C:drive
and thats for any future full system upgrades.

best of like Steve ..
 

My Computers My Computers

  • At a glance

    Debian 13 KDE .. Windows 11 HomeRyzen 7 5825u64GB DDR4 3200Ryzen 7 5825u
    OS
    Debian 13 KDE .. Windows 11 Home
    Computer type
    PC/Desktop
    Manufacturer/Model
    HP 24" AiO
    CPU
    Ryzen 7 5825u
    Motherboard
    HP
    Memory
    64GB DDR4 3200
    Graphics Card(s)
    Ryzen 7 5825u
    Sound Card
    RealTek
    Monitor(s) Displays
    24" HP AiO
    Screen Resolution
    1920 x 1080 @60 Hz
    Hard Drives
    1TB WD Blue SN580 M2 SSD Partitioned.
    2x 1TB USB HDD External Backup/Storage.
    PSU
    90W external power brick
    Case
    24" All in One
    Cooling
    Default Air Cooling
    Keyboard
    HP WiFi UK extended
    Mouse
    HP WiFi 3 Button
    Internet Speed
    1GB full fibre
    Browser
    Edge & Firefox
    Antivirus
    AVG Internet Security/Windows Defender
    Other Info
    Mainly Open Source Software
  • At a glance

    Ubuntu 22.04.5 LTSi5 7200u16GB DDR4Intel
    Operating System
    Ubuntu 22.04.5 LTS
    Computer type
    Laptop
    Manufacturer/Model
    Dell 13" Latitude 2017
    CPU
    i5 7200u
    Motherboard
    Dell
    Memory
    16GB DDR4
    Graphics card(s)
    Intel
    Sound Card
    Intel
    Monitor(s) Displays
    13" Dell Laptop
    Hard Drives
    250GB Crucial 2.5" SSD
    Mouse
    Generic WiFi 3 button
    Internet Speed
    WiFi only
    Browser
    Firefox
    Antivirus
    ClamAV TK
    Other Info
    Mainly Open Source Software

Latest Support Threads

Back
Top Bottom