Analysis and comparison of these three files in Linux/etc/fstab/etc/mtab/proc/mounts

Source: Internet
Author: User

This article mainly explains the functions and differences of the three files in Linux/etc/fstab/etc/mtab/proc/mounts.


/etc/fstab

Operations are aware of the files, if you want to set Mount disk and Dir to automatically load each time the boot, then the relevant information should be written to this file. This file is also read when the "mount-a" command is used to mount automatically. For example:

LABEL=/HADOOP/9/HADOOP/9 ext3 defaults,noatime,nodiratime,noauto 0 2LABEL=/HADOOP/10/HADOOP/10 ext3 defaults,noatime , Nodiratime,noauto 0 2


/etc/mtab

This file is primarily used with the Mount command when the system generates data based on the actual mount situation, for example:

/DEV/SDB1/HADOOP/9 ext3 rw,noatime,nodiratime 0 0/dev/sdc1/hadoop/10 ext3 rw,noatime,nodiratime 0 0


/proc/mounts

This file is a soft link to/proc/self/mounts,/proc the following files are stored in memory and are automatically generated by the kernel. So/proc/mounts can reflect the current mount situation more realistically than the/etc/mtab file.


Scenario Application:

There is a disk in the server because there is a bad way, was umount, through the "df-h" can not see the information of this disk.

Or you can use "chmod 000/dir" to set the disk to be unreadable and not writable.

At this point if you manage 1000 servers, you need to know which disks in your server are umount, what will you do?

Here is a shell script that can give you ideas for:

function check_disks {  for m in  ' awk   ' $3~/ext3/ {printf '  %s  ', $  /etc/fstab '  ; do     fsdev= ""     fsdev= ' awk -v m= $m   ' $2==m {print $1} '  /proc/ Mounts ';    if [ -z  "$fsdev"  ] ; then       msg_= "$msg _  $m (u)"     else      msg_= "$msg _ ' awk -v m= $m   ' $2==m { if  ( $4 ~ /^ro,/ )  {printf" %s (RO) ", $2 } ; } '  /proc/mounts '"     fi  done  if  [ -z  "$msg _"  ] ; then    echo  "Disks ok"  ;  exit 0  else    echo  "$msg _"  ; exit 2   FI} 

The script begins by comparing the differences in/etc/fstab and/proc/mounts, getting the disk to be umount, and then analyzing the RO (read only) disk.

This article from "Linux operation and Maintenance" blog, declined reprint!

Analysis and comparison of these three files in Linux/etc/fstab/etc/mtab/proc/mounts

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.