Notes

Change Swap partition in Ubuntu

Edit on GitHub


System Administration
  • Create swap and turn it on
  • add swap entry to fstab
  • update grub sudo gedit /etc/default/grub
  • update sudo gedit /etc/initramfs-tools/conf.d/resume
  • you can get UUID with sudo blkid
  • if you just update the fstab and not the RESUME values, it’ll not boot on the next restart, will give an error about resume device.
 1# prepare your partitions
 2swapoff /dev/sda2
 3mkswap /dev/sda3
 4swapon /dev/sda3
 5
 6# find swap uuid
 7sudo blkid | grep swap
 8# OR
 9sudo echo ls -l /dev/disk/by-uuid | grep sda3 |  cut -d' '  -f8 >> /etc/fstab
10
11# edit swap entry in /etc/fstab
12gksu gedit /etc/fstab
13
14# edit the uuid line in /etc/initramfs-tools/conf.d/resume
15gksu gedit /etc/initramfs-tools/conf.d/resume
16
17# In terminal, execute this command
18sudo update-initramfs -u

you can test your hibernation here, if it doesn’t work:

1# check your /etc/default/grub file
2gksu gedit /etc/default/grub
3
4# Depending on your version : if a line looks like
5GRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=UUID=<old_swap_partition_uuid>"
6# then modify it accordingly; otherwise that's all, you're done
7
8# execute in terminal
9sudo update-grub