linux tmpfs 百思不解的现象

来源:百度知道 编辑:UC知道 时间:2024/05/21 16:36:35
系统 ubuntu 9.04 桌面版, 内核2.6.28.15, 内存 1g 可用7百多
操作过程及现象
1.挂载450m容量的tmpfs到/home/xx/tfs
2.进入tfs目录显示可用450m,这时查看可用内存和交换空间都没什么变化。3.从windows分区复制420m的文件到tfs目录,这时tfs目录的可用空间为30m,但是可用内存和交换空间却还是没什么变化。连ubuntu系统盘空间都没变化。
问题:
tmpfs不是占用内存 或/和 交换分区的么?怎么容量一点都不变。新建的时候可能不怎么占空间,但是拷了这么多数据进去怎么还不占空间?小弟接触linux不久,忘各位帮忙解惑,谢谢!
二楼也非常感谢!我这样弄是想把经常读写的文件放到内存中以提高读写速率和减小磁盘读写概率。三楼的内存好大呀,读写速率也比我快多了,空了这么多真浪费,可以把系统都装进内存了。

不知道你是怎么看的。
tmpfs 是由内核管理的,某些用户层的内存查看软件不会对他的使用反应出来。
我的机器上:

localhost ~ # free
total used free shared buffers cached
Mem: 4061116 1576436 2484680 0 124816 417816
-/+ buffers/cache: 1033804 3027312
Swap: 0 0 0
localhost ~ # mount -t tmpfs tmpfs temp/
localhost ~ # cd temp/
localhost temp # dd if=/dev/zero of=temp bs=1M count=512
512+0 records in
512+0 records out
536870912 bytes (537 MB) copied,0.869186 秒,618 MB/秒
localhost temp # free
total used free shared buffers cached
Mem: 4061116 2127856 1933260 0 124856 942488
-/+ buffers/cache: 1060512 3000604
Swap: 0 0 0
localhost temp # ls
temp
localhost temp # rm temp
localhost temp # free
total used f