linux文件系统学习,linux文件系统之tmpfs学习

关于文件系统,我们在下面的博文中已有做简单的介绍,外链网址已屏蔽

本篇博文我们学习的是文件系统中的tmpfs。

tmpfs是一种伪文件系统,它是从DRAM中创建出来的,

相比于磁盘而言,其具有更高的访问效率。

如何创建一个tmpfs?

第一步先配置/etc/fstab,新增加一栏tmpfs的配置,

sh-3.2# cat /etc/fstab

# /etc/fstab: static file system information.

#

#                              

/dev/root       /               auto    noauto,rw,errors=remount-rw     0 0

none            /proc           proc    defaults                0 0

none            /sys            sysfs   defaults                0 0

none            /dev/pts        devpts  noauto,gid=5,mode=620   0 0

none            /tmp            tmpfs   defaults                0 0

none            /opt            tmpfs   defaults                0 0

none            /dev/shm        tmpfs   noauto                  0 0

sh-3.2# mount

rootfs on / type rootfs (rw)

/dev/root on / type squashfs (ro,relatime)

none on /proc type proc (rw,relatime)

none on /sys type sysfs (rw,relatime)

none on /tmp type tmpfs (rw,relatime)

none on /opt type tmpfs (rw,relatime)

none on /proc/bus/usb type usbfs (rw,relatime)

/dev/mapper/dm-1 on /3rd type squashfs (ro,relatime)

ubi2:perm on /perm type ubifs (ro,relatime,bulk_read,no_chk_data_crc)

ubi1:3rd_rw on /3rd_rw type ubifs (rw,relatime,bulk_read,no_chk_data_crc)

第二步测试,为什么没看到新增加的tmpfs呢?

sh-3.2# cat /etc/fstab

# /etc/fstab: static file system information.

#

#                              

/dev/root       /               auto    noauto,rw,errors=remount-rw     0 0

none            /proc           proc    defaults                0 0

none            /sys            sysfs   defaults                0 0

none            /dev/pts        devpts  noauto,gid=5,mode=620   0 0

none            /tmp            tmpfs   defaults                0 0

none            /opt            tmpfs   defaults                0 0

none            /dev/shm        tmpfs   noauto                  0 0

none    /tmp_fs         tmpfs   defaults                0 0

sh-3.2# mount

rootfs on / type rootfs (rw)

/dev/root on / type squashfs (ro,relatime)

none on /proc type proc (rw,relatime)

none on /sys type sysfs (rw,relatime)

none on /tmp type tmpfs (rw,relatime)

none on /opt type tmpfs (rw,relatime)

none on /proc/bus/usb type usbfs (rw,relatime)

/dev/mapper/dm-1 on /3rd type squashfs (ro,relatime)

ubi2:perm on /perm type ubifs (ro,relatime,bulk_read,no_chk_data_crc)

/dev/sda1 on /tmp/mnt/usb/sda1 type vfat (rw,noatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=cp437,iocharset=utf8,shortname=mixed,errors=continue)

ubi1:3rd_rw on /3rd_rw type ubifs (rw,relatime,bulk_read,no_chk_data_crc)

通过检查系统启动时log发现,

mount: mount point /tmp_fs does not exist

原来是因为没有mount point,所以导致tmpfs没有挂载成功。

这个很容易理解,在mount一个文件系统之前必须指定一个目录,然后将文件系统挂载到这个目录下,

这个目录就是mount point。

接下来我们在创建一个/tmp_fs的文件夹作为这个tmpfs的mount point,再次测试,

可以看到我们期待的文件系统/tmp_fs已经出来了。

sh-3.2# mount

rootfs on / type rootfs (rw)

/dev/root on / type squashfs (ro,relatime)

none on /proc type proc (rw,relatime)

none on /sys type sysfs (rw,relatime)

none on /tmp type tmpfs (rw,relatime)

none on /opt type tmpfs (rw,relatime)

none on /tmp_fs type tmpfs (rw,relatime)

none on /proc/bus/usb type usbfs (rw,relatime)

/dev/mapper/dm-1 on /3rd type squashfs (ro,relatime)

