Chinaunix首页 | 论坛 | 博客
  • 博客访问: 48809
  • 博文数量: 19
  • 博客积分: 1504
  • 博客等级: 上尉
  • 技术积分: 190
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-06 14:21
个人简介

系统运维

文章分类
文章存档

2013年(6)

2011年(2)

2009年(4)

2008年(7)

我的朋友

分类: LINUX

2008-10-18 23:49:07

What is /dev/shm and its practical usage ? (/dev/shm是什么?其大小怎么改呢?)
2008-07-21 16:01

You can see original text here.

/dev/shm is nothing but implementation of traditional shared memory concept. It is an efficient means of passing data between programs. One program will create a memory portion, which other processes (if permitted) can access. This will result into speeding up things on Linux.

shm / shmfs is also known as tmpfs, which is a common name for a temporary file storage facility on many Unix-like operating systems. It is intended to appear as a mounted file system, but one which uses virtual memory instead of a persistent storage device.

If you type mount command you will see /dev/shm as a tempfs file system. Therefore, it is a file system, which keeps all files in virtual memory. Everything in tmpfs is temporary in the sense that no files will be created on your hard drive. If you unmount a tmpfs instance, everything stored therein is lost. By default almost all Linux distros configured to use /dev/shm.

Nevertheless, where can I use /dev/shm?

You can use /dev/shm to improve the performance of application software or overall Linux system performance. 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).

For example, if you have 8GB RAM then remount /dev/shm as follows:
# mount -o remount,size=8G /dev/shm
To be frank, if you have more than 2GB RAM + multiple Virtual machines, this hack always improves performance.

# mount -t tmpfs -o size=5G,nr_inodes=5k,mode=700 tmpfs /disk2/tmpfs
Above will give you tmpfs instance on /disk2/tmpfs which can allocate 5GB RAM/SWAP in 5K inodes and it is only accessible by root.

/dev/shm 是linux的共享内存。默认情况下是真实内存的一半。翻译成共享内存也许不是很适合,请看后面的英文解释。

更改其大小有两种方法:(512可被改为任何你想改成的数)
1、unmount /dev/shm
    mount -t tmpfs -o size=512 none /dev/shm
重新加载一个临时文件系统给共享内存。但每次启动linux都要这样做,很烦!!

2、修改linux 启动时文件系统加载配置文件/etc/fstab,把其中的一行改成下面就可以了。保存。
以后就不会每次都探出这个消息

tmpfs   /dev/shm   tmpfs   defaults,size=512M 0 0

阅读(618) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:Net::Telnet::Cisco修改CISCO交换机密码-原创

给主人留下些什么吧!~~