login
Header Space

 
 

Re: Share swapfile between Linux and MSWindows?

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
Date: Monday, July 5, 1993 - 6:09 pm

This is becoming a FAQ...

:> Is there a way to share a swapfile between Linux and MSWindows (not
:> simultaneously)?  I am willing to put it in its own partition, if that
:> is what it takes.

Yes, it is possible to share windows swap and linux swap. I have
them on separate artition, but I've also heard that linux can
use windows swap files directly, but this is a sloooww way to do
it. 

:> Would this involve a script using fdisk to change the partition type?

No, It isn't necessary.

:> Would the partition have to be reformmated every time I changed from
:> Linux to MSWindows or back again?

If you mean under dos... no. If you mean under linux... not
necessarily, but just saying "mkswap /dev/??? nnnn" during reboot
is faster than first copying out the old partition info and then
copying new onto it.


Here is a description how I did it. Works fine for me.

In the beginning I had a 12MB linux swap partition. First I did
"swapoff" under linux and then marked that partion to be a dos
partition, so that msdos could also see it. I also wrote down the
size of swap partition in block (kilobytes), since this info were
needed later. After that I rebooted to dos and formatted my new
swap partition to dos and then under windows created a permanent
swap file to that partition. Swap file took whole partition even
windows complains before creating it. I rebooted again. This time
to linux (swapping disabled, of course). There I mounted my new
"dos" partition to see its total size in kilobytes with df. The
difference between the size I wrote down earlier and the size df
reported were the number of blocks I had to save when changing
from windows swap to linux swap (and restore when doing it other
direction). In my case I had to save 28KB from the beginning of
the partition (FATs and the root directory).

Here are appropriate lines from my /etc/rc (my swap partition is
is on /dev/hda1 and my msdos filesystem is mounted under /dos. I
originally saved the partition info there):

===============================================================================
if [ ! -f /dos/winswap.lnx ]; then
  echo -n "Saving windows swap... "
  dd if=/dev/hda1 of=/dos/winswap.lnx bs=512 count=58 && \
   echo "Done."
fi
echo -n "Creating swap... " && /etc/mkswap /dev/hda1 12545 
/etc/swapon -a && echo "Adding swap..."
===============================================================================

Here is how I restore my windows swap. When shutting down I
simply swapoff and copy /dos/winswap.lnx to the beginning of
/dev/hda1. I must point out that I'm using sysVinit-2.4 and thus
this script mihgt apperar under different name (or doesn't even
appear at all) in your system. Check your files and manual pages!
I do this in /etc/brc, which is executed just before system is
brought down (that is, after user processes are killed by
reboot).  Here are appropriate lines from my /etc/brc:

===============================================================================
if [ -f /dos/winswap.lnx ]; then
  echo 'Restoring windows swap.'
  dd if=/dos/winswap.lnx of=/dev/hda1 bs=512 count=58
  sync
  sync
fi
===============================================================================

I have also seen other descriptions how to do this "swap
sharing", but they were somehow more comples and needed suxh
tools like norton utilities.

If you, or anybody else, have anything to ask or any suggestions
or anything else to point out, please, feel free and comment to
the newsgroup or to me via mail.


Juha
--
THE CHEMIST'S RULE: Never take more than three data points. There will always
           be some kind of graph paper on which they fall in a straight line.

THE CHEMIST'S RULE, FIRST COROLLARY: If you have only one kind of graph paper,
           never take more than two data points.
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: Share swapfile between Linux and MSWindows?, Juha Virtanen, (Mon Jul 5, 6:09 pm)
speck-geostationary