The search for the compressed ramdisk is over!

Last Updated on September 30, 2010 by Dave Farquhar

Things that make you go… D’OH! I spent, as I’ve said a number of times before, the better part of a weekend trying to figure out how to run Windows from a ramdisk. I figured I couldn’t have been the first to do such a thing, but I couldn’t find any reference online to anyone who had. After a weekend of turning some hair gray, I got it working on my own.

Then I set out to compress my ramdisk. Disk compression makes sense when disk space is expensive, and RAM is comparatively expensive, and even if disk compression slows it down by 100%, compressed RAM is still many orders of magnitude faster than a metal disk. I couldn’t get it working. I didn’t say it was impossible, because I’ll never write anything off as impossible, but I said I couldn’t get it working. I figured that’d be the last I’d hear of it.

Then over the weekend, Tony Brewer, a reader of the Optimizing Windows, wrote in, quoted that paragraph verbatim and casually said, “It’s most definitely possible.” I was flabbergasted. Had he done it? I wrote back and asked if he’d done it and if he’d be willing to share the secret.

Indeed he had, and he was kind enough to share the secret. It turns out I was very, very close to getting it working. But close is only good enough in nuclear war, not computers.

Here’s what he had to say:

Dave,

There is an elegant and simple method for running Win9x on a compressed RAM disk. Assuming that Win9x is already installed on C: and using the same drive letters as in Chapter 11 of your book:

Run DriveSpace in Windows to create an empty compressed drive E: of the desired size using free space on C:, re-boot, then install Win9x to E:windows (with the swap file on C:). Edit c:\msdos.sys, c:\config.sys and c:\autoexec.bat as follows:

c:msdos.sys
——————
[Paths]WinDir=e:\windows
WinBootDir=e:\windows
HostWinBootDrv=c

c:\config.sys
—————–
device=c:\windows\himem.sys
device=c:\windows\emm386.exe    ;or use umbpci.sys
dos=high,umb
devicehigh=c:\windows\ifshlp.sys
devicehigh=c:\windows\setver.exe

c:\autoexec.bat
———————

path=e:\windows;e:\windows\command;e:\windows\system
set temp=c:\ temp
set tmp=c:\temp
….

After re-booting, Win9x should run on the compressed drive E:, hosted by physical disk C:. To have a compressed RAM disk, the host must be an uncompressed RAM disk, D: for example. In c:d??space.ini (c:dblspace.ini or c:drvspace.ini, probably the former), change the ActivateDrive setting to read:

ActivateDrive=E,D1

This tells the DriveSpace driver to mount the compressed volume file (CVF) d??space.001 as drive E: with host drive D:. (Mounting is not automatic as it was with host drive C:, because RAM disk D: does not exist when io.sys loads the DriveSpace driver, dblspace.bin or drvspace.bin.)

Edit c:\autoexec.bat so that it contains the following:


path=c:\windows;c:\windows\command;c:\windows\system
REM Create RAM disk
xmsdsk {desired size of RAM disk in kilobytes} d: /t /y
REM Copy CVF to RAM disk
attrib c:\drvspace.001 -s -h -r
copy c:\drvspace.001 d:\
attrib c:\drvspace.001 +s +h +r
attrib d:\drvspace.001 +s +h +r
REM Mount CVF using scandisk /mount
scandisk /mount d:\drvspace.001
REM E: is now compressed RAM disk
path=e:\windows;e:\windows\command;e:\windows\system
set temp=c:\temp
set tmp=c:\temp

After re-booting, Win9x should run on the compressed RAM disk! :o)

(On a networked PC, there is no need for a hard disk as the CVF can be copied from a server. Diskless Win9x using a compressed RAM disk works very well.)

The above method is an adaptation of one by Andre Moreira. http://www.dei.isep.ipp.pt/~andre/extern/nc98.htm

Regards,

Tony Brewer
tonybrewer@bigDELETEfoot.com

With some thought, I may be able to simplify it a little, but not by much. The obvious simplification would be to use the free-for-private-use xxcopy to copy drvspace.001 in a single step, saving all those attrib lines in autoexec.bat.

This shows a lot of promise. Memory’s so cheap right now that it’s feasible to get 384 megs, leave yourself with 64 or even 128 megs of working memory, and still have a decent-sized ramdisk. Windows 95 will install to as little as 17 MB, if you know the secrets. Windows 98 is considerably larger but it’s still possible to stuff Win98 and a couple of apps into a compressed 256 MB disk, and it’s super fast. Even with disk compression, access to a compressed ramdrive is nearly instant. I did get compressed ramdrives working inside Windows (I just couldn’t boot from them) and even on my Pentium-90 a compressed ramdisk was fast. So if you want maximum speed, this is the way. And I’m wondering what this would do for a laptop’s battery life…

I’m really eager to give this a test drive.

Update: The following doesn’t seem to work with the original Windows 95 or Windows 95A. This may explain the difficulty I had initially, because I was using the Aug. 24, 1995 release of Win95 because of its small size (I was using a P90 with 48 MB RAM at the time).

I’m going to try to test it with Win98 this afternoon. I’d rate the chances of it working with Win95B higher than with Win95A but not necessarily as high as with Win98.

Update 2: Indeed, it does work with Win98 (original, I haven’t tested 98SE yet) with the instructions as written. The only caveats: Be sure to double check c:\config.sys, c:\autoexec.bat, and c:\dblspace.ini every step of the way. Windows setup has a tendency to modify their contents without warning, so you can get complaints of missing files when it goes to look for them on a not-yet-existing ramdrive.

Also, Fat32 and DriveSpace are incompatible, so you have to do your initial build on a Fat16 drive.

And for maximum speed, be sure to defrag the compressed volume before booting it into RAM. Sure, ramdisks are invulnerable to the mechanical effects of fragmentation, but the data structures are fragmented too, which slows things down even when no mechanical parts are involved.

How fast is it? I tested it on a Pentium-200 with the Intel VX chipset with 160 MB RAM. I set up a 128-meg ramdisk with a compressed drive using 127 megs total. The system boots in a little over a minute. IE4.0 loads in literally a second. Word 97 loads in two. Not bad for a system that’s suddenly found itself with only 32 MB RAM to work with.

Obsolescence is obsolete.

If you found this post informative or helpful, please share it!