UNIX‎ > ‎

Know about Memory

A normal Middleware Admin is going to work on the machines that have huge size of memory capabilities. Cause is simple, to run the millions of users load on to the Middleware machines must be capable to handle those requests with adequate memory.  As our computer basics tells us about there will be two basic types of memories are available in every computer machine:
* Primary memory
* Secondary memory
Primary memory can be used for starting from installation to application up and running. This is also known as RAM in our machine, this primary memory is available per machine with variety of speeds and it depends on number of slots available on it. As an Admin you must know how much physical memory and how much virtual memory on your system have?

On SunOS you can get the information about RAM by prtconf command.

$ prtconf|grep Mem

Memory size: 32760 Megabytes
To find how much free Memory available on a Solaris machine use sar or vmstat commands

sar -r 5 10

or else you can use vamstat you will be finding here each and every detail with time interval will be displayed.

$ vmstat 5

procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------

r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st

0  0    476 1153928 490548 1996108    0    0     0    19    2    2  0  1 98  1  0

Know about virtual memory components 
The most important attributes here are process, memory, swap space, of vmstat are RSS, 

On Linux RAM Size

In Oracle Enterprise Linux 5  to know about RAM stats we have many options but easy option is using free command.

$ free –m

      total       used       free     shared    buffers     cached

Mem:   3949       2822       1126          0        479       1949

-/+ buffers/cache:        393       3555

Swap:         4095          0       4095

Another thing is you can also use ‘top’ in linux to show the memory and swap statistics

Check the disk space 

Now let us see secondary memory that is disk . The quick way to get a summary of the available and used disk space on your UNIX system is to using the 'df' command in a terminal window. The command df stands for "disk filesystem". Wise way to use the -h option (df -h) it shows the disk space in "human readable" form, which in this case means, it gives you the units such as M= MB, G=GB along with the numbers. 

Type df -h or df -k to list free disk space:
$ df –k

$ df -h

Filesystem             Size   Used  Avail Use% Mounted on

/dev/sdb1               20G   9.2G   9.6G  49% /

varrun                 393M   144k   393M   1% /var/run

varlock                393M      0   393M   0% /var/lock

procbususb             393M   123k   393M   1% /proc/bus/usb

udev                   393M   123k   393M   1% /dev

devshm                 393M      0   393M   0% /dev/shm

lrm                    393M    35M   359M   9% /lib/modules/2.6.20-15-generic/volatile

/dev/sdb5               29G   5.4G    22G  20% /media/docs

Troubleshoot disk space issue

Case 1: Requirement of Resize mount partition

This was the issue when we were working on Oracle DB installation.time the /var and /tmp spaces came to 100% used. There was need of increase these mount points. To provide the solution for this disk space issue on Oracle Enterprise LInux need to follow these steps:

  1. Check the sum of Physical Volume sizes ( 
  2. Check the Logical Volume sizes
Determine the how much free space availabe (pv - lv), that will tells you left over space. It is available then you can go for resize the logical volumes.

# pvdisplay

  --- Physical volume ---

  PV Name               /dev/hda2

  VG Name               rootvg

  PV Size               19.89 GB / not usable 19.49 MB

  Allocatable           yes (but full)

  PE Size (KByte)       32768

  Total PE              636

  Free PE               0

  Allocated PE          636

  PV UUID               cDlGpW-xDaf-knMJ-aOkH-FWZ9-M1Es-LQNRCG

  --- Physical volume ---

  PV Name               /dev/hda3

  VG Name               rootvg

  PV Size               11.00 GB / not usable 334.00 KB

  Allocatable           yes

  PE Size (KByte)       32768

  Total PE              352

  Free PE               14

  Allocated PE          338

  PV UUID               18C1aR-hcCL-JLsh-P0GD-914q-SIUi-MVgmMC

or you can grep the PV Size:

# pvdisplay |grep "PV Size"
  PV Size               19.89 GB / not usable 19.49 MB
  PV Size               11.00 GB / not usable 334.00 KB

Similarly, You can find the Logical volume sizes 

# lvdisplay |grep "LV Size"
  LV Size                5.00 GB
  LV Size                4.00 GB
  LV Size                3.00 GB
  LV Size                256.00 MB
  LV Size                192.00 MB
  LV Size                3.00 GB
  LV Size                3.00 GB
  LV Size                2.00 GB
  LV Size                10.00 GB

In my VM boxes PV Size = LV Size no chance of resizing. If there is no free space availability then look for the removal of useless logs files that keep on updating in /var/log directory: where you can remove the all files with *.1, *.2 etc.

Case 2: Another important disk related command is 'du'  stands for "disk usage". The du command shows the disk space used by the files and directories in the current directory. Again the -h option (du -h) makes the output easier to comprehend. 

 $ du -h | sort -n| more 

To display large amounts of disk space using file/directory will be on top. This will make administrators life easy

$ du -ah | grep M       

du -c will gives you Grand total count

Total Disk space

To know about total disk space in UNIX there is no direct command available. So we need to use a pattern matching field extraction and sum up using AWK trick.

$ df -lk | egrep -v "Filesystem|/proc|/dev/fd|swap|/home|/platform" | awk ' \  
 { t += $2 } \ 
 { u += $3 } \ 
 {GB2 = 1024*1024} END \ 
 { printf "%d of %d Gb in use.\n", u/GB2, t/GB2 }'

Good References