48

In order to save disk space, I want to have two OS installations share a single swap partition (a dual-boot). Is this a good idea?

  • Get more ram, it's cheap, don't use swap, it'll help you with that IO issue. I realize this might not be feasible, but gone are the days where you must have swap. – xenoterracide Jan 11 '11 at 10:10
  • 2
    @xeno if u dont have swap, u lose Suspend ability – tshepang Jan 11 '11 at 11:04
  • 3
    I don't use that, so... yeah I don't use that. – xenoterracide Jan 11 '11 at 11:11
  • 1
    @xenoterracide disks are also cheap, and oomkiller behave strangely. – shellholic Jan 11 '11 at 11:16
  • 2
    @xenoterracide I like your optimistic point of view, but I will continue to have swap partitions because I like safety nets. Just change your swapiness to 0. – shellholic Jan 11 '11 at 11:20
39

It's possible. In fact, you can share the swap space between completely different operating systems, as long as you initialize the swap space when you boot. It used to be relatively common to share swap space between Linux and Windows, back when it represented a significant portion of your hard disk.

Two restrictions come to mind:

  • The OSes cannot be running concurrently (which you might want to do with virtual machines).
  • You can't hibernate one of the OSes while you run another.
21

One side effect I can think of is:

  1. Hibernate system1 (using the swap partition for hibernation).
  2. Boot system2.

You could lose data.

  • 8
    Murphys law suggests that if you do this, you will one day forget, you will hibernate an OS, or boot it into a VM, and you will hose your system, and possibly data. Simple truth - disk space is dirt cheap, your data and work is probably not. Unless you are needing terabyte's of swap space for each OS, just make separate ones. – Danny Staple Jan 11 '11 at 9:57
8

One of my friends tried this. He has installed five or six distributions in a single hard drive.

The first primary partition is for GRUB, and he is able to boot to all the distributions. The second partition is swap. The third partition is an extended partition and each of the distributions are installed into their own logical partitions.

All of the distributions are able to boot and can hibernate. I think you just need to make sure and select the correct distribution after resuming from hibernation.

So, on the basis of his experiment I should say YES this is possible, but I think it can break things. What if distribution 2 wakes up and distribution 1's resume file is using up the swap partition; what's the next thing that's going to happen?
So I, too, agree with all the above posts. Why don't you try to split the swap partitions, rather than taking this huge risk?

  • check the question again: "is it a good idea?" VS "is it possible" – tshepang Jan 11 '11 at 14:39
  • this also means you are essentially repeating what @shellholic said – tshepang Jan 11 '11 at 14:43
  • @Tshepang: I was actually thinking from the point of its possibility. Its my mistake. Will edit the answer appropriately. – Sen Jan 11 '11 at 14:50
  • Before you respond, check the other answers, to ensure you don't repeat what they said. – tshepang Jan 11 '11 at 14:54
  • I never actually Suspend. I really wanted to know if there were other issues I wasn't thinking of. – tshepang Jan 11 '11 at 15:42

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