Showing posts with label swap. Show all posts
Showing posts with label swap. Show all posts

Tuesday 16 January 2018

How to Flush Memory Cache and Buffer Cache on Linux Server

When you run the "free -m" command and get the below output, then you observe free memory section will be low value but comparatively buffers+cache value would be higher.

Now this is not a bad thing actually since your OS has reserved this memory to speed up your most used process by keeping them in the cache. But in case any new process is executed and your system is low on memory then these cache would be automatically released to make space for memory reservation of new processes.

[root@localhost]# free -m
             total       used       free     shared    buffers     cached
Mem:          2345       1234        1145          0         24        400
-/+ buffers/cache:        664        345
Swap:         4032          0       4032

if you want to clear or free cache/buffer memory then you need to run the below command.

[root@localhost]# echo 3 > /proc/sys/vm/drop_caches

These are the different values which you can use with the above command

echo 1 is clearing only page cache

[root@localhost]# echo 1 > /proc/sys/vm/drop_caches

echo 2 is to clear free dentries and inodes

[root@localhost]# echo 2 > /proc/sys/vm/drop_caches

echo 3 is clearing page cache, dentries and inodes

[root@localhost]# echo 3 > /proc/sys/vm/drop_caches

Thursday 18 May 2017

How to Increase a Swap Space on Solaris Server

Swap memory work as a virtual memory in Unix operating systems. In Unix server when your physical memory used fully, that time swap memory are used and its maintain the system performance.

On Solaris server, if your swap size space use full then you need to create a new swap file or increase the swap space. We have a different method to increase/create a swap size on Solaris operating system server.

Here, we will discuss how to increase a swap size on Sun Solaris 11 operating system. The same steps are used for Sun Solaris 10 operating system.

In my testing machine, we are using storage space to create a new swap file as my operating system pool space are already fully utilized. 

Step by Step Method to Increase a Swap Space:

➤ On your Solaris machine , first you check the current swap space. Please use the below command to check the current running swap size.

!-[solaris]# swap -l
swapfile                               dev        swaplo   blocks       free
/dev/zvol/dsk/san/swap1     202,1        16         731596    6730226

In above example, "swap -l" command used to check the existing swap size space, you can use "top" command as well but using "top" command you can not find which swap named file are in used. You can find only total swap memory available on the Solaris server. On my solaris testing machine "swap1" file was already created which is currently in used.

➤ If you want to increase more size then you need to create a new swap file like swap2 or swap 3 as per your requirement and space available on server storage.

Let's assume on my Solaris server, I need to increase 30 GB more swap size, then you need to create new swap file.

Please use the below command to create a new swap file on Sun Solaris 11 operating system.

!-[solaris]# zfs create –V 30G san/swap2
!-[solaris]# swap –a /dev/zvol/dsk/san/swap2

In above command, we will create swap2 file with 30 GB space. Once you run both command one by one in given sequence a new swap 2 file with 30 GB has been created on the server.

➤ To verify the new swap size space, you need to run the below command.

!-[solaris]# swap -l
swapfile                               dev        swaplo   blocks       free
/dev/zvol/dsk/san/swap1     202,1        16         731596    6730226
/dev/zvol/dsk/san/swap2     209,2        16         832226    31457280

If you see the above output, the newly created swap file are seen with 30 GB space, and you can run the top command which show you the total swap memory space.

➤ To make it this swap space on Solaris server, please make an entry in "/etc/vfstab" file.

!-[solaris]# vi /etc/vfstab
/dev/zvol/dsk/san/swap1 -       -       swap    -       no      -

When we make this an entry in vfstab file, we don't need to take a reboot.  Once you take a reboot your space would be available and you can show it without any problem.

Please post your comment on this blog, if you have any query related to this topic.