4

To install various Linux distributions on the same physical machine, do I need to add a swap partition for each distribution, or one will suffice for all?

jobin
  • 28,567

3 Answers3

7

I assume you are asking about a swap partition.

Yes you can share a swap partition, but each time you install, the swap space will be reformatted. This will change the UUID of the swap partition and you will need to update /etc/fstab in each installed os.

sudo nano /etc/fstab

You will see an entry similar to:

UUID=cee15eca-5b2e-48ad-9735-eae5ac14bc90 none swap sw 0 0

List your partitions with

sudo blkid

and update fstab with the new UUID.

See https://help.ubuntu.com/community/Fstab

Panther
  • 104,528
1

Maybe is solution to add swap like swapfile. You don't need partition for swap and each distribution have his swap.

Take space to make swap

dd if=/dev/zero of=/swapfile bs=1024 count=1048576

Count is size of swapfile

create swap file system

mkswap /swapfile

Turn on swap

swapon /swapfile

End at the end change /etc/fstab

sudo nano /etc/fstab

add line

/swapfile       none    swap    sw      0       0
2707974
  • 10,758
0

Yes, but...

The big restriction if you share your swap across distros is that you will be unable to use hibernation/suspend-to-disk. This uses the swap space to store the current contents of RAM, and if you boot into one distro while another is hibernating, it'll clobber the hibernation information.

(Mixing hibernation and dual-booting is a bad idea in general, because the hibernated data may include cached information about the contents of the hard drive, and the actual contents of the drive may change if you boot into one OS while another is hibernated.)

Mark
  • 1,054