![]() If the value is closer to 0, it means the kernel will not swap the data to the hard disk unless it is required. The swappiness parameter, a value between 0 and 100 represents the percentage, configures how frequently your system swaps the data out of the RAM to the swap space. $ sudo echo ‘/swapfile none swap sw 0 0’| sudo tee -a /etc/fstab Now edit the swap file at the end of this file by entering the following command. We can change it by adding this swap file to /etc/fstab File.Įnter the following command to back up the /etc/fstab file. Now the swap file is enabled, but if you reboot then swap file is disabled unless you made it permanent. Successfully set up swap and our operating system will begin to use it if required. You can verify the output of free utility by entering the following command. We can enable the swap file by allowing the system to start utilizing it, after marking the file.Įnter the following command to verify swap is available or not. Now we can mark the file as swap space by entering the below command. ![]() Now you can see the root user has read and write flags enabled. To verify the permissions whether they are changed or not, use the following command. We can restrict other users from reading or editing the swap file by using the following command. !( Now the file is created with the required amount of space.īefore enabling the swap file, you need to change the settings so that no one can read the file except the root user. We can verify the amount of space reserved by the following command. This command generates a file with a specified size.įor example, a server has 1G of RAM, we will create a 1G file in this guide. The swap file can be created by using fallocate programme. This can be done using the following method. This file must be allocated the amount of space that you wish to. You must create a file, swapfile, in your root directory. Now, as you know the amount of available space in your hard disk, you can create a swap file within your file system. Now, it is recommended to have either 8GB or 16GB of swap space. But, it is recommended to have the size of your swap space equal to or double the space of RAM on your system.įor example, your system has 8 GB of RAM. The appropriate size of your swap space depends on the requirement of your applications and your personal choice. It means we have an adequate amount of space to work with, however, your actual usage might be different. Now, you can see the first line in the above table that the hard disk partition has 1GB of available memory. You can use the below command to know that. # Check the Hard Disk for Available SpaceĪlso, check your hard disk for the current disk usage. We can know the swap usage and current memory by using the below command. If you get the header of the table, as shown above, it means you do not have any swap space in your system.Īnd, another way to check space is by using the free utility, which shows the memory usage of your system. ![]() You can check it by using the following command. Make sure to check whether your system has swap space already or not. And, the operating system will use swap space to store the older data.Īdding a swap space to your applications is the best and easiest way to increase the responsiveness of your server and protect against memory errors in the applications. The information in the Swap space is comparatively slower than the information in the RAM. And, this space will only be used when the memory space in RAM is not sufficient for data. Swap space gives your server the ability to store more amount of data in its working memory but with a few cautions. But, the swap space can also be a swap file or a combination of swap partitions and swap files. It is always recommended to have a dedicated swap partition for the swap space. When the RAM is full, the system needs more memory resources, all the inactive pages in the memory will be moved to Swap space. Swap space is used when your machine’s physical memory (RAM is full. Swap is the area on a hard disk and a part of Virtual Memory, a combination of RAM and Swap space, of your computer. In this guide, I will explain to you how to add swap space on Ubuntu 18.04. – (#check-the-hard-disk-for-available-space ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |