Mounting File Systems

1.Mounting File Systems

Just creating a partition and putting a file system on it is not enough to start using it. To use a partition, you have to mount it as well. By mounting a partition (or better, the file system on it), you make its contents accessible through a specific directory.
To mount a file system, some information is needed:
■ What to mount: This information is mandatory and specifies the name of the device that needs to be mounted.
■ Where to mount it: This is also mandatory information which specifies the directory on which the device should be mounted.
■ What file system to mount: Optionally, you can specify the file system type. In most cases, this is not necessary. The mount command will detect which file system is used on the device and make sure the correct driver is used.
■ Mount options: Many mount options can be used when mounting a device. Using options is optional and depends on the needs you may have with the file system.
Manually Mounting File Systems To manually mount a file system, the mount command is used. To disconnect a mounted file system, the umount command is used. Using these commands is relatively easy. To mount the file system that is on /dev/vda5 on the directory /mnt, use the following command:
mount /dev/vda5 /mnt
To disconnect the mount, you can use umount with either the name of the device or the name of the mount point you want to disconnect. So, both of the following commands will work: umount /dev/vda5 umount /mnt
Using Device Names, UUIDs, or Disk Labels

To mount a device, the name of the device can be used, as in the command /dev/ vda5. If your server is used in an environment where a dynamic storage topology is used, this is not always the best approach. You may today have a storage device /dev/ sda5, which after changes in the storage topology can be /dev/sdb5 after the next reboot of your server. This is why on a default RHEL 7 installation UUIDs are used instead of device names. Every file system by default has a UUID associated to it, not just file systems that are used to store files but also special file systems such as the swap file system. You can use the blkid command to get an overview of the current file systems on your system and the UUID that is used by that file system.

[[email protected] ~]# blkid
/dev/sda1: UUID="2f8b9056-1129-4bea-bb94-bc2f7f8de206" TYPE="xfs"
/dev/sda2: UUID="OjqvZk-KS1b-YegW-zb4b-uaNV-zGt7-npfsjU" TYPE="LVM2_member"
/dev/sdb1: UUID="f4a212cd-211f-4ddd-84ed-18ede66505ff" TYPE="ext4"
/dev/sdc1: UUID="b74fbc00-3f2e-4dea-99da-a17de3f798c3" TYPE="swap"
/dev/mapper/rhel-root: UUID="4119798b-4939-48f4-be1a-3f3de1f8e934" TYPE="xfs"
/dev/mapper/rhel-swap: UUID="8a1f616f-989d-4846-a961-ee5ea2bc32bf" TYPE="swap" 

mount UUID="42f419c4-633f-4ed7-b161-519a4dadd3da" /mnt   --使用uuid挂载设备
Manually mounting devices using the UUID is not exactly easier. If mounts are automated as discussed in the next section, however, it does make sense using UUIDs instead of device names.

2. Automating File System Mounts Through /etc/fstab 

[[email protected] ~]# cat /etc/fstab 

#
# /etc/fstab
# Created by anaconda on Tue Jun 14 22:38:46 2016
#
# Accessible filesystems, by reference, are maintained under ‘/dev/disk‘
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/rhel-root   /                       xfs     defaults        0 0
UUID=2f8b9056-1129-4bea-bb94-bc2f7f8de206 /boot xfs     defaults        0 0
/dev/mapper/rhel-swap   swap                    swap    defaults        0 0

#added by rusky:used for testing.
/dev/sdb1       /testdisk       ext4    defaults        0 0

In the /etc/fstab file, everything is specified to mount the file system automatically. For this purpose, every line has six fields, as summarized in  Table   14.5   .

Notice that in the mount point not all file systems use a directory name. Some system devices such as swap are not mounted on a directory, but on a kernel interface. It is easy to recognize when a kernel interface is used; its name does not start with a / (and does not exist in the file system on your server).   The Mount Options field defines specific mount options that can be used. If no specific options are required, this line will just read “defaults.” To offer specific functionality, a large number of mount options can be specified here.  Table   14.6    gives an overview of some of the more common mount options.

