Disable Virtual memory
Delete swap file
You just installed your brand new Haiku operating system, and you are ready to roll with it and enjoy its features, snappiness, slickness, coolness, and even are willing to go to Lake Ness to celebrate. Then you realize that your computer has a solid state drive, and you have enough physical RAM so you check in your Haiku Preferences for Virtual Memory and…
There it is, your virtual memory swap file.
Upon installation, Haiku defaults to enable virtual memory, and automatically manage the swap file. There are many reasons why any user would like to have a Virtual Memory Swap file, and as many as why any user wouldn’t like to have such amount of disk space locked, reserved to be used as Swap.
Launching the DiskUsage application, we can see that in our case, with 8 GB of RAM, Haiku wants an 8.14 GB of Swap, and at this moment it has reserved 4.85 GB of disk space as Swap file. That swap file is hanging there in our hard drive, and with a small drive like the one we are using here (20 GB), reserving 4.85 GB of space is way too much wasted space. So we decide to deactivate Virtual Memory and regain that disk space for applications and documents.
1: Disable Virtual Memory
In Haiku, the disk icons show the used/free space ratio by an overlayed bar at the right side of the icon, which at the moment shows that about one third of the disk capacity is used already. With a clean install of Haiku R1/beta2 on a 20 GB disk, seems too much space taken. A great amount is due to the swap file as we will see in a moment.
Once disabling the Virtual Memory we need to reboot our system in order for the changes to take effect. Then, upon reboot:
2: Delete swap file
After reboot Virtual Memory has been disabled, but the space is still there, taken by the swap file. The swap file is still taking up space on our hard drive, though not being used. Now we can safely delete the swap file from our drive, as is not being used, thus it won’t cause any trouble to our system.
When we try to move the Swap file to the trash, Haiku will complain it won’t be able to boot. We are sure we want to do this because we know what we are doing, so we press Shift key and click on the Move button, which will be available when whe press the shift key. Then we just need to empty the trash:
Once the Trash has been emptied, our hard drive has gained space, the space before taken by the swap file. Now our 20 GB hard drive has 19.38 GB free for installing applications and documents.
3: Check the Filesystem
After the delete is complete, and in order to be safe, we should check the filesystem on our hard drive, to verify that everything is correct and no errors will appear upon next boot. To do this we launch the Terminal application and execute the command:
~> checkfs /Haikuverse
where Haikuverse is the name of the disk where the swap file was located:
Now our system is clean and without a swap file. We regained the space taken by the virtual memory to install new software and save our documents.
We could enable the Virtual Memory anytime, if we need it, and disable it again following the procedure stated here in case we don’t need it or we don’t want to use Virtual Memory.
Actually, we could just disable virtual memory and do nothing with the Swap file, just let it be there holding on to our disk, or we could resize it to take less space or whatever to suit our particular needs. Anything is possible. 😉