4

I currently have a working installation of MS-DOS 6.2.2 with Windows 3.1. I can only use Windows or DOS individually so I don't see the point of having a swap-file for Windows taking up space that can't be used for the DOS %TEMP% directory.

Let's assume that I have a separate %TEMP% directory for when Windows starts. How can I configure DOS to overwrite the Windows swap area with the contents of the %TEMP% directory?

  • 3
    I don't really think it is useful to have a swap file for DOS in a relatively modern computer that has enough memory to properly use HIMEM.SYS and EMM386 – tofro Jun 18 '17 at 12:27
  • 5
    You could delete the Windows swap file when running MS-DOS and when running Windows recreate the swap file and delete the contents of the TEMP directory. I don't think this going to worth the effort though. You'd need to have MS-DOS applications that need the extra disk space, and Windows applications that need the extra virtual memory but not the extra disk space. And be willing to put up with the longer startup times this would require. – Ross Ridge Jun 18 '17 at 20:18
  • 2
    Fragmentation could be a problem, yes, but I don't see any way else to make the disk space taken up by the Windows swap file generally available to MS-DOS applications. One thing that makes my suggestion easier to implement is that Windows 3.1 supports using a temporary swap file that it will automatically delete on exit and recreate on startup. – Ross Ridge Jun 18 '17 at 20:27
  • 1
    Is DESQView open-sourced, @RossRidge? I remember hearing that QuarterDeck (now Symantec) released it into the public domain some years back, but I can't remember if the source code was ever published. And now, of course, 10+ years later, I can't find any extant references to it online. – Cody Gray Jun 19 '17 at 16:15
  • 2
    @Cody DESQview was never open-sourced, just released as freeware. It used to be available from chsoft.com, but the FTP server has disappeared. oldskool.org still has it. – Stephen Kitt Jun 19 '17 at 21:06
3

Firstly, you shouldn't do that. It will be sloooow, and won't be worth the time spent on it, mostly because old hard drives are kinda slow and not very useful in terms of using them as swap. Besides that, it may lead to slowing down the HDD or even HDD malfunction, where you may not be able to restore the data (old HDDs are mostly heavily-used ones, and making a new swapfile will make things even worse in terms of write-count).

The easiest solution would be adding something like that to the begining of AUTOEXEC.BAT:

DEL swapfile.sys
MKDIR C:/DOS/TMP
SET TEMP=C:/DOS/TMP

Where swapfile.sys is the name of your swapfile.

Then, the best approach is probably creating a script that will look like this:

@ECHO OFF
ECHO Creating swapfile.sys, please wait...
FOR /l %i in (1,1,1000) DO ECHO. > swapfile.sys
WIN.COM
  • 2
    "mostly because old hard drives are kinda slow and not very useful in terms of using them as swap." Yes, but old computers are also kinda slow. The relative difference between computational power and disk-access speed was much smaller in the DOS days than it is now. Also, swap space isn't used for performance reasons. It's used to allow you to do things that you couldn't otherwise use because you don't have enough physical RAM. – Cody Gray Jun 20 '17 at 11:00
  • @CodyGray Well, sometimes having SWAP on a slow hard drive makes performance worse(even taking other old hardware into consideration), that's what i was trying to write. – redsPL Jun 20 '17 at 16:24
  • 4
    I wouldn't recommend creating a Windows swap in a batch file like this. Windows 3.1 can create its own temporary swap file as necessarily, while a file with a 1000 blank lines is unlikely to work as a permanent swap file. Also FOR /l won't work in MS-DOS. That, and any of the other FOR options, requires that the script be run using cmd.exe under a Windows NT based OS. You also need to use backslashes (\) instead of forward slashes (/) in your path names. – Ross Ridge Jun 20 '17 at 18:06
  • 1
    It is true that the swap file should generally be placed on the fastest disk you have available. However, it is not true that simply having a swap file makes performance slower. In a sane implementation of virtual memory, the swap file wouldn't even be used unless it was necessary because physical memory was full. (That's sort of beginning to change on modern systems, with caching and memory compression, but these ideas are very new, weren't ever used on retro systems, and wouldn't make sense there anyway for a variety of reasons.) What you were saying just isn't true. – Cody Gray Jun 21 '17 at 3:02
  • Another reason not to do this: the Windows 386 swap file must be contiguously allocated on the disk, which this approach doesn't guarantee. – Jules May 15 '18 at 4:41
3

Deleting and recreating the swap file is a really bad idea for reasons in comments.

Here follows an insane idea that would work if you pulled it off.

1) Create Permanent Swap File; ensure its contiguous. This is best done with a disk editor to ensure you also align on a cylinder boundary. Thankfully defrag.exe is sane enough to not move the windows swap file.

2) Create overlapping primary partition so that it aligns with the the swap file. I will now assume that this ends up on D:; replace script references as necessary

3) Add lines to autoexec.bat:

FORMAT D: /Q < Y.CHR > NUL
MD D:\TEMP
SET TMP=D:\TEMP
SET TEMP=D:\TEMP

3) Make C:\WINDOWS\TEMP if it doesn't already exist

4) Rename win.com to runwin.com

5) Create win.bat as follows

subst D: C:\WINDOWS
runwin.com
subst D: /D
FORMAT D: /Q < C:\Y.CHR > NUL
MD D:\TEMP

6) Create Y.CHR

echo Y> C:\Y.CHR

7) Reboot

The subst command can be used to mask off drives you don't want to be able to access. I've done this in the past when I had two paths to the same disk so I got two drive letters for it, and drove smartdrv.exe bonkers.

Does it work? Yes. Are you going to regret it if you ever reconfigure your windows swap file again? Yes.

  • 1
    When I read the question my first thought was to write a loadable device driver that would let you mount the swap file as an extra drive, but this is probably neater, as long as you're happy using full cylinders for the job... – Jules May 15 '18 at 4:44
  • @Jules: That's what I thought too, but who has the expertise for that these days? A quick attempt at finding one didn't. – Joshua May 15 '18 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.