Sharing of swap partiton between linux systems?

Solution 1:

Yes, you can share swap area with two or more operating systems. To share swap area, create the swap area when you install the first operating system and then when you install the second one, do not create a new swap area, instead just use the first OS's swap area as the mount point for swap area of the second OS.

If you have already installed both OS's, use gparted to create a common swap area and then add it to your /etc/fstab file to automount it at boot-time.

Just in case you would like to know the drawbacks of using a shared swap area, refer this question on StackExchange:

  • Ill-effects of sharing swap area

Solution 2:

Yes, it's possible. The swap is only used while the system is running, so you can do what you want with the swap space when it isn't running, such as use it as swap space for another Linux installation. You can even share swap space between Linux and Windows, but it's a bit more work.

There is one exception: if you want to hibernate, then the swap space is in use while the system is hibernating.

If you point the installer at the existing swap space during the installation of the second distribution, it will be able to make use of it.

With today's disk sizes, there is usually no point in saving a couple of GB with such tricks. But it's possible.

However, I question the utility in installing two Linux distributions in dual boot. Dual boot sucks — you can't run the two operating systems at the same time. If you want to run programs from two different Ubuntu releases, or more generally from two Linux distributions, I recommend a different approach: pick the one that has the most recent kernel and use it as your main operating system. Install the second one and run programs from it directly from your installed system, using schroot. I've written a guide on doing this which covers the installation of the second system using debootstrap and the schroot setup.