399€

Become a Reseller

APPBUILDER

Reseller whit platform

Siberian&Nwicode

Change Swap Size in Ubuntu

In the case of Linux, the swap file is an important part. It’s not a must-have option but having one is crucial for a number of purposes. Generally, when installing the system, you have to declare the size of the swap file. The recommended size is 4GB but you can either decrease or increase it depending on your demand. Today, let’s have a look at changing the swap size in Ubuntu.

Note – Running all these commands require root privilege, so I recommend running a “root” terminal.

root@sv0:~# sudo -s

Finding out available swap file(s)

Before we get to change the swap, let’s find out how much swap size we have.

root@sv0:~# swapon -s

According to the result, the system has a swap file at “/swapfile”.

For manipulating the swap file, we have to disable it first.

root@sv0:~# swapon -a

Now, change the size of the swap file

root@sv0:~# dd if=/dev/zero of=/swapfile bs=1M count=4096

Here, the total size of the swap file will be bs*count = 1M x 4096 = 4GB

Make the “/swapfile” usable again –

root@sv0:~# mkswap /swapfil

Turn on the swapfile –

root@sv0:~# swapon /swapfile

After restarting your system, check out the result –

root@sv0:~# swapon -s

 

Deleting the swap file

If your RAM space is high enough, then you probably want to get rid of the swap file. If that’s your case, then let’s get rid of the swap file!

Don’t worry! I’ll also show you how to set a completely fresh swap file.

For deleting the swap file, run the following commands –

root@sv0:~# swapoff -v /swapfile

Remove the swap file entry from “/etc/fstab” file. It should be the last line of the file.

root@sv0:~# gedit /etc/fstab

Now, time to remove the actual swap file.

Leave a Reply

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

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Appteam to offer you a better experience on this site uses its own and third-party technical, analytical and profiling cookies. The site also uses third-party tracking cookies to adapt advertising to your preferences.

If you want to know more or refuse consent to the use of cookies click here. By continuing to browse, you consent to the use of cookies.

Privacy Settings saved!
GDPR Center

When you visit a website, it can store or retrieve information on your browser, mainly in the form of cookies. Check your personal cookie services here.

These cookies are necessary for the website to function and cannot be disabled in our systems.

In order to use this website we use the following technically required cookies
  • wordpress_logged_in_
  • wordpress_sec
  • wordpress_test_cookie

We use WooCommerce as a purchasing system. 2 cookies will be stored for the shopping cart and order processing. These cookies are strictly necessary and cannot be disabled.
  • woocommerce_cart_hash
  • woocommerce_items_in_cart

  • wordpress_test_cookie
  • wordpress_logged_in_
  • wordpress_sec

Decline all Services
Accept all Services

Main Menu