新聞中心
在Linux操作系統(tǒng)中,MTAB代表”mounted table”,是一個(gè)包含系統(tǒng)當(dāng)前已掛載文件系統(tǒng)的列表。MTAB文件記錄了系統(tǒng)中每一個(gè)已經(jīng)掛載的文件系統(tǒng)的類型、掛載點(diǎn)、文件系統(tǒng)的參數(shù)等等。

MTAB文件最初是由系統(tǒng)管理員手動(dòng)創(chuàng)建的,但是在現(xiàn)代Linux發(fā)行版中,MTAB文件已經(jīng)被自動(dòng)化,并且在系統(tǒng)啟動(dòng)時(shí)由init腳本掃描掛載點(diǎn)的文件,并將掛載文件系統(tǒng)的數(shù)據(jù)寫入MTAB文件中。
作用
MTAB文件的主要作用是提供有關(guān)當(dāng)前掛載的文件系統(tǒng)列表的信息。MTAB文件包含了當(dāng)前系統(tǒng)所有已經(jīng)掛載的文件系統(tǒng)的類型,掛載點(diǎn)和文件系統(tǒng)參數(shù)的信息。此外,MTAB文件還可以用于驗(yàn)證已掛載文件系統(tǒng)的正確性,以及管理掛載點(diǎn)和文件系統(tǒng)的參數(shù)。
MTAB文件有助于系統(tǒng)管理員了解有關(guān)文件系統(tǒng)的信息。如果有必要重新安裝文件系統(tǒng)或者掛載點(diǎn),系統(tǒng)管理員可以參考MTAB文件以獲取有關(guān)掛載點(diǎn)和文件系統(tǒng)的信息。
使用方法
MTAB文件通常保存在”/etc/mtab”目錄下。可以使用以下命令來(lái)查看當(dāng)前掛載文件系統(tǒng)的列表:
$ cat /etc/mtab
該命令會(huì)輸出MTAB文件的全部?jī)?nèi)容。在MTAB文件中,每個(gè)文件系統(tǒng)條目包括全部的文件系統(tǒng)和掛載點(diǎn)的信息。以下是一個(gè)典型的MTAB文件的示例:
rootfs / rootfs rw 0 0
sysfs /sys sysfs rw,nosuid,nodev,noexec 0 0
proc /proc proc rw,nosuid,nodev,noexec 0 0
udev /dev tmpfs rw,size=10m,mode=0755,nosuid,nodev 0 0
tmpfs /dev/shm tmpfs rw,size=10m,mode=1777,nosuid,nodev 0 0
devpts /dev/pts devpts rw,nosuid,noexec,gid=5,mode=0620 0 0
MTAB文件是一個(gè)記錄已掛載的文件系統(tǒng)信息的表格。它提供了有關(guān)系統(tǒng)中文件系統(tǒng)的類別、掛載點(diǎn)、文件系統(tǒng)參數(shù)等重要信息,并可以作為驗(yàn)證、管理、查詢掛載點(diǎn)和文件系統(tǒng)參數(shù)的基礎(chǔ)。
在Linux系統(tǒng)中,理解MTAB文件的含義和作用是非常重要的。通過(guò)了解MTAB文件的內(nèi)容和使用方法,系統(tǒng)管理員可以更有效地管理文件系統(tǒng),確保系統(tǒng)的穩(wěn)定性和安全性。
相關(guān)問題拓展閱讀:
- /etc/fstab文件和/etc/mtab文件是什么關(guān)系?
- Linux磁盤管理
/etc/fstab文件和/etc/mtab文件是什么關(guān)系?
他們兩個(gè)在結(jié)構(gòu)和內(nèi)容上基本是相同的,也同樣在一個(gè)文件夾之下,只不過(guò)他們的記錄的分區(qū)信息不同。
前者主要是存放了系統(tǒng)啟動(dòng)時(shí)需要掛載的文檔信息,每當(dāng)系統(tǒng)自動(dòng)啟動(dòng)的時(shí)候,系統(tǒng)就會(huì)讀取這些文件,當(dāng)系統(tǒng)需要掛載的時(shí)候,系統(tǒng)就會(huì)選擇這種掛載。
而后者主要用于系統(tǒng)啟動(dòng)之后,系統(tǒng)產(chǎn)生掛在文件,這其中也包括他的系統(tǒng)建立的窨井文件,可以直接通過(guò)后者來(lái)確定或者查詢,兩者的功能,可以說(shuō)是一前一后的,也可以認(rèn)為是相輔相成的。
這個(gè)文件更好不要?jiǎng)铀?,是給你看的,不是給你改的 fstab 文件想必大家都很熟悉,記錄了計(jì)算機(jī)上硬盤分區(qū)的相關(guān)信息,啟動(dòng) Linux 的時(shí)候,檢查分區(qū)的 fsck 命令,和掛載分區(qū)的 mount 命令,都需要 fstab 中的信息,來(lái)正確的檢查和掛載硬盤。
/etc/fstab文件記錄靜態(tài)文件系統(tǒng)信息,按照/etc/fstab上的介紹,該文件記錄計(jì)算機(jī)硬盤分區(qū)相關(guān)信息,啟動(dòng)Linux、mount掛載分區(qū)等命令執(zhí)行都,都會(huì)用到fstab信息,看頁(yè)面示例也是帶有: 。
文件系統(tǒng),掛載點(diǎn),分區(qū)類型,掛載選項(xiàng),dump選項(xiàng),這樣的格式內(nèi)容,但天緣自己從Ubuntu 11.04上抓到卻是這么個(gè)內(nèi)容,其它細(xì)節(jié)沒看,至少直接打開來(lái)查詢外部SD卡驅(qū)動(dòng)器路徑有點(diǎn)問題。
Linux磁盤管理
是一個(gè)創(chuàng)建和維護(hù)分區(qū)表的程序,它兼容DOS類型的分區(qū)表、BSD或者SUN類型的磁盤列表。
語(yǔ)法
fdisk
必要參數(shù):
-l 列出素所有分區(qū)表
-u 與”-l”搭配使用,顯示分區(qū)數(shù)目
選擇參數(shù):
-s 指定分區(qū)
-v 版本信息
菜單操作說(shuō)明
m :顯示菜單和幫助信息
a :活動(dòng)分區(qū)標(biāo)記/引導(dǎo)分區(qū)
d :刪除分區(qū)
l :顯示分區(qū)類型
n :新建分區(qū)
p :顯示分區(qū)信息
q :退出不保存
t :設(shè)置分區(qū)號(hào)
v :進(jìn)行分區(qū)檢查
w :保存修改
x :擴(kuò)展應(yīng)用,高級(jí)功能
(英文全拼:make file system)命令用于在特定的分區(qū)上建立 linux 文件系統(tǒng)。
使用方式 :
mkfs filesys
參數(shù) :
device : 預(yù)備檢查的硬盤分區(qū),例如:/dev/sda1
-V : 詳細(xì)顯示模式
-t : 給定檔案系統(tǒng)的型式,Linux 的預(yù)設(shè)值為 ext2
-c : 在制做檔案系統(tǒng)前,檢查該partition 是否有壞軌
-l bad_blocks_file : 將有壞軌的block資料加到 bad_blocks_file 里面
block : 給定 block 的大小
命令是經(jīng)常會(huì)使用到的命令,它用于掛載Linux系統(tǒng)外的文件。
語(yǔ)法
mount mount -a mount > device | dir
mount device dir
參數(shù)說(shuō)明:
-V:顯示程序版本
-h:顯示輔助訊息
-v:顯示較訊息,通常和 -f 用來(lái)除錯(cuò)。
-a:將 /etc/fstab 中定義的所有檔案系統(tǒng)掛上。
-F:這個(gè)命令通常和 -a 一起使用,它會(huì)為每一個(gè) mount 的動(dòng)作產(chǎn)生一個(gè)行程負(fù)責(zé)執(zhí)行。在系統(tǒng)需要掛上大量 NFS 檔案系統(tǒng)時(shí)可以加快掛上的動(dòng)作。
-f:通常用在除錯(cuò)的用途。它會(huì)使 mount 并不執(zhí)行實(shí)際掛上的動(dòng)作,而是模擬整個(gè)掛上的過(guò)程。通常會(huì)和 -v 一起使用。
-n:一般而言,mount 在掛上后會(huì)在 /etc/mtab 中寫入一筆資料。但在系統(tǒng)中沒有可寫入檔案系統(tǒng)存在的情況下可以用這個(gè)選項(xiàng)取消這個(gè)動(dòng)作。
-s-r:等于 -o ro
-w:等于 -o rw
-L:將含有特定標(biāo)簽的硬盤分割掛上。
-U:將檔案分割序號(hào)為 的檔案系統(tǒng)掛下。-L 和 -U 必須在/proc/partition 這種檔案存在時(shí)才有意義。
-t:指定檔案系統(tǒng)的型態(tài),通常不必指定。mount 會(huì)自動(dòng)選擇正確的型態(tài)。
-o async:打開非同步模式,所有的檔案讀寫動(dòng)作都會(huì)用非同步模式執(zhí)行。
-o sync:在同步模式下執(zhí)行。
-o atime、-o noatime:當(dāng) atime 打開時(shí),系統(tǒng)會(huì)在每次讀取檔案時(shí)更新檔案的『上一次調(diào)用時(shí)間』。當(dāng)我們使用 flash 檔案系統(tǒng)時(shí)可能會(huì)選項(xiàng)把這個(gè)選項(xiàng)關(guān)閉以減少寫入的次數(shù)。
-o auto、-o noauto:打開/關(guān)閉自動(dòng)掛上模式。
-o defaults:使用預(yù)設(shè)的選項(xiàng) rw, suid, dev, exec, auto, nouser, and async.
-o dev、-o nodev-o exec、-o noexec允許執(zhí)行檔被執(zhí)行。
-o suid、-o nosuid:
允許執(zhí)行檔在 root 權(quán)限下執(zhí)行。
-o user、-o nouser:使用者可以執(zhí)行 mount/umount 的動(dòng)作。
-o remount:將一個(gè)已經(jīng)掛下的檔案系統(tǒng)重新用不同的方式掛上。例如原先是唯讀的系統(tǒng),現(xiàn)在用可讀寫的模式重新掛上。
-o ro:用唯讀模式掛上。
-o rw:用可讀寫模式掛上。
-o loop=:使用 loop 模式用來(lái)將一個(gè)檔案當(dāng)成硬盤分割掛上系統(tǒng)。
(base) zfy@zfy-PC:~$ sudo fdisk -l
Disk /dev/sda: 80 GiB,bytes,sectors
#塊設(shè)備名稱為/dev/sda,此設(shè)備的大小為80 GB,bytes是轉(zhuǎn)換成字節(jié)后的大小,共個(gè)扇區(qū)
Disk model: VMware Virtual S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x3b1ffeba
Device Boot StartEnd Sectors Size Id Type
#分區(qū)序列 | 引導(dǎo) | 開始 | 終止 | Sectors | 容量 | 分區(qū)類型ID | 分區(qū)類型
/dev/sda1 *.5G 83 Linux
/dev/sda.5G 5 Extended
/dev/sdaG 83 Linux
/dev/sdaG 82 Linux swap / Solaris
/dev/sdaG 83 Linux
/dev/sdaG 83 Linux
/dev/sda.5G 83 Linux
Partition table entries are not in disk order.
a. 在虛擬機(jī)中添加硬盤,添加后使用fdisk -l命令查看,磁盤變成兩個(gè),在sda中還沒有分區(qū)
root@zfy-PC:/home/zfy# fdisk -l
Disk /dev/sda: 2 GiB,bytes,sectors
Disk model: VMware Virtual S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/sdb: 80 GiB,bytes,sectors
Disk model: VMware Virtual S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x3b1ffeba
Device Boot StartEnd Sectors Size Id Type
/dev/sdb1 *.5G 83 Linux
/dev/sdb.5G 5 Extended
/dev/sdbG 83 Linux
/dev/sdbG 82 Linux swap / Solaris
/dev/sdbG 83 Linux
/dev/sdbG 83 Linux
/dev/sdb.5G 83 Linux
Partition table entries are not in disk order.
b.下面對(duì)sda進(jìn)行分區(qū)
root@zfy-PC:/home/zfy# fdisk /dev/sda
Welcome to fdisk (util-linux 2.33.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xb985e226.
Command (m for help): m
#輸入m查看幫助
Help:
DOS (MBR)
a toggle a bootable flag
b edit nested BSD disklabel
c toggle the dos compatibility flag
Generic
d delete a partition
F list free unpartitioned space
l list known partition types
n add a new partition
p print the partition table
t change a partition type
v verify the partition table
i print information about a partition
Misc
m print this menu
u change display/entry units
x extra functionality (experts only)
Script
I load disk layout from sfdisk script file
O dump disk layout to sfdisk script file
Save & Exit
w write table to disk and exit
q quit without saving changes
Create a new label
g create a new empty GPT partition table
G create a new empty SGI (IRIX) partition table
o create a new empty DOS partition table
s create a new empty Sun partition table
Command (m for help): n
#輸入n創(chuàng)建一個(gè)分區(qū)
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
#選擇主分區(qū)
Partition number (1-4, default 1): 1
#選擇編號(hào)為1
First sector (, default 2023):
#起始sector 設(shè)為
Last sector, +/-sectors or +/-size{K,M,G,T,P} (3, default):
#終止sector 設(shè)為
Created a new partition 1 of type ‘Linux’ and of size 827.3 MiB.
#分區(qū)完成,分區(qū)大小為827.3 MiB
Command (m for help): n
#繼續(xù)創(chuàng)建一個(gè)分區(qū)
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p): e
#新增擴(kuò)展分區(qū)
Partition number (2-4, default 2): 2
#選擇編號(hào)為2
First sector (, default 2023): 2023
#起始sector為2023
Last sector, +/-sectors or +/-size{K,M,G,T,P} (, default):
#終止sector為
Created a new partition 2 of type ‘Extended’ and of size 1.2 GiB.
#新增完成,大小為1.2GiB
Command (m for help): w
#保存
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
c.查看分區(qū)后磁盤信息,此時(shí)sda磁盤已經(jīng)有兩個(gè)分區(qū)
Disk /dev/sda: 2 GiB,bytes,sectors
Disk model: VMware Virtual S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xb985e226
Device Boot Start End Sectors Size Id Type
/dev/sda.3M 83 Linux
/dev/sda.2G 5 Extended
Partition table entries are not in disk order.
Disk /dev/sdb: 80 GiB,bytes,sectors
Disk model: VMware Virtual S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x3b1ffeba
Device Boot StartEnd Sectors Size Id Type
/dev/sdb1 *.5G 83 Linux
/dev/sdb.5G 5 Extended
/dev/sdbG 83 Linux
/dev/sdbG 82 Linux swap / Solaris
/dev/sdbG 83 Linux
/dev/sdbG 83 Linux
/dev/sdb.5G 83 Linux
Partition table entries are not in disk order.
d.用ext3的文件系統(tǒng)對(duì)分區(qū)進(jìn)行格式化
root@zfy-PC:/home/zfy# mkfs -t ext3 /dev/sda1
mke2fs 1.44.5 (15-Dec-2023)
Creating filesystem withk blocks andinodes
Filesystem UUID: dbaf1-4eec-a62d-f2b2f8e0ec96
Superblock backups stored on blocks:
, 98304,
Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
e.新建一個(gè)分區(qū)目錄 /data,并掛載
root@zfy-PC:/home/zfy# mkdir data
root@zfy-PC:/home/zfy# mount /dev/sda1 /data
root@zfy-PC:/home/zfy# df -TH /data/#查看是否掛載成功
文件系統(tǒng)類型 容量 已用 可用 已用% 掛載點(diǎn)
/dev/sdaext3 838M 881k 793M 1% /data
f. 用vim打開 etc/fstab并假如 /dev/sda1/data ext3 defaults 0 0,這樣重啟后便不需要再掛載
參考文獻(xiàn):
【1】 Linux mount命令 | 菜鳥教程 (runoob.com)
關(guān)于linux mtab 縮寫的介紹到此就結(jié)束了,不知道你從中找到你需要的信息了嗎 ?如果你還想了解更多這方面的信息,記得收藏關(guān)注本站。
香港服務(wù)器選創(chuàng)新互聯(lián),2H2G首月10元開通。
創(chuàng)新互聯(lián)(www.cdcxhl.com)互聯(lián)網(wǎng)服務(wù)提供商,擁有超過(guò)10年的服務(wù)器租用、服務(wù)器托管、云服務(wù)器、虛擬主機(jī)、網(wǎng)站系統(tǒng)開發(fā)經(jīng)驗(yàn)。專業(yè)提供云主機(jī)、虛擬主機(jī)、域名注冊(cè)、VPS主機(jī)、云服務(wù)器、香港云服務(wù)器、免備案服務(wù)器等。
新聞名稱:Linux文件系統(tǒng)MTAB的含義和作用(linuxmtab縮寫)
分享路徑:http://www.5511xx.com/article/cdhsepj.html


咨詢
建站咨詢