ubi2:perm on /perm type ubifs (ro,relatime,bulk_read,no_chk_data_crc)

/dev/sda1 on /tmp/mnt/usb/sda1 type vfat (rw,noatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=cp437,iocharset=utf8,shortname=mixed,errors=continue)

ubi1:3rd_rw on /3rd_rw type ubifs (rw,relatime,bulk_read,no_chk_data_crc)

sh-3.2# touch /tmp_fs/test

sh-3.2#

sh-3.2# ls /tmp_fs

test

上面介绍的是静态配置文件系统的方法,我们也可以在系统启动后动态的创建一个tmpfs类型的文件系统。

只要找到一个mount point,然后向tmpfs挂载到这个mount point上即可。

sh-3.2# mount -t tmpfs -o size=2m tmpfs /tmp_fs_2/

sh-3.2# touch /tmp_fs_2/test

sh-3.2# ls /tmp_fs_2/

test

sh-3.2# umount /tmp_fs_2/

sh-3.2# ls /tmp_fs_2/

如何umount一个文件系统?

可以直接使用umount命令来卸载一个文件系统。

sh-3.2# umount /tmp

umount: /tmp: device is busy.

(In some cases useful info about processes that use

the device is found by lsof(8) or fuser(1))

但是有时候会出现文件系统无法卸载的情况。

初步分析可能是因为该文件系统中存在打开着的文件没有被关闭造成的。

此时我们可以借助于lsof命令进行确认。

sh-3.2# ./lsof /tmp/

通过确认,果然有很多打开着的文件。

所以如果想要umount这个文件系统,必须将该文件系统中已打开的文件都关闭掉。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/388568.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

python 数据科学 包_什么时候应该使用哪个Python数据科学软件包?

python 数据科学 包Python is the most popular language for data science. Unfortunately, it can be tricky to know which of the many data science libraries to use when. ☹️Python是数据科学中最流行的语言。 不幸的是,要知道何时使用许多数据科学库中的哪…

Go语言开发环境配置

http://blog.csdn.net/hil2000/article/details/41261267/ 一.我为什么要学习go语言 当今已经是移动和云计算时代,Go出现在了工业向云计算转型的时刻,简单、高效、内 置并发原语和现代的标准库让Go语言尤其适合云端软件开发(毕竟它就是为此而…

微软研发致胜策略

第一章奠定基础 1.千万不要把程序设计师的时间浪费在改善产品以外的工作上。 2.保护程序设计师不受任何阻碍和干扰。 3.永远记得自己真正的目标,然后让团队用最有将效又最愉快的方法把它完成。 4.理清详细的项目目…

熊猫tv新功能介绍_您应该知道的4种熊猫绘图功能

熊猫tv新功能介绍Pandas is a powerful package for data scientists. There are many reasons we use Pandas, e.g. Data wrangling, Data cleaning, and Data manipulation. Although, there is a method that rarely talks about regarding Pandas package and that is the …

CPP_封装_继承_多态

类的三方法:封装,继承,多态。封装:使用一整套方法去创建一个新的类型,这叫类的封装。继承:从一个现有的类型基础上,稍作改动,得到一个新的类型的方法,叫类的继承。多态&a…

win与linux渊源,微软与Linux从对立走向合作,WSL是如何诞生的

原标题:微软与Linux从对立走向合作,WSL是如何诞生的正文Windows Subsystem for Linux(WSL)的开发,让微软从Linux的对立面走向合作,并且不断加大对开源社区的支持力度。而作为微软历史上的重要转折点,外界对WSL技术在Pr…

文件编辑器 vi

1、关于文本编辑器; 文本编辑器有很多,比如图形模式的gedit、kwrite、OpenOffice ... ... ,文本模式下的编辑器有vi、vim(vi的增强版本)和nano ... ... vi和vim是我们在Linux中最常用的编辑器。我们有必要介绍一下vi&a…

MFC80.DLL复制到程序目录中,也有的说复制到安装目录中

在用VS2005学习C调试程序的时候,按F5键,总提示这个问题, 不晓得什么原因,网上有的说找到MFC80.DLL复制到程序目录中,也有的说复制到安装目录中,可结果很失望,也有的VS2005安装有问题&#xff0…

