Soon after I had posted this Custom Win PE Boot Disk Building: Step Four – Pulling it all together walkthrough binding all the elements on making a custom PE boot disk, I started getting comments that followers were unable to get CubicExplorer working in it.
The solution was a long time coming, but revelation of the solution culminated in the Solved: Run CubicExplorer in Win PE with no Crashes... post.
I’m not revisiting that one, but one path I and parities played with in the process was to fiddle with the PE Ram Disk size.
As this may or may not be something amateur PE builders and hobbies may be familiar with (I really wasn’t fully) I thought I would take a few moments to post some related links about it for future reference.
Very Basic info on RamDisk/ScratchSpace in PE
By default, Windows PE builds “by the book” allocate 32 MB of writeable memory to the PE environment.
I like to think of it (very roughly) like this.
The space of my yard would correspond to the System RAM.
The PE system (containing all the stuff in your PE wim-image file) would correspond to a kiddie-pool placed in the back-yard.
The scratch space would correspond to how big the kiddie-pool is and, thusly, how much water fills it up for everyone to play in.
Now generally, for most stock PE builds, 32 MB of scratch space works very well. PE environments (base) run a CLI shell box and a simple background. The services are simple and it’s not like you are running a lot of GUI apps. This small and shallow pool is more than sufficient to let the kids play happily and safely.
But say you then get a lot of neighborhood kids coming to join in. And some of them aren’t five-year olds. These are third and fourth graders. Suddenly there isn’t enough water in the pool for everyone to feel comfortable in. Kids get cranky and don’t behave.
Under these circumstances you need to get a larger kiddie-pool!
Microsoft describes it like this:
If your Windows PE environment becomes unresponsive when running an application, you may have run out of memory. By default, Windows PE allocates 32 megabytes (MB) of writeable memory, known as scratch space.
Typically, you don’t need to do anything as the standard 32 MB scratch space size is adequate. But if you need to, you do have the option to manually set the scratch space size larger…assuming the yard (system RAM) is large enough to accommodate things…
In WinPE, scratch space can be set at 32, 64, 128, 256, or 512 MB levels.
It does make a difference, particularly with GUI-heavy applications running in the WinPE environs. I’ve personally observed some applications either not running at all, running very sluggishly, or even not fully displaying all the expected graphical elements.
When I rolled out the larger kiddie-pool, they suddenly sprang to life and made things much more pleasant.
The drawback is you have to know the systems you intend to deploy these specific solutions on, and ensure you find the sweet-spot. If your supported desktop systems have just 256 MB of RAM, and you go to boot it with a WinPE disk set at a 512 MB scratch-space size, it won’t be pretty. Then again, if you don’t really use a lot of additional memory-intensive applications in WinPE, then you also don’t probably need a 512 MB scratch space wrapped WinPE setup.
In other words, your kiddie-pool can’t be larger than your yard or else it just won’t fit in there.
WinPE 3.0 and Increasing Scratch Space
WinPE 3.0 is based on the Windows 7 platform. As such, you have to use a WinPE 3.0 specific tool to make changes to the default scratch-space settings.
The beauty of it is that once you get this basic process down, the rest is gravy. I’ll come back to that in a minute.
Under WinPE 3.0 building, you must use the DISM.exe command tool.
Go ahead and create your WinPE 3.0 “wim” file image using your own technique or the ones I outlined in the first link of this post.
This assumes you have already installed and are familiar with the Windows® AIK for Windows® 7. There are a few other related Microsoft WinPE building packages/tools as well that should include the tool (Microsoft Deployment Toolkit).
Launch the “Deployment Tools Command Prompt” and use the following format to adjust the scratch-space of your wim file. (note in this case I am using standard locations to mount the wim file for servicing as well as using the name “winpe.wim” for this example. You will need to adjust to your own particular wim-file and mounting location accordingly.)
Dism /Mount-Wim /WimFile:C:\winpe_x86\winpe.wim /index:1 /MountDir:C:\winpe_x86\mount
dism /image:C:\winpe_x86\mount /Set-ScratchSpace:256
Dism /Unmount-Wim /MountDir:C:\winpe_x86\mount\ /Commit
In the second line of the example above I used the “256” value to set the scratch-space to 256 MB RAM. Adjust the value you use accordingly (32, 64, 128, 256, or 512 MB levels).
Then toss the updated wim image file either into the correct location of your USB-bootable storage device, or into the proper folder and build/burn your WinPE ISO file to optical media.
To verify that you were successful, launch your PE build, navigate in a CLI window to the X: drive (RamDisk) and run a DIR command. The size shown should equal the scratch-space size you set.
Related WinPE 3.0 Resources:
- WinPE Crashes – MSFN Forums.
- Building a Windows PE Image – Microsoft TechNet.
- How to use DISM to create WinPE 3.0 Boot Environment – eHow.com
- New Features in the Windows AIK – Microsoft TechNet.
- Deployment Tools Walkthroughs – Microsoft TechNet.
- Deployment Image Servicing and Management Command-Line Options – Microsoft TechNet.
- Walkthrough: Create a Custom Windows PE Image – Microsoft TechNet.
- Add an Application to a Windows PE Image – Microsoft TechNet.
- Deploying Windows 7 - Part 2: Using DISM – Windows Networking.
- ImageX GUI (GImageX) – Super cool GUI utility for mounting/working-with WIM files and ImageX.
- Je Jin’s DISM Tool - My Digital Life Forums. – Neat GUI utility to also do some WIM file mounting, tricks, and DISM related servicing duties.
WinPE 2.0 and Increasing Scratch Space
WinPE 2.0 is based on the Windows Vista platform. As such, you have to use a WinPE 2.0 specific tool to make changes to the default scratch-space settings such as the Windows Automated Installation Kit (AIK) for Vista or (even better) the Automated Installation Kit (AIK) for Windows Vista SP1 and Windows Server 2008.
Under WinPE 2.0 building, you must use the PEimg.exe command tool.
The principle is basically the same as before, and again assumes you already have build your WIM image file and now need to adjust its scratch space.
“With the introduction of Windows PE 2.1 (supplied with the Windows Automated Installation Kit (Windows AIK) 1.1), the scratch area can be changed from the command line. Below is the process for creating a larger scratch area.
1. Create a temporary mount folder on your hard disk - MD c:\temp\mount
2. Go to the Windows AIK tools folder for the platform of PE that you will be changing (ie x86/x64) - CD "Program Files\Windows AIK\Tools\x86"
3. Mount the default Windows PE image supplied with Windows AIK to your temporary mount folder - imagex.exe /MOUNTRW "C:\Program Files\Windows AIK\Tools\PETools\x86\winpe.wim" 1 c:\temp\mount
4. Go to the Windows AIK PETools folder - CD "C:\Program Files\Windows AIK\Tools\PETools"
5. Run the PEIMG command to adjust the scratch size in the mounted image using /SCRATCHSPACE flag to set the size of the drive you want (in this case 128Mb) - peimg.exe /SCRATCHSPACE=128 c:\temp\mount\windows
6. Change back to the PETools directory - CD "Program Files\Windows AIK\Tools\x86"
7. Unmount the image and commit the changes - imagex.exe /UNMOUNT /COMMIT c:\temp\mount
“That's it - the scratch area will now be set at 128 Mb for all boot images based on this source - which means all boot images created by MDT will now have the set scratch space set….”
Again, pretty easy stuff. Just adjust your recipe accordingly.
Related WinPE 2.0 Resources:
- PEImg Command-Line Options – Microsoft TechNet.
- Scratch Space aka Ram Drive – All About Windows PE 2.x blog.
- Configuring WinPE 2.0 scratch space (RAM Drive) – Deploy Vista.
- Windows PE 2.0 for Windows Vista Overview – Microsoft TechNet.
- WMI Tracing – All About Windows PE 2.x blog. (Rare condition of when WMI package is added to WinPE, log file generated may exceed ram disk size. Increasing scratch space or disabling feature in WinPE registry may fix issue.)
- All About Windows PE 2.x – WinPE blog by Paul Matthews that is currently in hiatus. Too bad as there was (is) a number of great tips and tricks regarding WinPE (2.x) in here. Maybe we will eventually hear from Paul again…
So earlier in the post I said that once you get down the commands to modify your WIM boot image file, you can easily crank out various versions.
If you are using optical media based WinPE builds, then you just have to carry a few disks in each of the scratch-space flavors you created.
However, if you are using a bootable USB disk, and it has sufficient space, you can get all crazy!
On my own bootable USB flash stick, in addition to the required “SOURCES” folder and contents, I also have a “SOURCES-ALT” folder. In there I keep all my additional and scratch-space-adjusted WIM files. So I have a Boot-32.wim, Boot-128.wim, Boot-256.wim, and a Boot-512.wim file stored in there. Typically, I have the 512 MB set scratch-space boot.wim file in my SOURCES folder to boot with. However, if I know I need to WinPE boot a system that that wouldn’t work on, then I can delete the boot.wim file out of my SOURCES folder on the USB stick, and copy another more appropriate version from my SOURCES-ALT folder over into it, say the Boot-128.wim one. Then I rename it to boot.wim and I am good to go!
In fact, once the contents of the WIM file are loaded into the scratch-space/RAM Disk, it is then released. That means if you are going from a system that uses the 512 MB scratch-space, and then progress on to one that will require the 64 MB scratch-space version, it seems you can do the boot.wim delete/copy/rename routine on your USB stick still from within your WinPE boot session! I’ve done this on a number of occasions.
Even more fun is making up not just different scratch-space flavors of the boot.wim file, but even wholly different versions of the boot.wim file itself! You could have a custom WinPE 2.0 boot.wim file, a custom WinPE 3.0 boot.wim file, an AntiVirus PE Disk to offline-scan a Windows system, or maybe, say, a Win(FE) forensics build boot.wim, and so on…limited only by the size of your USB storage device and your imagination and efforts. Even different WIM files with different hardware drivers injected for various system platforms. Instead of carrying a mess of optical disks, just a single large USB storage may do the trick (assuming the system BIOS supports USB based booting).
Of course, you do have to reboot the system to then load whichever WIM file you have swapped out…but I’m sure you knew that already. Just keep the originals safely and alternatively named in your “storage” folder location and delete/copy/rename the original boot.wim file as needed.
One more Bonus Find
- Windows 7 Tips & Tweaks – CatPawz.com
The real find on this tip comes at the bottom of the page.
CatPawz has three helpful CLI sections documented that deal with “Build a Windows 7 AIO DVD”, “To Modify a Win7PE Disk”, and “To Create a Win7 Disk”. If you aren’t familiar or comfortable with CLI usage in WinPE building and servicing, these could be great examples to follow and learn from.