8

I have a laptop on which I have installed Ubuntu 12.04 and Windows Now just for learning purposes I am going to install Backtrack OS on it.

My laptop has 4 GB of RAM so according to the recommendation I have allocated 8 GB of swap space on my hard drive.

can I share the swap space between these two OS (Backtrack and Ubuntu)

I really don't want to waste 8 GB of more space for swap (because as I have noticed it is rarely used and as far as I know OS doesn't store any data in swap space, does it?) So is there a way with which I can share this 8 GB swap partition? If yes how?

10

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:

  • Thanks ...and can please explain the process of adding it to fstab...because I have already installed Backtrack OS and btw jobin I am from TYIT..:p – Null pointer Nov 15 '13 at 16:18
  • Found an answer explaining this verbose: askubuntu.com/questions/232790/… – jobin Nov 15 '13 at 16:32
  • I have installed Ubuntu and Kali in order. But Kali fstab was having Ubuntu's swap too. I commented one from Kali's fstab but still Ubuntu and Kali both uses two Swap partition. I want to correct that and use each separate swap I have created for Ubuntu and Kali. How to do that? – Satya Prakash Sep 10 '17 at 7:08
6

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.