Need help with /dev/shm

Lisa Kachold lisakachold at obnosis.com
Sun Sep 9 13:25:43 MST 2012


Hi Mark,

On Sun, Sep 9, 2012 at 12:50 PM, Mark Phillips
<mark at phillipsmarketing.biz>wrote:

> I have been having some issues with an old server running a jsp
> applicaition (tomcat web server and java 1.5....I said it was old!). I
> looked at the partitions and found:
>
> Last login: Sun Sep 9 11:57:49 2012 from 192.168.25.150
> mark at gandalf:~$ df -h
> Filesystem Size Used Avail Use% Mounted on
> /dev/hda6 110G 61G 44G 58% /
> tmpfs 63M 0 63M 0% /dev/shm
> /dev/hda1 30M 7.3M 21M 27% /boot
> mark at gandalf:~$
>
> tmpfs or /dev/shm is at 0%. Usually, a zero anywhere is bad thing....;) so
> should I do something about this?
>
> This is 63M with 0 used above.

You can expand it for better performance, but I doubt that your utilization
issues are /dev/shm kernel intermessage processing related.  In a J2EE
system, it would be memory, garbage collection, or a kernel based known
memory error.

But if you are running Ultramonkey  or a databasae, you could use all of
/dev/shm during heavy network use, so you can easily expand /dev/shm (see
below).


Reference:
http://www.cyberciti.biz/tips/what-is-devshm-and-its-practical-usage.html


> I goolged /dev/shm and understand that it is a ram disk for interprocess
> communications. Wonderful. Should I be worried it is at 0% Should I
> increase the size? Running top shows these resources in the system"
>
> Tasks: 60 total, 1 running, 59 sleeping, 0 stopped, 0 zombie
> Cpu(s): 1.0% us, 0.3% sy, 0.0% ni, 98.4% id, 0.0% wa, 0.3% hi, 0.0% si
> Mem: 127152k total, 124740k used, 2412k free, 6896k buffers
> Swap: 489940k total, 0k used, 489940k free, 45500k cached
>
>
> If I should increase the size of /dev/shm, would I edit fstab and add this
> line
>
> none /dev/shm tmpfs defaults,size=8G 0 0
>
> and then
>
> mount -o remount /dev/shm
>
> You can use /dev/shm to improve the performance of application<http://www.cyberciti.biz/tips/what-is-devshm-and-its-practical-usage.html#>software such as Oracle or overall Linux system
performance<http://www.cyberciti.biz/tips/what-is-devshm-and-its-practical-usage.html#>.
On heavily loaded system, it can make tons of difference. For example
VMware workstation/server can be optimized to improve your Linux host's
performance (i.e. improve the performance of your virtual machines).

In this example, remount /dev/shm with 8G size as follows:
# mount -o remount,size=8G /dev/shm
To be frank, if you have more than 2GB RAM + multiple Virtual
machines<http://www.cyberciti.biz/tips/what-is-devshm-and-its-practical-usage.html#>,
this hack always improves performance. In this example, you will give you
tmpfs instance on /disk2/tmpfs which can allocate 5GB RAM/SWAP in 5K inodes
and it is only accessible by root:
# mount -t tmpfs -o size=5G,nr_inodes=5k,mode=700 tmpfs /disk2/tmpfs
Where,

   - *-o opt1,opt2 * : Pass various options with a -o flag followed by a
   comma separated string of options. In this examples, I used the following
   options:
      - *remount* : Attempt to remount an already-mounted filesystem. In
      this example, remount the system and increase its size.
      - *size=8G or size=5G* : Override default maximum size of the
      /dev/shm filesystem. he size is given in bytes, and rounded up to entire
      pages. The default is half of the memory. The size parameter
also accepts a
      suffix % to limit this tmpfs instance to that percentage of your pysical
      RAM: the default, when neither size nor nr_blocks is specified, is
      size=50%. In this example it is set to 8GiB or 5GiB. The tmpfs mount
      options for sizing ( size, nr_blocks, and nr_inodes) accept a suffix k, m
      or g for Ki, Mi, Gi (binary kilo, mega and giga) and can be changed on
      remount.
      - *nr_inodes=5k* : The maximum number of inodes for this instance.
      The default is half of the number of your physical RAM pages, or (on a
      machine with highmem) the number of lowmem RAM pages, whichever is the
      lower.
      - *mode=700* : Set initial permissions of the root directory.
      - *tmpfs* : Tmpfs is a file system which keeps all files in virtual
      memory.

*How do I restrict or modify size of /dev/shm permanently?*

You need to add or modify entry in /etc/fstab file so that system can read
it after the reboot. Edit, /etc/fstab as a root user, enter:
# vi /etc/fstab
Append or modify /dev/shm entry as follows to set size to 8G

none      /dev/shm        tmpfs   defaults,size=8G        0 0

Save and close the file. For the changes to take effect immediately remount
/dev/shm:
# mount -o remount /dev/shm

> Thanks,
>
>


> Mark
>
> P.S. The issues I am having with the application may have nothing to do
> with this situation...could be some bad programming....ie a bug.
>
> P.P.S. I am running Linux version 2.6.8-2-386 (
> horms at tabatha.lab.ultramonkey.org) (gcc version 3.3.5 (Debian
> 1:3.3.5-13)) (yes, I said it was old....) Consider it my contribution to
> keeping old hardware out of the dump!
>
>
>
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss at lists.plug.phoenix.az.us
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>



-- 
(503) 754-4452 Android
(623) 239-3392 Skype
(623) 688-3392 Google Voice
**
it-clowns.com
Chief Clown
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.PLUG.phoenix.az.us/pipermail/plug-discuss/attachments/20120909/c76cbf09/attachment.html>


More information about the PLUG-discuss mailing list