Penguin
Note: You are viewing an old revision of this page. View the current version.

Linux Swap Space Mini-HOWTO


Linux Swap Space Mini-HOWTO

Rahul U. Joshi,

jurahul@hotmail.com http://jurahul.freeservers.comv1.42, 18 January 2000


This Linux Mini-HOWTO describes how to share your Linux swap partition with Windows.


1. Introduction

2. What you need

3. Recent Changes and versions

4. Administrative

  • 4.1 Copyright
  • 4.2 Disclaimer

5. Before you begin

6. The Procedure

  • 6.1 Turn off swapping and create a DOS partition
  • 6.2 Tell Windows the location of the new swap file
  • 6.3 Back up the Total Special Sectors
  • 6.4 Modify the initialization and shutdown scripts to handle our new configuration
  • 6.5 Reenable swapping

7. A couple of notes

8. What are we exactly doing ?

9. The swapinit.sh script

10. The swaphalt.sh script

11. The msinfo.sh script

12. The original msinfo file

13. Acknowledgements, feedback and dedication


1. Introduction

Many people use both Linux and MS-Windows. The ability to do so is an important part of "the Linux revolution"; i.e. letting people experiment with (and get hooked on) Linux while still being able to run their off-the-shelf software. Since both Linux and MS-Windows use virtual memory with swap to disk, a frequently occurring question in comp.os.linux.setup is how to share swap spaces, in order to reduce the amount of disk space needed.

There are several methods for sharing swap spaces, the one described in this document is probably the most complicated one but is the only one I have encountered that allows maximum performance for both environments without the risk of trashing a disk partition. If you are using DOS, then many DOS applications manage their own swap files. You can also share the Linux swap partition with these applications.


2. What you need

This procedure have a few requirements that need to be filled. I strongly recommend that you fill these requirements anyway, as there are several problems with older versions.

# MS-DOS 5.0 or newer and MS-Windows 3.1/3.11 OR MS-Windows 95/98 #

# A shutdown/init that knows to run a file on shutdown. (The !SysVinit?-2.50 package can do this, for example.

SysVinit?-2.50 is available from sunsite.unc.edu in

/pub/Linux/system/Daemons. Almost all current distributions use this init package.) #


3. Recent Changes and versions

  • Version 1.3 -- Written by H. Peter Anvin, and was not maintained

from 15 Jan 1998. *

  • Version 1.4 -- Based on v1.3, but added more details.

Currently maintained by Rahul U. Joshi *

  • Version 1.42 -- Deleted the recovery section for v1.4 users an v1.4

never actually appeared on the LDP website. *

Modifications by Rahul U. Joshi

Date: 26 Nov 1999

  • Added Windows 95/98 specific details.

*

  • Added Red Hat Linux specific details.

*

  • Modified the msinfo program.

*

  • Added sections 5 to 12.

*

  • Completely revamped the "Procedure" section to make it more understandable.

*

  • Split up the swap initialization and halt into two shell scripts.

*

  • Modified the scripts to handle signature verification more than once.

*

  • Added details about new type swap areas.

*

  • Added more reliable schemes.

*


4. Administrative

4.1 Copyright

Unless otherwise stated, Linux HOWTO documents are copyrighted by their respective authors. Linux HOWTO documents may be reproduced and distributed in whole or in part, in any medium physical or electronic, as long as this copyright notice is retained on all copies. Commercial redistribution is allowed and encouraged; however, the author would like to be notified of any such distributions.

All translations, derivative works, or aggregate works incorporating any Linux HOWTO documents must be covered under this copyright notice. That is, you may not produce a derivative work from a HOWTO and impose additional restrictions on its distribution. Exceptions to these rules may be granted under certain conditions; please contact the Linux HOWTO coordinator at the address given below.

In short, we wish to promote dissemination of this information through as many channels as possible. However, we do wish to retain copyright on the HOWTO documents, and would like to be notified of any plans to redistribute the HOWTOs.

If you have questions, please contact Tim Bynum, the Linux HOWTO coordinator, at linux-howto@sunsite.unc.edu via email.

4.2 Disclaimer

Although I have tried my best to bring out various facts, the author is not responsible for any damage due to the actions taken based upon the information contained in this document. It is impossible to test the things under all the configurations, so probably some of the hints given in this document may be buggy and may not work on your system. In case you trace the bug, let me know it first !

This document is provided ``as is''. I put great effort into writing it as accurately as I could, but you use the information contained in it at your own risk. In no event shall I be liable for any damages resulting from the use of this work.

In case you are planning to include this HOWTO on some distribution medium or in print, I will like to have an acknowledgement e-mail (just for my record). In that case, I may also be able to send you the latest version of the document.


5. Before you begin

This is not a step by step HOWTO. The reader is expected to first read the entire document so that he (or she) becomes aware of the possible pitfalls and performance bottlenecks. After having a fair idea as to what steps are to be taken, he (or she) can then follow the next section in a step by step manner. Since you will be playing as a root and that too with the system initialization files, be alert as to what you are doing. Write in those files comments for those sections that you added, and when you want to remove a section, do not delete it. Instead just comment it out. (In shell scripts comments begin with a pound(#) sign). In case things go wrong, you may restore your original configuration by removing the changes you did. Although you are not required to know shell scripting since I have given all those that would be needed, some knowledge may be advantageous both for understanding as well for debugging.


6. The Procedure

NOTE: This procedure has been written keeping in mind !RedHat Linux 6.0 Although this procedure in general is applicable for all Linux distributions, the details may vary. You are welcome to add the details for your distribution. Many users will already have a swap partition devoted to Linux. I assume you have one.

6.1 Turn off swapping and create a DOS partition

*

Boot Linux. Turn off swapping by editing the /etc/fstab file and commenting the line that describes your swap partition.

*

*

Using fdisk under Linux, delete the swap partition in order to create free space on the disk.

*

*

Boot DOS. Create a DOS partition (using FDISK) the size = the size swap space you want. If you cannot create the partition (probably because DOS FDISK says that all the space in extended partition is allocated to the logical drive), you can use fdisk or cfdisk under Linux to create the partition. You can even just change the type of your swap partition from 82h (Linux Swap) to 06h (FAT16). In that case you don't need to delete the swap partition, just change the type.

*

*

Once you have created the partition, Boot DOS if you are not already in DOS. DOS will be assigned a drive letter to your new partition. Use that drive letter instead of X whenever these instructions lists a command like "LABEL X:" or "COPY FOO X:DUMMY.DAT"

*

*

Format this partition using the DOS FORMAT command.

C:\>FORMAT X:

*

*

Set the volume label on this partition to "SWAP SPACE" using the DOS LABEL command. Verify it by the DIR command. Please do this as a separate step. Some versions of FORMAT do not seem to put the volume label in the boot sector as it should.

Fatal Error:

lib/CachedMarkup.php (In template 'browse' < 'body' < 'html'):257: Error: Pure virtual

lib/InlineParser.php:336: Warning: Invalid [] syntax ignored: [[Note: some people has written me saying the volume label is (...repeated 30 times)

  • stored in the root directory. Yes, but at least since DOS 5.0 it has also been
  • in the boot sector.]

lib/BlockParser.php:552: Notice: Internal Error: no block advance



Fatal PhpWiki Error

lib/CachedMarkup.php (In template 'browse' < 'body' < 'html'):257: Error: Pure virtual