Should I manually edit the /etc/fstab after creating a new swapfile or not?

I installed Manjaro and used the option swapfile, but it didn’t tell me how much it’s going to be the size. After the install I’ve checked it was around 512 mb in size. So, I wanted to increase the swap, following swapfile manjaro tutorial, it says I need firstly to turn off and delete the old swapfile Manjaro created and create a new one. So I did, however in the end it also says:

Add the following line to your /etc/fstab
/swapfile none swap defaults 0 0

I didn’t understand but it seems there is no need to change anything.

The default is:

/swapfile swap swap defaults,noatime 0 0

Do I really need to change something or it’s okay?

I have 16 GB of RAM and I don’t use hibernation, so according to manjaro swap tutorial I need at least 4 GB (I was think about using only 2 GB, tbh). I use many virtual machines at the same time, so ram is very used.

What’s better? To install Manjaro without any swap and after it’s installed manually create your swapfile (do I still need to edit /etc/fstab?) or install Manjaro with default swapfile and after that editing it?! I’m so confused.

As you can see, there is no difference in both cases, so there’s no need to edit.

If you really need to increase your swap capacity, then those 2 GiB won’t get you very far, and then 4 GiB would be the recommended minimum. However, I would personally advise 8 GiB if you’re going to be playing with virtual machines.

That all said, I don’t really understand why you’ve opted to use a swap file, rather than a dedicated swap partition, which is a lot easier to set up and also takes away some of the obstacles that come with swap files.

A swap partition doesn’t have any filesystem on it, because the kernel accesses the raw storage blocks directly. With a swap file, the kernel accesses the storage blocks directly as well, but it has to pass though the filesystem layer in order to locate the swap file, which itself resides on a filesystem. Furthermore, in order for the kernel to be able directly access those storage blocks, the filesystem may not apply any performance-enhancing tricks that it would apply to common other files, such as compression or (in the event of btrfs) copy-on-write.

The better way is to create a dedicated swap partition. But if you want to go with a swap file instead and you don’t understand the basics, then best is to let the installer take care of it.

But for the record, I believe that the installer does allow you to set another size than 512 MiB, although I could be wrong about that ─ it has been ages since I installed Manjaro on this machine, because I’ve been seamlessly updating/upgrading the system ever since. :man_shrugging:

1 Like

I thought it was needed to change something… Good to know in this case I don’t need.

I won’t use hibernation, but yeah, Manjaro recommends at least the bare minimum 4 GB of RAM. I’ve chosen swapfile because it’s more easy to manage and remove, modify, disable if I want to do while using swap on partition, it’s more complicated to change the size or remove totally the swap without affecting other partitions. Using swapfile seems more comfortable and flexible. About performance, for what I’ve seen there is no much difference between the two, especially on newest SSDs, even the order of partitions doesn’t matter anymore. I’m using EXT4.

I’ve already explained why I decided to use swapfile instead of swap partition.
The automatic partition doesn’t let you choose the swapfile size, only for partition, it created for me 512 MB (not sure if it does for all ppl).