2

I have 3 Linux distributions on my machine (Ubuntu, Arch and Fedora). I allocated half the RAM size (3GB) as swap for each of them. (I have realized that having 3 distributions is not of much use to me, but I still have them.)

The problem is now the 3 distributions mount all the 3 swap partitions while loading, and treat swap as a single 9GB partition.

Now when I hibernate my system, obviously no distribution ever wakes up from hibernation.

Is there any way to overcome this?

4
  • These are all running at the same time?
    – slm
    Commented Sep 22, 2013 at 16:55
  • @slm: Nope, one at a time.
    – 0xc0de
    Commented Sep 22, 2013 at 16:56
  • Can you explain the situation a bit more? The issue is that you have 1 9GB swap that they all use?
    – slm
    Commented Sep 22, 2013 at 16:58
  • 4
    Each distro should only use the swap partition that is listed in its /etc/fstab... Commented Sep 22, 2013 at 17:01

2 Answers 2

1

If you simply want to share a single swap partition across the 3 distros then create a single swap partition, and then configure each distros via it's /etc/fstab so that each is using the same one.

 /dev/sda1 swap                    swap    defaults        0 0

This question discusses doing this in more detail: Are there any side effects when two distros share a swap partition?.

Specifically from @Gilles answer in that Q&A, you can't hibernate 2 of the OSes into the same swap, and have them be able to resume. From his answer:

You can't hibernate one of the OSes while you run another.

If you're thinking of running any of the distros at the same time, which I don't think you are, then this is dangerous and should not be done. See my answer to this question: Can linux systems on multiple virtual machines share the same swap partition?.

1

As an alternative to slm's answer, if you want each installation to use only a single swap partition (which it sounds like to me), then edit /etc/fstab and remove or comment out all type swap entries except for the one you want the installation in question to use. After you reboot you should be able to confirm using cat /proc/swaps that only one swap partition is in use.

It is perfectly possible that the installation program for each of the distributions detected three swap partitions and just said to itself "heck, they are all there, might as well put them to good use!". It should have asked you first what to do with them, though.

Note that having only half the RAM size as swap and using hibernation is likely to be finicky. It may work, and then again it might not, depending on how much data is actually in RAM that cannot be evicted from caches.

3
  • +1, good answer. two more points to be aware of: 1. you need to tell the kernel for each distro which swap device it should use to resume. you can do this in your grub config - e.g. if ubuntu uses /dev/sda3 as swap then add resume=/dev/sda3 to the GRUB_COMMAND_LINE_LINX="..." variable /etc/default/grub (create the line if it doesn't already exist). Do the same for Arch and Fedora (except use their dedicated swap partitions). Arch Linux has, as usual, great documentation at wiki.archlinux.org/index.php/Suspend_and_Hibernate (tailored for Arch but useful for any distro).
    – cas
    Commented Sep 23, 2013 at 0:53
  • 2. if you are using systemd rather than sysvinit or upstart, then it will use all swap devices that it can find by default. As well as editing /etc/fstab you probably also need to configure systemd to only use one of the swap devices. I'm not familiar with systemd so can't give any details on how to do that.
    – cas
    Commented Sep 23, 2013 at 0:57
  • BTW based on what I read in the Arch Suspend/Hibernate page I mentioned, it's probably best to add 'noauto' to the /etc/fstab lines for unwanted swap partitions rather than delete them - that should prevent systemd or anything else from automatically re-adding the swap devices if it finds them.
    – cas
    Commented Sep 23, 2013 at 0:57

Not the answer you're looking for? Browse other questions tagged .