22

I didn't use a swap partition during installation so now that my ubuntu is installed, I used GParted Partition Editor to create an unallocated partition which I formatted as linux-swap. It didn't automatically mount so I right clicked it and selected swapon. Now, whenever I boot the laptop, the partition is not mounted automatically. Swapon still works but if the partition isn't mounted at boot, its as good as useless. I saw some answers which said to edit some file named Fstab, but I'm not sure about what changes to make... Please help me by giving step-by-step instructions as I'm a TOTAL noob and don't know U of Ubuntu, I'm having a lot of problems... please help me! :'( :( Here's what my fstab file contains-

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda2 during installation
UUID=33a0fc77-06b0-406c-95fd-15bf7033b619 /               ext4    errors=remount-ro 0       1
# a swapfile is not a swap partition, no line here
#   use  dphys-swapfile swap[on|off]  for that
1
  • 1
    Can you post the output of sudo blkid. It will show the UUID of the swap partition, and we can then add it to /etc/fstab. Dec 19, 2015 at 11:12

3 Answers 3

25

This is your previous /etc/fstab:

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda2 during installation
UUID=33a0fc77-06b0-406c-95fd-15bf7033b619 /               ext4    errors=remount-ro 0       1
# a swapfile is not a swap partition, no line here
#   use  dphys-swapfile swap[on|off]  for that

Now, to add your swap partition to it, do the following:

  1. Open Gparted.

    Gparted screenshot

  2. Right-click on the swap partition and click on Information.

    select partition in Gparted

  3. Note down your UUID.

    UUID in partition info

  4. Now, modify your previous /etc/fstab, by doing the following:

    • Open the file by typing the command:

      sudo -H gedit /etc/fstab
      
    • Then, add this line,

      UUID=THE UUID YOU OBTAINED FROM ABOVE none       swap   sw         0     0
      

      after the line

      # a swapfile is not a swap partition, no line here
      
    • Save the file and restart your computer. Everything should be working now.

6
  • It worked!! Thanks a lot! You're a god... But hibernate and is still not working. I have 2gb RAM and 3gb swap. Dec 21, 2015 at 20:37
  • @HrijulBhatnagar - The question was only about swap so, I answered it at that. If you want to know how to hibernate, then, please ask a new question and share the link in this comment section, I will answer it for you. Also, if the answer helped, then PLEASE ACCEPT THE ANSWER AND UPVOTE IT.
    – Raphael
    Dec 22, 2015 at 3:50
  • I did upvote it but since I'm a new user, it says that I need a reputation of 15 to publicly display my vote... Dec 23, 2015 at 15:11
  • @HrijulBhatnagar - If you want the answer to be accepted then click on the tick below the upvote downvote buttons.
    – Raphael
    Dec 23, 2015 at 15:12
  • And regarding hibernation please ask a new question and link that question in the comments here, I shall try to answer that for you.
    – Raphael
    Dec 23, 2015 at 15:13
5

Type in terminal:

gnome-disks 

Then select the swap partition. In the settings menu select "Edit mount" option.

0

I found a quick way that is:

  1. Go to Disk from App list
  2. Select swap Location
  3. Click on the setting
  4. Edit mount option
  5. Tick at mount at Startup

below image links are for hint

select swap

click on setting

edit mount option check on mount at start

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.