vs显示堆栈数据分析_什么是“数据分析堆栈”?

vs显示堆栈数据分析A poor craftsman blames his tools. But if all you have is a hammer, everything looks like a nail.一个可怜的工匠责怪他的工具。 但是,如果您只有一把锤子,那么一切看起来都像钉子。 It’s common for web developers or databa…

服务器

服务器主流品牌:华为、浪潮、戴尔、惠普华为服务器:华为FusionServer RH2288 V3 华为FusionServer RH5885 V3 浪潮服务器: 浪潮英信NP3020M4 浪潮英信NF5280M4 戴尔服务器: 戴尔PowerEdge R730 机架式服务器 戴尔PowerEdge R740 机…

树莓派 zero linux,树莓派 zero基本调试

回家之前就从网上购买了一堆设备,回去也不能闲着,可以利用家里相对齐全的准备安装调试。结果人还没回来,东西先到了。购买的核心装备是树莓派zero w,虽然已经知道它比家族大哥树莓派小不少,但拿到手里还是惊奇它的小巧…

error C2440 “static_cast” 无法从“void (__thiscall CPppView )(void)”转换为“LRESULT (__thiscall

error C2440 “static_cast” 无法从“void (__thiscall CPppView )(void)”转换为“LRESULT (__thiscall CWnd )(WPARAM,LPARAM)” 不能转换void (_thiscall CMainFrame::*)(void)to LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)开发平台由VC6.0升级至VS2005,需要…

简单的编译流程

简易编译器流程图: 一个典型的编译器,可以包含为一个前端,一个后端。前端接收源程序产生一个中间表示,后端接收中间表示继续生成一个目标程序。所以,前端处理的是跟源语言有关的属性,后端处理跟目标机器有关的属性。 复…

广告投手_测量投手隐藏自己的音高的程度

广告投手As the baseball community has recently seen with the Astros 2017 cheating scandal, knowing what pitch is being thrown gives batters a game-breaking advantage. However, unless you have an intricate system of cameras and trash cans set up, knowing wh…

linux事务隔离级别,事务的隔离级别(Transaction isolation levels)2

READ COMMITTEDREAD COMMITTED这是数据库默认的隔离级别。它能保证你不能读取那张表格数据,只要有其它事务还在改变这张表格数据。可是,因为sql server在select操作的时,锁表格时间就那么一小会儿,如果一个事务在READ COMMITTED级…

Asp导出到Excel之二

response.contentType "application/vnd.ms-excel" response.addheader "Content-Disposition", "attachment; filename引出文件.xls" 一、适用于动态和表态表。 二、页面最好只存放数据表,不要有其它内容。 三、对于分页的情…

warning C4996: “strcpy”被声明为否决的解决办法

VC2005中,使用了很多标准的C函数,比如fopen,strcpy之类的。编译时会出现警告,比如这个: d:\xxxx.c(1893) : warning C4996: “strcpy”被声明为否决的 紧接着IDE有提示说:“This function or variable…

验证部分表单是否重复

1. 效果 图片中的名称、机构编码需要进行重复验证2. 思路及实现 表单验证在获取数据将需要验证的表单数据进行保存this.nameChangeTemp response.data.orgName;this.codeChangeTemp response.data.orgCode; 通过rule对表单进行验证 以名字的验证为例rules: {orgName: [// 设置…

python bokeh_提升视觉效果:使用Python和Bokeh制作交互式地图

python bokehLet’s face it, fellow data scientists: our clients LOVE dashboards. Why wouldn’t they? Visualizing our data helps us tell a story. Visualization turns thousands of rows of data into a compelling and beautiful narrative. In fact, dashboard vi…

用C#写 四舍五入函数(原理版)

doubled 0.06576523;inti (int)(d/0.01);//0.01决定了精度 doubledd (double)i/100;//还原 if(d-dd>0.005)dd0.01;//四舍五入 MessageBox.Show((dd*100).ToString()"%");//7%,dd*100就变成百分的前面那一部分了