Hello again,
When installing Manjaro XFCE I chose to create a swap file. That was an option over a partition. I’m now asking whether this is enough for my notebook or what I should do better next time or just now?
swapon
NAME TYPE SIZE USED PRIO
/swapfile file 512M 0B -2
OK, I see it’s 16 GiB. Thanks for posting the info.
A SWAP partition of at least 16GiB (and a bit more, if possible), will be sufficient to allow for hibernation, and most other needs.
If you plan on adding more RAM in the the near future, you might also want to allow for that as well.
I notice you’re using zswap as suggested by @cscs in another thread. I only mention this in case it’s relevant to others reading along.
To switch to using an adequately sized SWAP partition would require resizing the root (/) partition to create the extra space needed. This can (potentially) be a cumbersome task, sometimes with unexpected difficulties.
Although this would ultimately be more performant, the easiest for you is probably to reconfigure the size of the swap file using zswap. Were you given any reference information for that?
Thank you!
I did read here but I didn´t understand all: swap.
Should I reinstall Manjaro to create a 16GB swap partition? Or is that not absolutely necessary? I don’t actually have any programs running in standby mode, I don’t think.
Yes, given the situation, a fresh install allowing a 16Gib (maybe 17Gib), would be the easiest for a performant swap partition.
Increasing the swap file would probably be easier still, but my opinion is a full swap partition will be better.
Ultimately it’s up to you.
Whether you use a swap partition or a swap file, it still must be able to accommodate whatever data is in RAM, if hibernation is desired at any time.
Personally, I do not use swap files/ partitions on machines with modern ssd/ nvmes. I have seen no problems. When I use swap is with older devices for speed boost.
While I agree in essence, your reasoning is flawed.
If one wishes to hibernate a system, whatever is in RAM must be written to disk – to the swap partition (or file). Therefore there must be sufficient swap space for that to occur.
The good thing of having a swap file instead of a swap partition is that you can always easily adapt it’s size to your needs.
@soundofthunder gave you step by step instructions to get to a larger one
But you don’t really need to do this unless you want to set up hibernation or are otherwise sure that your current 512 MB swap file is not big enough.
If I where you, I’d opt for a swap file as big as my RAM.
But with the size of solid state drives, that much swap seems like a waste of disk space.
I have got 8 GB of RAM, 4 GB of swap (file)
Swap rarely gets used with what I do and hibernation works just fine with this size
even though it is only half the recommended size.
Systems on nvme solid state drives are booting so fast that hibernation isn’t really needed.
I still have a rotating disk. Plenty of space (1TB) - but speed matters here and does make a difference.
The argument is sound, up to the point when you have 5-6 GB ISO file, or Video file being edited (or, whatever) that happens to be in RAM when you decide to hibernate the machine…
Oops!
I don’t hibernate, either. I have 64GiB RAM and a 32GiB swap partition, but I carefully calculated and anticipated my needs beforehand.
I’ll add this here for the OP to find, if he also has no desire to use hibernation, and wishes a smaller swap file:
And that’s the point.
I know. You know. But he doesn’t.
… and I did not intend to persuade him to do as I did
Apparently I never tried to hibernate with too much of my RAM being used so that it would fail.
I don’t know what would happen then - probably an fsck on the next reboot and perhaps some of the more recent changes lost due to it.
To be very honest - there is not that much (time) difference between coming out of hibernation and a clean boot - the reading back of 4 GB from swap takes it’s sweet time.
I appreciate you taking the time and effort to guide him to change what he has got now.
Very nice of you!
I already like this forum! You are really nice and knowledgeable helpers! I now have a 16 GB swap file using the instructions written especially for me! Many many thanks!
LC_ALL=C cat /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>
UUID=22F4-54A6 /boot/efi vfat umask=0077 0 2
UUID=d8ff5d2f-cd13-4534-b598-7ae3f9f4950e / ext4 defaults,noatime 0 1
/swapfile swap swap defaults,noatime 0 0
tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0
Yes, it’s OK to install a swap file but it feels old-school to me
I don’t understand why people don’t use zram instead, it’s more dynamic and costs less hdd space.
Install zram-generator using one of the methods listed above.
Create a zram-generator.conf config file.
Run systemctl daemon-reload to create new device units.
Run systemctl start /dev/zram0 (adjust the name as appropriate to match the config).
Call zramctl or swapon to confirm that the device has been created and is in use.
Once installed and configured, the generator will be invoked by systemd early at boot, there is no need to do anything else.
If you decide to use zram instead of a swap file & don’t want to have to fiddle around with a configuration file (as required with zram-generator), then a good alternative in the AUR is systemd-zram (and there are plenty of other zram enablers available in the AUR repository too). I recently installed systemd-zram with its default settings (lzo compression, cache size 75% of RAM size) & it works just as it should.
After I installed systemd-zram all I had to do was run (as root) systemctl enable --now systemd-zram to start it immediately and also have it run automatically at boot.