How to set swap in /etc/initramfs-tools/conf.d/resume if I have two swap partitons?

I have two swap partitions in fstab :

    /dev/sda8    none            swap    sw,pri=1           0       0
    /dev/sdb8    none            swap    sw,pri=1           0       0

How to set swap in /etc/initramfs-tools/conf.d/resume file?

According to SwapFaq this will not work for 12.04:

INFO: This will not work for 12.04, resume from hibernate work differently in 12.04.

How to do it in Ubuntu 12.04?


Solution 1:

Check UUID

 sudo blkid

Then

 sudo gedit /etc/default/grub 

to pull up the boot loader configuration. Look for the line GRUB_CMDLINE_LINUX_DEFAULT="" and using your UUID add:

resume=UUID=41e86209-3802-424b-9a9d-d7683142dab7

That means change this

   GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

to this

  GRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=UUID=41e86209-3802-424b-9a9d-d7683142dab7"

save then edit:

gksu gedit /etc/initramfs-tools/conf.d/resume 

and make sure its contents are

RESUME=UUID=41e86209-3802-424b-9a9d-d7683142dab7 

(with your UUID of course in place of mine). Save the file!

 sudo update-grub
 sudo update-initramfs -u -k all

Reboot!

https://help.ubuntu.com/community/SwapFaq

Edit: Technically only one of the two methods needs to be used, the kernel parameter in the grub file will take precedence over the initramfs resume config file

Solution 2:

(18.04) You can also edit /etc/initramfs-tools/conf.d/resume and change RESUME=UUID=$uuid to the output of blkid /dev/raidN (whatever block device your 2 swap devices are RAID'd as)