The search for the compressed ramdisk is over!

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.

Optimizing DOS and the BIOS, plus new iMacs

Optimizing DOS (Or: A New Use for Ancient Equipment). I was thinking yesterday, I wished I had a computer that could just hold disk images and do data recovery. Then I remembered I had a DECpc 320P laptop laying under my desk. I cranked it up. MS-DOS 5, 20 MHz 386sx, 80-meg drive, 6 MB RAM, grayscale VGA display. So I installed Norton Utilities 8, the main thing I wanted to run (I had a retail box sitting on my shelf), then of course I set out to optimize it. Optimizing DOS is really easy: it’s just a question of disk optimization and memory management. I cleaned up the root directory, pulled the extraneous files in the C:\DOS directory (the .cpi files, all the .sys files, all the .bas files). Then I ran Speed Disk, setting it to sort directory entries by size in descending order, put directories first, and do full optimization. It took about 30 minutes. If I’d been really bored I could have mapped out what executables are most important to me and put those first. Since DOS doesn’t track file access dates it can’t automatically put your frequently accessed files first like Speed Disk for Windows does.

Of course when I installed Norton Utilities 8 I installed NDOS, its command.com replacement. Built-in command history, improved resident utilities, and thanks to its memory management, it actually uses far less conventional memory (but more memory total) than command.com. That’s OK; with 6 MB of RAM I can afford to give up a fair bit of extended memory for better functionality.

Once I was happy with all that, I also attacked the startup files. I started off with a basic config.sys:

device=c:\dos\himem.sys
device=c:\dos\emm386.exe noems
dos=high,umb
files=30

Then I went into autoexec.bat, consolidated the PATH statements into one (it read: PATH C:\WINDOWS;C:\DOS;C:\DOS\u;C:\MOUSE) and added the prefix LH to all lines that ran TSRs or device drivers (such as MOUSE.EXE). Upon further reflection, I should have moved the Mouse directory into C:\DOS to save a root directory entry.

I added the NCACHE2 disk cache to autoexec.bat– NCACHE2 /ext=4096 /optimize=s /usehigh=on /a a c /usehma=on /multi=on. That turns on multitasking, enables caching of both C: and A:, tells it to use 4 MB of memory, use high memory, and use extended memory. My goal was to use as much memory as prudently as possible, since I’d be using this just for DOS (and mosly for running Norton Utilities).

I also set up a 512K RAMdisk using RAMDRIVE.SYS (devicehigh=c:\dos\ramdrive.sys 512 128 4). Then I added these lines to autoexec.bat:

md d:\temp
set tmp=d:\temp
set temp=d:\temp

Now when an app wants to write temp files, it does it to a RAMdisk. The other parameters tell it to use 128K sectors to save space, and put 4 entries in the root directory, also to save space. With DOS 5, that was the minimum. I don’t need any more than one, since I’m making a subdirectory. I could just point the temp directory to the root of D:, but I’d rather have dynamic allocation of the number of directory entries. This setting is more versatile–if I need two big files in the temp directory, I’m not wasting space on directory entries. If on the other hand I need tons of tiny files, I’m guaranteed not to run out of entries.

It’s not a barn burner by any stretch, but it’s reasonably quick considering its specs. Now when someone trashes a floppy disk, I can just throw it in the 320P, run Disk Doctor and Disktool on it (and in a pinch, Norton Disk Editor), copy the data to the HD, then throw the recovered data onto a new, freshly formatted floppy. I’ll only use it a couple of times a year, but when I need such a beast, I need it badly. And if I have the need to run some other old obscure DOS program that won’t run on newer machines, the 320P can come to my rescue again too. It runs the software well, it boots in seconds–what more can I ask?

I could have done a couple more things, such as a  screen accelerator and a keyboard accelerator . Maybe today if I have time.

