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?
3 Answers
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.

- 829,060
-
If you try to boot into an OS when another is hibernated, will it be not possible or will it boot but the hibernation data get corrupted? I thinking that it may refuse to boot due to some logic in grub or something like that. – paradroid Dec 18 '20 at 16:54
-
1@paradroid I don't think grub knows anything about hibernation. If you boot an OS while another OS is hibernated, it's safe provided that no filesystem is mounted by both OSes. If a filesystem is mounted by the hibernating OS and you mount it in the other OS, expect massive corruption. – Gilles 'SO- stop being evil' Dec 19 '20 at 20:02
-
Thanks. Well I'm wondering what would happen if an ext4 disk is shared with a Linux OS and Windows WSL, as Windows actually partially hibernates when it is 'Shut Down', so I am not sure if the second disk will still be mounted in that case, but this is a Windows issue... – paradroid Dec 21 '20 at 08:53
-
@Gilles'SO-stopbeingevil' From your above comment and answer, if I only share a Data partition between the 2 operating systems. Do you think that it can lead to corruption of data when hibernated on one OS and booted to another? – Porcupine Apr 12 '23 at 03:02
-
@Porcupine Yes. Never use a partition that's mounted by a hibernating system. It's only safe if you unmount that partition before hibernating. – Gilles 'SO- stop being evil' Apr 12 '23 at 08:37
-
@Gilles'SO-stopbeingevil' So basically we should not share any partition or logical volume between the operating systems if we do hibernation? Not even a partition that just contains data like videos and music and pictures? – Porcupine Apr 12 '23 at 23:11
One side effect I can think of is:
- Hibernate system1 (using the swap partition for hibernation).
- Boot system2.
You could lose data.

- 1,024

- 6,255
-
11Murphys 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 09:57
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?

- 67,283
- 35
- 116
- 255

- 9,489
-
-
-
@Tshepang: I was actually thinking from the point of its possibility. Its my mistake. Will edit the answer appropriately. – Navaneeth 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
-
I think Suspend is different from Hibernation. Was that a typo? If not, I dint get your doubt. – Navaneeth Sen Jan 12 '11 at 02:22
swapiness
to 0. – shellholic Jan 11 '11 at 11:20