From: krej@electrum.kth.se (Kristian Ejvind) Subject: Re: Linux and MS Windows 3.1 (yuck) swap space. Date: Wed, 15 Sep 1993 22:20:16 GMT
In article <CDCEr7.1BB@bt-sys.bt.co.uk> cbeauch@xenon (Chris Beauchamp) writes:
> I am about to install SLS (latest version) on a Dell 486sx25, but I'm
> only using half the hard disk,the other half being used for DOS and Windows.
>
> I have a 12Mb Linux swap partition - is this possible to be used as both a
> Linux and a Windows swapfile? What does Linux do to this partition? Does it
> put anything corruptable on it?
OK, here we go again: 'windows-linux swap in common?'. Perhaps time for
moving this into the FAQ (I assume it's not there already, havn't checked...)?
A swap *file* cannot be shared inbetween, as dos can't access the linux file
system and linux can't swap on the dos file system. However a linux swap
partion can be made into a swap file for windows at the cost of a few
seconds longer time to reboot. If you want to do things the same way as I
have done then follow these steps: (remember to subtitute the sizes and
partions to match your computer, else.... bad luck!)
1) Decide how much swap space you need and create a partion to swap on with
fdisk (or any other disk partioning program). I chose to make it about 6M or
to be exact 5967 blocks large and on /dev/hda4. Make the partion a DOS
partion. Mine is a primary 12-bit-fat (id 1) partion.
2) Erase the partion completely so that it will compress to the smallest
possible size. This can be done with :
dd if=/dev/zero of=/dev/hda4
while running linux. If you want you can use norton's wipeinfo to
'Wipe the entire drive' but this must be done after step 3). Neither
'format f:' or 'del f:*.*' will erase the data on the disk, they just
delete the information in the directory block(s) and wont work.
3) (Re)Boot dos. The swap partion will show up as a new 'disk letter' in
dos, which dos wont be able to read (dos says something like 'Invalid
media error on drive F'). My swap partion shows up as F:. Format
the new drive:
c:\>format f:
4) Start windows (if you are running windows 3.0 you must start it in
real mode: c:\>win /r) and create a permanent swap file as large as the new
partion. Ignore the warning that windows won't use more than the recommended
size, it will. In windows 3.0 this is done by closing ALL active applications
excluding the program manager, selecting File/Run and run 'system/swapfile'.
In windows 3.1 it's in the control panel under '386 Enh' and 'virtual memory'.
5) Reboot your computer into linux immediately after creating the
swapfile. DO NOT start windows.
6) Save and compress the swap partion to a file:
dd if=/dev/hda4 | gzip -9 > /.winswap
Since you erased the whole partion the compressed file will become
very small; from my computer:
23:27-oden:/>ls -l .winswap
-r-------- 1 root root 9431 Apr 10 20:23 .winswap
7) Place the following commands in your /etc/rc:
/bin/mkswap /dev/hda4 5967
/bin/swapon -a
and a line in /etc/fstab describing your swap partion:
/dev/hda4 none swap defaults
8) These commands will destroy the dos partion and the windows swap
file and must be restored before windows can be used. I do this when I
reboot linux automatically with this script which I have named
/etc/reboot and with a link to it from /etc/halt:
----/etc/reboot-----snip-----8<--------
#!/bin/sh -
if [ "root" != "`whoami`" ]
then
echo "Sorry "`whoami`. You must be root to reboot!. Exiting.
exit 1
fi
echo `basename $0` in progress. Please standby
swapoff /dev/hda4
/usr/local/bin/gunzip < /.winswap > /dev/hda4
exec /etc/.hidden/`basename $0` $*
----end /etc/reboot-----snip-----8<----
and I have moved the original /etc/reboot and /etc/halt to
/etc/.hidden/reboot and /etc/.hidden/halt
9) Enjoy.
10) Realize that 6M swap isn't enough. Sigh :-(
I have seen some peolpe suggesting that it is possible to just save
the beginning of the partion (just enough to hold the boot block, the
fat and the root directory), and others saying that you must save the
whole partion but I havn't bothered to investigate this matter, the
solution above works just perfect.
/Kristian
p.s. I hope I havn't mistyped anything but anyway: Be careful when
dealing with the disk partions as you will blame yourself to death
when you have erased your whole dos partion with your five years worth
of work on just because you typed /dev/hda4 instead of /dev/hda3 ;-)