Swap turned off after reboot, but it works after turning on swap with this command

 sudo swapon /media/oleg/5C2C1D0A2C1CE0B6/swapfile


I have Ubuntu 18.04 installed on SSD. I have HDD with NTFS file system. I created swap file on NTFS partition not to put it on SSD.

/etc/fstab looks like:

UUID=26a50687-bfb3-4486-b822-9884130669de /               ext4    errors=remount-ro 0       1
# /boot/efi was on /dev/sda1 during installation
UUID=E055-53B9  /boot/efi       vfat    umask=0077      0       1

/media/oleg/5C2C1D0A2C1CE0B6/swapfile none swap sw 0 0

The computer has 8Gb, now it works ok without swap, but maybe it makes sense to add swap file just in case.

  • 3
    /media/oleg/5C2C1D0A2C1CE0B6 isn't configured in fstab, how do you normally mount that? You can not access and enable a swap file at boot with fstab if the file system on which it is located isn't mounted using fstab too. Also, swap files on NTFS are a relatively bad idea. See e.g. archlinuxarm.org/forum/viewtopic.php?t=5534 – Byte Commander Aug 16 '19 at 14:03
  • It's mounted automatically on every reboot. It's hdd, not external disk – Oleg Aug 16 '19 at 14:27
  • 2
    Yeah, but how? It must be configured in fstab, everything else happens later. Too late for the swap file. – Byte Commander Aug 16 '19 at 14:32
  • Could you please tell me how to configure it in fstab for ntfs partition? – Oleg Aug 16 '19 at 14:34
  • Thank you very much for your comments, I think I could make it work and I added answer. – Oleg Aug 16 '19 at 14:45

The problem was that the NTFS file system on which I placed my swap file was not configured to mount automatically in /etc/fstab, but it got only mounted automatically later somewhere.

I added this in /etc/fstab, it seems to work now:

/dev/sdb4 /media/oleg/5C2C1D0A2C1CE0B6 ntfs-3g rw,nosuid,nodev,allow_other,default_permissions,blksize=4096 0 0

And this line remains telling linux to use swap file after reboot. /media/oleg/5C2C1D0A2C1CE0B6/swapfile none swap sw 0 0

  • What?? I want a explanation of why it works... – zixuan Aug 16 '19 at 18:26
  • Can you see any issues with this solutions? It looks like it work. – Oleg Aug 19 '19 at 7:35

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.