Analysis and comparison of the three files in Linux/etc/fstab/etc/mtab/proc/mounts partition table location

Source: Internet
Author: User

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

Transfer from http://haohaozhang.blog.51cto.com/9176600/1681827/

/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:

12 LABEL=/hadoop/9/hadoop/9 ext3 defaults,noatime,nodiratime,noauto 0 2LABEL=/hadoop/10 /hadoop/10ext3 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:

12 /dev/sdb1/hadoop/9 ext3 rw,noatime,nodiratime 0 0/dev/sdc1 /hadoop/10ext3 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:

12345678910111213141516 functioncheck_disks {  forin`awk‘$3~/ext3/ {printf" %s ",$2}‘/etc/fstab` ; do    fsdev=""    fsdev=`awk-vm=$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"exit0  else    echo "$msg_"exit2  fi}

The script first compares the differences in/etc/fstab and/proc/mounts, gets the disk that is Umount, and then analyzes the RO (read only) disk.

Analysis and comparison of the three files in Linux/etc/fstab/etc/mtab/proc/mounts partition table location

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.