I was tempted to put Small Linux ( http://www.superant.com/smalllinux/ ) on it, but frankly, DOS 5 and Norton Utilities 8 is more useful to me. I’m not sure what I’d do with a non-networkable Linux box with only 6 MB RAM and a monochrome display.

A useful (but unfortunately dated) link. I stumbled across this yesterday: The BIOS Survival Guide , a nicely-done guide to BIOS settings. Unfortunately it stopped being maintained in 1997, so it’s most useful for tweaking very old PCs. Still, it’s better than nothing, and most modern PCs still have most of these settings. And reading this does give you a prayer of understanding the settings in a modern PC.

If you want to optimize your BIOS, this is about as good a starting point as you’re going to find online for free. For more recent systems, you’ll be better served by The BIOS Companion, written by Phil Croucher (one of the co-authors of this piece.) You can get a sample from that book at http://www.electrocution.com/biosc.htm .

New iMac flavors. Steve Jobs unveiled the new iMacs this week. The new flavors: Blue Dalmation and Flower Power. Yes, they’re as hideous as they sound. Maybe worse. Check the usual news outlets. They’d go great in a computer room with a leopard-skin chair, shag carpet, and lava lamps. And don’t forget the 8-track cranking out Jefferson Airplane and Grateful Dead tunes.

I think the outside-the-box look of Mir, the PC Gatermann and I built as a Linux gateway (see yesterday), is far more tasteful–and that’s not exactly the best idea we ever had.

12/29/2000

Mailbag:  Free FDISK; Reiser

ReiserFS experiments. I spent a good deal of time yesterday figuring out how to convert an ext2 system to a Reiser system (for greater speed and fault-tolerance) when Brian Bilbrey pointed out how to create an all-Reiser system from the get-go with Mandrake 7.2.

The trick is to pick expert mode when you get to the Setup filesystems portion of installation, click on some free space (making some if necessary), then click create. Under the Filesystem type drop-down list, you can select Linux native, Linux swap, ReiserFS, or FAT32. Pick Reiser, and you’re set.

Now the big question… How to partition? I like to put /boot on a FAT partition just in case something goes horribly wrong, then I can recover the system even if my Linux boot disk fails by using any old DOS boot disk. It doesn’t have to be very big. ReiserFS may make you nervous since it hasn’t been officially blessed by the kernel team, but at the very least use it for the /tmp partition, and I’d use it for /var as well. Since /tmp and /var are where lots of little files get written constantly, they’re ideal for Reiser, and since those files tend to have short lifespans, it’s good to use a partition to isolate them from the rest of your files. Fragmentation isn’t much of a problem with Linux; partitioning wisely makes it even less so. Neither of these partitions has to be huge; a few hundred megs ought to be plenty. The two biggest partitions should be / and /home. The / partition, of course, holds the OS, while /home holds user data. If you wish, you can place /usr on a separate disk if you want apps on a separate disk from the OS for performance’s sake.

And remember, the disk is faster towards the front, so put speed-critical partitions like /root and /home up front. Put /boot right up front unless you’re using a modern distribution that uses the new GRUB bootloader; LILO has problems with high partition numbers. If you’re using GRUB (Mandrake 7.2 does), you can put /boot at the very end. Since these files are accessed at boot time and then never again, they don’t have to have the greatest speed.

Mailbag:  Free FDISK; Reiser

Binary file editing and hardware compatibility

Binary file editing. I’ve recovered many a student’s term paper from munged disks over the years using Norton Disk Edit, from the Norton Utilities (making myself a hero many times). Usually I can only recover the plain text, but that’s a lot better than nothing. Rebuilding an Excel spreadsheet or a QuarkXPress document is much harder–you have to know the file formats, which I don’t.
But at any rate, I’ve on a number of occasions had to run NDE to recover meeting minutes or other documents at work. The sheer number of times I have to do this made me adamantly opposed to widespread use of NTFS at work. Sure, the extra security and other features is nice, but try telling that to an irate user who just lost the day’s work for some reason. The “technical superiority” argument doesn’t hold any water there.

Enter WinHex (www.winhex.com). Now it doesn’t matter so much that the powers that be at work didn’t listen to my arguments. 🙂 (NDE from vanilla DOS would still be safer, since the disk will be in suspended state, but I guess you could yank the drive and put it in another PC for editing.)

For those who’ve never done this before, you can recover data using a brute force method of searching for known text strings that appeared in the file. For example, I once worked on recovering a thesis that contained the line “I walk through a valley of hands.” Chances are, if I search for that, I’m gonna find the rest of the document in close proximity. A Windows-based editor makes this kind of data recovery very nice–search for the string, keeping Notepad open, then copy and paste the strings as you find them.

Knowledge of the underlying filesystem (FAT or NTFS) is helpful but not essential, as is knowledge of the file format involved. If worse comes to worse, you can recover the strings out of the file and have the app open to re-enter it (being aware that you run the risk of overwriting the data, of course).

I found some useful links on the WinHex site detailing certain file formats.

This is a program I suspect I’ll be buying soon, since my need for it is probably more a matter of when rather than if.

———-

From: “James Cooley”

Subject: Tip for tat?

Hi Dave,

I waded through all your views (That’s where all those hits came from!) and I like your style and learned a great deal. Here’s another tip I didn’t see mentioned: in autoexec.bat, add the following: set temp=C:\temp set tmp=C:\temp set tmpdir=C:\temp

You could use the ramdisk drive you mention, of course. I don’t know if this speeds things up, but it sure helps minimize the clutter from most installs when you clean the temp directory periodically. I use C:\temp2 for those disposable downloads because some programs hate extracting into their own directory. Norton Anti-Virus comes to mind: if you run the updates from C:\temp it hangs.

I ordered _UNIX in a Nutshell_ from a recommendation on your site, but got a 500 page tome instead of the 92 pages you mentioned. If you recall the O’Rielly book I’m talking about, could you give me the exact name so I needn’t hunt it down again?

Hope your hands are healing.

Regards,

Jim

———-

Thanks. I’m glad you enjoyed it (but isn’t that an awful lot of reading?)

I’ve seen the tmpdir trick; fortunately not a whole lot of programs use it anymore but that is useful. Thanks.

And yes, as you observe it’s a good idea to use a separate dir for program installs. I try to avoid hanging it directly off the root for speed considerations (a clean root dir is a fast root dir)–I usually stick it on the Windows desktop out of laziness. That’s not the best place for it either, but it’s convenient to get to.

The 92-page book is Learning the Unix Operating System, by Jerry Peek and others. It’s about $12. The 500-page Unix in a Nutshell is useful, but more as a reference. I’ve read it almost cover-to-cover, but I really don’t like to read the big Nutshell books that way. Information overload, you know?

———-

From: “al wynn”

Subject: MAX screen resolution for Win95/98/2000

Do you know the MAXIMUM screen resolutions for Win95/98/2000 (in pixels) ? Which operating systems can support a dual-monitors setting ?

NEC 15′ MultiSync CRT monitors max out at (1280 x 1024 @ 66Hz); for 17′ CRT’s, it’s usually (1600 x 1200 @76Hz). Do you know any 15′ and 17′ models that can handle denser resolutions ? (like (1792 x 1344 @68Hz) or (1920 x 1440 @73Hz) ?

Also, which Manufacturer/Model do you prefer for flat-panel LCD’s ? Which 15′ or 17′ LCD models boast the highest resolution ?

———-

I believe Windows’ limit is determined by the video drivers. So, if a video card ships someday that supports some obnoxious resolution like 3072×2560, Windows should support it. That’s been the case in the past, usually (and not just with the Windows platform–it holds true for other systems as well).

Windows 98 and 2000 support dual monitors.

I’ve never seen a 15″ monitor that does more than 1280×1024, and never seen a 17″ that does more than 1600×1200. I find anything higher than 1024×768 on a 15″ monitor and higher than 1152×864 on a 17″ strains my eyes after a full day of staring at it.

As for flat-panels, I don’t own one so I can’t speak authoritatively. I’d probably buy an NEC or a Mitsubishi if I were going to get one. The price difference between an off-brand flat-panel and a big name is small enough (relative to price) and the price high enough that I’d want to go with someone I know knows how to make quality stuff–I’m not gonna pay $800-900 for something only to have it break after two years. I’m totally sold on NEC, since I bought a used NEC Multisync II monitor in 1990 that was built in 1988. It finally died this year.

A 15″ flat-panel typically does 1024×768, while a 17″ does 1280×1024.

Sound card and hard drive troubleshooting

Sound card woes. Gatermann recently ran into some problems with sound cards forcing his Internet connection to drop. It had literally been six years since I’ve seen a problem like that before, but he kept running into it. Finally, it dawned on me: Try changing slots to force it to use a different interrupt. Therein was the silver bullet. The problem didn’t go away completely, but the culprit arose: the Sound Blaster 16 emulation. So I had him go into Device Manager and put the SB16 emulation on a different interrupt, and the problem went away.
It’s been forever since I’ve seen an honest-to-goodness interrupt conflict. This particular PC has every expansion slot filled with something or other, which is why he ran up against it. Keep that in mind: Just because we have PCI and plug and play these days, doesn’t mean you won’t ever see an interrupt conflict. On a well-expanded system, this ancient problem can occasionally rear its ugly head (while Microchannel required their cards to be capable of interrupt sharing; PCI only *recommends* it–so not every PCI device can share an interrupt, particularly if an ISA device has grabbed it. Alas, Microchannel fell victim to IBM’s greedy overly restrictive licensing terms and raw-dead-fish marketing, so as a result we have cheap PCs today but more headaches than we necessarily need. Speaking of raw-dead-fish marketing, I could mention that the Amiga’s Zorro bus had true plug and play and hundreds of interrupts from Day One in 1985, but nobody wants to hear that. Oops, I said it anyway.)

This problem used to happen all the time when people would put their modems on COM4 and a serial mouse on COM2 (or COM1 and 3). Since those ports by default shared interrupts with one another, you got goofy symptoms like your Internet connection dropping whenever you moved the mouse. People don’t configure their COM ports that way anymore, which is what’s made that problem so rare.

I think I finally got that G4 deployed. Wednesday it decided it didn’t want to shut down, and I had to reinstall the OS to fix it. Then on Thursday, it decided it didn’t want to recognize the mouse button anymore. I still don’t know what exactly I did to fix that–I booted off a spare MacOS 9 partition, ran a battery of disk repair tools and a defragmenter, and the problem went away. So while Mac users can snicker about interrupt problems, their machines aren’t exactly immune to weird problems either.

——-

From: “Gialluca, Tony”

question: RE Optimizing Windows and Temp files

Hi Mr. Farquhar,

In you book on page 112 you discuss placing temp files on a ramdisk. On this page you show an example where:

Set temp=ram disk letter:\temp Set tmp=ram disk letter:\temp

Shouldn’t you also include changing

[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\explorer\Volum eCaches\Temporary files\folder] to “ram disk letter:\temp” also ??

Per the description

([HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\explorer\Volu meCaches\Temporary files\description]) says: “Programs sometimes store temporary information in a TEMP folder. Before a program closes, it usually deletes this information.\r\n\r\nYou can safely delete temporary files that have not been modified in over a week.” The only potential pitfall that I can think of is if windows or programs (say during installations) need this area to remain persistant through reboots, even though the files may be of
a temporary nature…

Your thoughts would be appreciated …

Respectfully,

Tony

———-

To be perfectly honest, I didn’t know that registry key existed (nor did the book’s technical reviewers, evidently). That registry key, too, should be changed, yes. Thanks!

You are correct that if a program does a hard reboot (rather than just exiting to real mode and reloading Windows), you’ll lose the contents of the ramdisk and thus the temp folder. Fortunately, most programs seem to use the temp directory the way they’re supposed to–for temporary, fleeting things. Now if they’d just learn to clean up after themselves…

Of course, this also applies to my advice on creating a temp partition, on page 62.

Thanks much; this is very good information.

———-

From: “Gary M. Berg”

Subject: Maxtor hard drives

Since you’ve been talking about WD and Maxtor hard drives…

I heard rumors just after Win2K SP1 came out that the service pack had problems with machines with Maxtor hard drives. I’ve not been able to find much of anything else on this. What have you heard?

———-

That’s a new one to me. Maybe another reader has heard something, but it sure seems odd. I can’t imagine Microsoft didn’t test SP1 on the major drive manufactuers’ drives (Fujitsu, IBM, Maxtor, Quantum, Samsung, Seagate, and Western Digital), and with Maxtor being one of the Big Two in retail….

Once I get my current big project off my back this weekend, I’m half-tempted to try it just to see. Unless someone already has…