LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 554|回复: 4

交换空间的问题,很奇怪

[复制链接]
发表于 2004-9-9 09:58:48 | 显示全部楼层 |阅读模式
我系统用的是REDHAT AS3,在安装系统时候划分了2G的交换分区,但用df命令和free命令看到的结果却不一样
  1. [FONT=courier new]df -h
  2. Filesystem            Size  Used Avail Use% Mounted on  
  3. /dev/hda1             9.7G  1.9G  7.3G  21% /  
  4. [b][i]none                  503M     0  503M   0% /dev/shm[/i][/b]  
  5. /dev/hda3             9.7G  2.0G  7.2G  22% /usr  
  6. /dev/hda2              53G  9.4G   41G  19% /opt[/font]
复制代码


这个时候看显示的交换分区仅503M

  1. [FONT=courier new]free
  2.             total       used       free     shared    buffers     cached  
  3. Mem:       1029060     976732      52328          0      18232     586144  
  4. -/+ buffers/cache:     372356     656704  
  5. [i][b]Swap:      2096440     275948    1820492[/b][/i]
  6. [/font]
复制代码

这个命令显示的却是2G

  1. [FONT=courier new]fdisk -l /dev/hda   
  2. Disk /dev/hda: 80.0 GB, 80000000000 bytes  255 heads, 63 sectors/track, 9726 cylinders  
  3. Units = cylinders of 16065 * 512 = 8225280 bytes      
  4. Device Boot    Start       End    Blocks   Id  System  
  5. /dev/hda1   *         1      1275  10241406   83  Linux  
  6. /dev/hda2          1276      8189  55536705   83  Linux  
  7. /dev/hda3          8190      9464  10241437+  83  Linux  
  8. /dev/hda4          9465      9726   2104515    f  Win95 Ext'd (LBA)  
  9. [b][i]/dev/hda5          9465      9725   2096451   82  Linux swap[/i][/b][/font]
复制代码

这个时候显示的也是2G

为什么用不同的命令显示的结果却不一样
发表于 2004-9-9 11:44:59 | 显示全部楼层
/dev/shm和swap完全不是一回事啊
一般默认的/dev/shm是tmpfs,它只是一个“虚拟磁盘”,这个空间是动态变化的,他可能使用ram,也可能使用swap,这个对于tmpfs来讲是透明的。
 楼主| 发表于 2004-9-9 17:00:24 | 显示全部楼层
tmpfs是用来做什么的呢
发表于 2004-9-9 18:47:10 | 显示全部楼层
Tmpfs is a file system which keeps all files in virtual memory.


Everything is temporary in the sense that no files will be created on
your hard drive. If you reboot, everything in tmpfs will be lost.

In contrast to RAM disks, which get allocated a fixed amount of
physical RAM, tmpfs grows and shrinks to accommodate the files it
contains and is able to swap unneeded pages out to swap space.

Since tmpfs lives completely in the page cache and on swap, all in
memory tmpfs pages will show up as cached. It will not show up as
shared or something like that.
 楼主| 发表于 2004-9-11 23:50:50 | 显示全部楼层
能说明一下交换分区和tmpfs之间的联系吗
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表