The fifth column of /etc/fstab specifies support for the dump utility. This is a utility that was developed to create file system backups. It is good practice to switch this feature on by specifying a 1 for all real file systems, and switch it off by specifying 0 for all system mounts  . The last column indicates if the file system integrity needs to be checked while booting. Put a 0 if you do not want to check the file system at all, a 1 if this is the root file system which needs to be checked before anything else, and a 2 if this is a nonroot file system that needs to be checked while booting.

时间: 2024-10-13 10:35:22

Mounting File Systems的相关文章

RH413 Unit 3 Create File Systems

There are two major reasons for allocating fire systems separately: containment and mounting with more restrictive mount options.Containment reduces the impact a file systems has on the rest of the system if it fills up. For example, if a program has

Introducing Microsoft Sync Framework: Sync Services for File Systems

https://msdn.microsoft.com/en-us/sync/bb887623 Introduction to Microsoft Sync Framework File Synchronization Provider Introduction Microsoft Sync Framework is a comprehensive综合 synchronization同步 platform that enables collaboration合作 and offline scena

Log-structured File Systems

换到博客园排版有问题,原版在这里:http://xubenbenhit.github.io/LogStructureFileSystem.html Log-structured File Systems 2014-12-26 #system 先来扯淡,这篇博客讲的是LFS,之前写的硬盘与磁盘冗余阵列其实是第一篇,而这个应该算是第三篇,这中间差了一篇介绍文件系统的博客,原本打算今天回去之后一起写了,但是考虑到自己回家之后的效率不敢保证.故而先在实验室写完这个文章,而文件系统的资料全部在家. 1.

df 命令no file systems processed

故障现象: 执行df -h以及df -i检查磁盘信息是,无法返回结果,报df : no file systems processed错误 原因分析: 在执行 df 命令时,会读取 /etc/mtab 文件中的挂载信息,才能获取到当前系统中的分区的挂载情况.而 /etc/mtab 文件是在 mount 挂载分区.umount 卸载分区等操作时动态更新的,同时它也与 /proc/mount 中的挂载信息相同.当 /etc/mtab 中的内容存在异常导致与 /proc/mount 不同步时,就会导致执

df -h 时出现df: cannot read table of mounted file systems的解决方法

出现df: cannot read table of mounted file systems,使用grep -v rootfs /proc/mounts > /etc/mtab 后解决,这边做下记录. 下面来了解一下/etc/fstab和/etc/mtab的区别和联系. /etc/fstab文件的作用记录了计算机上硬盘分区的相关信息,启动 Linux 的时候,检查分区的 fsck 命令,和挂载分区的 mount 命令,都需要 fstab 中的信息,来正确的检查和挂载硬盘. /etc/mtab文

File System Design Case Studies

SRC=http://www.cs.rutgers.edu/~pxk/416/notes/13-fs-studies.html Paul Krzyzanowski April 24, 2014 Introduction We've studied various approaches to file system design. Now we'll look at some real file systems to explore the approaches that were taken i

NFS(Network File System)服务配置和使用

Sun公司开发NFS (Network File System)之初就是为了在不同linux/Unix系统之间共享文件或者文件夹.可以在本地通过网络挂载远程主机的共享文件,和远程主机交互.NFS共享存储对初学者来说不太好理解,我看到过一个很好的例子,假如有三台机器A.B.C,它们需要访问同一个目录,目录中都是图片,传统的做法是把这些图片分别放到A.B.C.但是使用NFS只需要放到A上,然后A共享给B和C即可.访问的时候,B和C是通过网络的方式去访问A上的那个目录的. 一.NFS的优势 允许本地获

DFS(distributed file system)

A clustered file system is a file system which is shared by being simultaneously mounted on multiple servers. There are several approaches to clustering, most of which do not employ a clustered file system (only direct attached storage for each node)

Extension of write anywhere file system layout

A file system layout apportions an underlying physical volume into one or more virtual volumes (vvols) of a storage system. The underlying physical volume is an aggregate comprising one or more groups of disks, such as RAID groups, of the storage sys