Linux tmpfs 文件系统(基础概念)

个人博客首页(点击查看 详情) -- https://blog.51cto.com/11495268
个人微信公众号(点击查看详情) -- https://blog.51cto.com/11495268/2401194

    

1、简介
    ceph bluestore 挂载的 就是 tmpfs 文件系统,所以 学习 下 tmpfs 文件系统;本文 描述 tmpfs 文件系统 基础概念
 

2、tmpfs 基础知识
2.1 tmpfs 介绍
    tmpfs(temporary filesystem)是Linux特有的文件系统

  • 标准挂载点是/dev/shm(也可以自定义)
  • 默认大小是实际内存的一半
  • tmpfs是一个独立的文件系统,不是块设备,只要挂载,就可以立即使用
         

# free -h
              total        used        free      shared  buff/cache   available
Mem:            31G        8.5G         22G         33M        654M         22G
Swap:           15G        4.0M         15G

# df -h 
Filesystem                   Size  Used Avail Use% Mounted on
tmpfs                         16G   24K   16G   1% /var/lib/ceph/osd/ceph-4
tmpfs                         16G   24K   16G   1% /var/lib/ceph/osd/ceph-2
tmpfs                         16G   24K   16G   1% /var/lib/ceph/osd/ceph-0
... ...

    

2.2 tmpfs 特点
    临时性:由于tmpfs是构建在内存中的,存放在 tmpfs 中的所有数据在卸载或断电后都会丢失
    快速读写能力:内存的访问速度要远快于磁盘I/O操作,即使使用了swap,性能仍然非常卓越
    动态收缩:tmpfs一开始使用很小的空间,但随着文件的复制和创建,tmpfs文件系统会分配更多的内存,并按照需求动态地增加文件系统的空间;而且 tmpfs中的文件被删除时,tmpfs文件系统会动态地减小文件并释放内存资源
    

3、tmpfs 挂载
3.1 挂载
3.1.1 直接 挂载

# mount -t tmpfs -o size={size} tmpfs {mount_point}

    

3.1.2 重新 挂载

# mount -t tmpfs -o remount tmpfs {mount_point}

    

3.2 开机 自启

# cat /etc/fstab
# /etc/fstab: static file system information.
    
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).

# <file system> <mount point>   <type>  <options>       <dump>  <pass>
#  /was on /dev/sda3 during installation
tmpfs                   /tmp    tmpfs   defaults,size=25M        0 0

猜你喜欢

转载自blog.51cto.com/11495268/2424414