How to register a global hotkey for your application in C#

How to register a global hotkey for your application in C#

Register a hotkey for your application that can be triggered even if your form is minimized and does not have focus. More »

How to download a file in C# (progressbar and download speed)

How to download a file in C# (progressbar and download speed)

Learn how to download files in C# while displaying the percentage and the download speed. More »

UDP hole punching implementation in C#

UDP hole punching implementation in C#

Learn how to implement UDP hole punching so you can make your clients life a lot easier by not forcing them to open ports on their end. More »

 

How to create a swap file on Ubuntu

Swap is particularly useful in situations where physical memory is limited, especially when dealing with low memory VPS/systems. This does not mean that swap is useless in all the other situations. Any system with close to 100% RAM utilization without swap enabled will cause application crashes or even worse, a system crash.

Moreover, some applications, in rare cases, require swap to be enabled regardless of memory capacity/usage, otherwise they simply crash.

To enable swap on Ubuntu follow the steps below (requires administration rights):

Create an empty file called “swapfile” using fallocate:

Feel free to change the “2G” value if you believe you require more or less swap space.

Change the permissions of the swap file to 600 in order to make it accessible only for the root user:

Mark the “swapfile” as swap space:

Enable the swap file:

Note: It is extremely important to note that any changes we have made so far are temporary and will be removed when we reboot the machine.

In order to make our changes permanent we will need to update the fstab file located at /etc/fstab. You can do so by editing the file and adding the following line inside:

Or simply by using this command do insert the line for you in the file:

We put together a one line command using the instructions above. It comes in handy when deploying new machines and we want to speed up the process. Feel free to use and modify it to suit your needs.

Share on FacebookTweet about this on TwitterShare on Google+Share on StumbleUponShare on LinkedInShare on RedditPin on PinterestShare on TumblrDigg thisPrint this pageEmail this to someone

Leave a Reply

Your email address will not be published. Required fields are marked *