1

I tried running sudo nano /etc/fstab/ but such a file did not exist. So nano displays the following error:

[ Error reading lock file /etc/.fstab.swp: Not enough data read ]

Some other background info about my setup, I had a swap parition defined during the OS installation but due to space constaints on my main partition I deleted it, and consumed the space.

Afterwards I added a second drive to my system and I'm trying to use one of its partitions as the swap. This is possible with GParted using the swapon command but it needs to be done after every reboot.

Is there a way to permanently set the new partition as my swap?

1

As lemonslice said, you need to edit /etc/fstab and not /etc/fstab/. You can use GParted to find your UUID (right click > informations).


Then just add a ligne to fstab like this UUID=YOUR_UUID none swap sw 0 0. I made you a screenshot to show you my configuration :

http://nsa38.casimages.com/img/2016/12/12/161212052324528993.png

  • Thanks, I shall report back in an hour or two. (My workspace is cluttered atm). Is there a command to quickly check the current swap in elementary? – john Dec 12 '16 at 16:10
  • 3
    You can use cat /proc/swaps or swapon -s to find devices used for swap and cat /proc/meminfo or free show you memory use. – Shining Dec 12 '16 at 16:15
4

You can check the UUID of your (new) swap space:

user@host:~$ lsblk -f -o NAME,FSTYPE,UUID | grep swap
├─sda3 swap   ce70123c-6341-4802-9b96-29c39fb4110b

You should edit sudo nano /etc/fstab (without the trailing slash) and add the line (make sure you use your UUID):

UUID=ce70123c-6341-4802-9b96-29c39fb4110b none            swap    sw              0       0
  • The trailing slash seems to make no difference, I'm getting the same error on nano. – john Dec 12 '16 at 16:05
  • Edit: I ignored the error and saved the file (as new), I shall report back if it worked. – john Dec 12 '16 at 16:08
  • If there is a fstab in another place, you can find it with whereis fstab – Shining Dec 12 '16 at 16:10
  • for your system to work you should have fstab in /etc/, this file cannot be in another directory – lemonslice Dec 12 '16 at 18:24
  • @lemonslice you're right it was there, wonder why nano was acting up... Anyways issue is sorted, thanks! – john Dec 12 '16 at 19:00
1

Run the following command to get the UUID of your swap partition:

ls -l /dev/disk/by-uuid

Edit your /etc/fstab and change the uuid

# swap was on /dev/sdax during installation
UUID=put_the uuid_here none            swap    sw              0       0

Assign the new uuid ( change sdax with yours)

swapoff /dev/sdax
mkswap -U put_the_uuid_here /dev/sdax
swapon -a

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.