Home | News | Download | Packages | Forum | Wiki | Github

Without swap?


#1

Hi all…

Have just installed Void successfully on USB flash without swap (BIOS/GPT - 1M for GPT and the rest for the /) and after a (short) trial I intend to install it as my main and only OS on sda. Can I do it without swap as well? Asking because I’ve read that swap is required in the wiki?


(Userx) #2

I’ve been running without a swap drive for a long time now, after I noticed I was no longer using any (maybe because I upgraded to 16GB RAM) so I no longer use a swap drive at all for any of my installs of Linux.
BUT
if you ever find you need some swap space then you can just create it on the fly. it is called a swap file.
man 1 fallocate

sudo fallocate -l 512M /swapfile
or
sudo fallocate -l 1024M /swapfile1

sudo mkswap /swapfile
or
sudo mkswap /swapfile1
then
sudo swapon /swapfile

you can change the size of the file to whatever you want / need as well as the file name and put it anywhere on your system to use. then swap off, or reboot to turn it off, and you can delete it and make another one later on if you need to.

or keep it then slap it into fstab as a mount to swap?


#3

It really depends on your use case and how much RAM you have. If you want to use suspend-to-disk, you need swap. If you prefer having a system that is slow as hell over processes getting killed by the oom killer, you need swap. If both doesn’t apply, you could probably do without. Most distributions recommend putting a certain amount of disk space aside to use as swap but in my experience, most systems also run fine without it.


#4

Thanks a lot, chaps. And please excuse me for not being clear enough. I know all these, but I’ve never seen a distro wiki “requiring” a swap like Void does. That’s why I’ve asked about it. I’ll install it in the same way in sda then.

Thanks again.


(Anthony Eadicicco) #5

Where does the wiki say this? Void uses a vanilla Linux kernel. The requirements should not be anything beyond any other standard Linux kernel.

For what it’s worth, it’s usually a better idea to set aside some swap, then set the vm.swappiness sysctl to some low value such as 1 if you want to mimic the behavior of a swap-less system (don’t evacuate code for buffers, only use swap if absolutely necessary). Having some swap available can save you if you do end up in an OOM situation.


#6

A swap partition is also required, please refer to Disks#Swap for more information.

https://wiki.voidlinux.eu/Disks#Partitioning (At the end of the first paragraph.)

At least two partitions, one for the rootfs and another one for swap must be created.

https://wiki.voidlinux.eu/Installer_Partitioning

Thanks for the info, though generally the only mem hungry app I use is Qupzilla!


#7

You can do without swap just as I do. Only if you want its “features” do you need it and those are hibernation and out-of-memory handling only useful for gigantic processing tasks (video editing, scientific simulation). IMO swap is mostly a way to corrupt your disk and slow your system down. It’s a holdover from long-ago days of more severe resource constraints than we have now. Memory is cheap.

Use the kernel parameter “noswap” at boot time. You can type it in by hand at boot or modify your dracut boot files.


#8

Yes, because of ssd wear I don’t use it and haven’t needed eithe.


(Anthony Eadicicco) #9

That should probably read, instead

A swap partition is strongly encouraged.

For what it’s worth, unless you got a fairly cheap SSD, it probably has enough endurance to handle swap just fine and still outlast your computer.


#10

No. Swap is harmful in all cases (SSD and HDD) unless you really do need its specific utility namely (1) hibernation or (2) oom likelihood. Otherwise just forget it.