Score:0

How to modify fstab to automatically load my swap file?

mc flag

I have an 8GB swap file under /swapfile1 and I have to load it manually in the terminal every time I log in. I tried to modify fstab following the advice given in this thread Adding a new swap file. How to edit fstab to enable swap after reboot? with no success. What do I need to add to fstab to make this work?

Here is my existing fstab file:

# /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>
/dev/mapper/nvme0n1p6_crypt /               ext4    errors=remount-ro 0       1
# /boot was on /dev/nvme0n1p5 during installation
UUID=0caeaa04-232f-4181-87a6-cab787ef6d0c /boot           ext4    defaults        0       2
# /boot/efi was on /dev/nvme0n1p1 during installation
UUID=666E-4F0F  /boot/efi       vfat    umask=0077      0       1
Zeiss Ikon avatar
cn flag
Please paste in your existing `fstab` so we can see where you're starting. [Edit] the question above to include the text of the file. And welcome to AskUbuntu! Please be sure to take the [tour] and read through the [FAQ].
Zeiss Ikon avatar
cn flag
Is your `/swapfile1` located inside the `nvme0n1p6_crypt` volume?
osilverstone96 avatar
mc flag
Yes it is, the encrypted partition is mounted as / and partition 5 is mounted as /boot
Score:1
mx flag

You should add something like:

/swapfile1  none  swap  sw   0  0

to /etc/fstab.

Zeiss Ikon avatar
cn flag
Asker claimed to have tried this (it was the basis of the answer linked in the question), but it doesn't show in the pasted `fstab`.
osilverstone96 avatar
mc flag
Yes this works, I tried something similar from the thread that I mentioned but I think there were too many spaces. Thanks
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.