Search This Blog

Monday 4 July 2016

Working with Memory in Unix

In Unix, files are arranged in file hierarchy, this hierarchy called file system. Files in different devices or on same devices can be mounted to one hierarchy so that all these files can be accessed as single file system. Each mount point can be assigned a space limit. The mount points, space usage and available space on each mount point can be listed using following command.
DF -H (all small letters)

When mount point reached max space limited then processes writing to that mount point will start failing as space is not available for that mount point even though lots of space available in disk.

In this scenario we have two options,
         1)  Either increase space limit for mount point (If more space available in disk)
         2) Purge some files to release space
 
The command that can be used to increase the logical extents for the mount point is lvextend .
The following article explains how to increase space limit on mount point
In terms of releasing the space.. it will be as easy as using “rm -rf”

But if do not want to delete existing folder structure and delete only the old or big files, we need to do following
          1) Identify the folder which occupied more space
          2)   Delete older and larger files

To identify the folders that occupied more space in a mount point, we can use following command
DU -H –MAX-DEPTH=1 (all small letters)

To delete files bases on size and time, use find as below
FIND /TMP/VAR -TYPE F -MTIME +15 -SIZE +2M -EXEC RM -RF {} \; (all small letters)


If we want to check the RAM size and memory usage in linux system, we could use either of following commands

view /proc/meminfo file

or use "free" command

or use vmstat for memory statistics. 



No comments:

Post a Comment