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.pswp.cn/news/388568.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/388568.shtml
英文地址,請注明出處:http://en.pswp.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就變成百分的前面那一部分了