Linux Swap Space Mini-HOWTO: What are we exactly doing ?

Next Previous Contents

## 8. What are we exactly doing ?

- Both Windows and Linux use swap space. When an OS is shut down, the contents of the swap space are just garbage, the OS doesn't bother about what is in it. Now what is the point in devoting a 60MB partition for swap space to Linux and about 32MB of disk space separately to Windows when only one of them is going to run at a time (It is possible to run both Linux and Windows at the same time, thanks to VMWare. For more information, see VMWare website). So we want Linux and Windows to share the same hard disk space as swap space.

- The problem is that Linux uses a partition as a swap space and Windows uses a file as a swap space. ( Although it is possible to create a swap file for Linux, it is not recommended. See "Linux Installation and Getting Started" by Matt Welsh). Now if Linux uses the same partition on which Windows stores it's swap file, it will overwrite the boot sector, FAT and other data tables that Windows assumes to exist on every drive. Thus, Windows will not be in a position to find the swap file on startup and will create the win386.swp file in the windows directory. Thus, even if by chance, your Linux crashes, Windows will be in a position to start. In such a case ( with Windows swap file in the Windows directory), just restore the DOS/Windows swap info by restarting Linux and the start Windows. Now Windows will be using the swap file on drive X: so you can safely delete the win386.swp file in the windows directory.

- The remedy is to store those critical data tables once on the Linux partition in some file. Then every time Linux starts, check whether the swap space was last used by Linux or Windows (using the label you gave to your partition). If it was Linux, just enable swapping else first make a swap partition on the X: drive using "mkswap /dev/winswap" and then enable swapping.

- When you shut down Linux, it is important to restore the swap partition to the DOS format, so that Windows can start properly. For that purpose we add the

  > `

  >     /bin/zcat /etc/winswap.gz > /dev/winswap

  > `

  command to the halt file.

Next Previous Contents