Linux Entry Disk Management (3) file system mount

Source: Internet
Author: User
Tags uuid

Linux Entry Disk Management (3) file system Mount

when a disk is partitioned and a file system is created, it simply means that the device can be used for storage, but to access the device, it is necessary to provide access to the user by establishing one or more mount points, in Linux , Provides powerful commands for file system mount and management.


Use of MOUNT commands

Mount Command

Usage:

Mount [option] DEVICE MountDir

device (Devices to be mounted) :

device name: such as /dev/sdb1/dev/hda2

Volume label name:-L "lable" such as -L MyData

UUID :-u uuid

pseudo file system:proc SYSFS Tmpfs devpts

MountDir (mount point):

generally use an empty directory, if the directory has content, mount this directory, the content is hidden

Option

-T Vfstype : Specifies that the file system is used for recognition, such as ISO9660 as an image file

-A : Mount the device and mount point specified in the /etc/fstab

-N : Do not update/etc/mtab when mounted

-R : Read-only Mount

-W : Read-write Mount

-L LABEL : Specifies that the volume label is attached to a mounted device

-U uuid : Specifies The Mount device of the corresponding UUID

-B or --bind : Mount a directory as a device

- o OPTIONS : Additional mount options

Async : Asynchronous Mount

Sync : Sync Mount

Noatime/atime : Do not update / update access time for all files (including directories) in the Mount

Nodiratime/diratime : Do not update directory access time / Update Directory Access time

Auto/noauto : Whether to support automatic mount, that is, whether to support mount-a

Exec/noexec : Whether to support running program files on this mount point

Dev/nodev : Whether to support the use of device files on this mount point

Suid/nosuid: Whether the suid and sgid permission bits on this mount point are supported

Remount : Re-mount

RO : Read-only Mount

RW : Read-write Mount

ACL : Enable ACL feature

User/nouser : Whether a normal user is supported to mount this device, the default is for administrators to use

Defaults (the General default Mount option, which excludes additional mounts that are added with the-o option in TUNE2FS):

RW, suid, dev, exec, suid, Nouser, async


Uninstall Command

Umount Command

Umount DEVICE | Mount_point : Indicates mount point directory or Mount device can be uninstalled


Command use case:

View a list of mount points

Using the Mount command

Mount #直接输入mount表示查看当前系统所有挂载点

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/86/88/wKiom1fC2meyfH2wAAB8qvf0--w031.jpg "title=" Mount.jpg "alt=" Wkiom1fc2meyfh2waab8qvf0--w031.jpg "/>

Using the FINDMNT command

Findmnt #默认为查看所有 to view mount information for the specified device mount status findmnt/dev/sdb1 #查看/dev/sdb1

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/86/88/wKiom1fC2vSjZ7-2AAAlVDxr_k4665.jpg "title=" Findmnt.jpg "alt=" Wkiom1fc2vsjz7-2aaalvdxr_k4665.jpg "/>

You can view the System file mapping file by viewing the

Cat/proc/mounts #查看所有被挂载的文件系统

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/86/87/wKioL1fC2ySDc5oDAAE31YU2_5A791.jpg "title=" Proc.jpg "alt=" Wkiol1fc2ysdc5odaae31yu2_5a791.jpg "/>


Mounting devices

Mount/dev/sdb1/mnt/sdb1

#直接挂载 [[email protected] ~]# MOUNT/DEV/SDB1/MNT/SDB1

Resolution: No mount option is specified, and the default Mount option has no additional functionality, there is no hint

Mount properties for #查看/dev/sdb1 [[email protected] ~]# Mount | grep ' ^/dev/sdb1 '/dev/sdb1 on/mnt/sdb1 type ext2 (rw)
#查看更详细的信息 [[email protected] ~]# Cat/proc/mounts | grep ' ^/dev/sdb1 '/dev/sdb1/mnt/sdb1 ext2 rw,seclabel,relatime,errors=continue,acl 0 0


Uninstalling the device

UMOUNT/DEV/DB1 #一般没有消息说明卸载成功, uninstall to stop the use of their files, or can not be uninstalled


Use specific options to mount

#挂载为只读挂载点 [[email protected] ~]# mount-r/dev/sdb1/mnt/sdb1# write the data again, showing the error message: read-only file system [[email protected] ~]# echo "Data" ;>/mnt/sdb1/file.log-bash:/mnt/sdb1/file.log:read-only file system# re-mount as readable writable [[email protected] ~]# Mount-o remount,rw/dev/sdb1# Query mount device information, more Rw[[email protected] ~]# findmnt/dev/sdb1target SOURCE fstype Options/mnt/sdb1/dev /SDB1 ext2 Rw,relatime,seclabel,errors=continue,acl

Note: Re-mount does not indicate the mount point again, because after the last mount operation, the list information is saved by default in/etc/mtab, and the reload reads the corresponding information


Mount Directory

#将一个文件夹当设备挂载 [[email protected] ~]# Mount--BIND/BOOT/MNT/BOOT#DF View only the file system types supported by the system kernel, all unrecognized [[email protected] ~]# DF | grep '/boot '/dev/sda1 194241 34107 149894 19%/boot# use mount to view all mount points and find/boot related mounts, found 2 [[email protected] ~]# mo UNT | grep '/boot '/dev/sda1 on/boot type EXT4 (rw)/boot On/mnt/boot type None (Rw,bind)

Then use LS to view the information of two mount points separately:

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/86/88/wKioL1fC3NiS8K2VAAByyWBjx0U422.jpg "title=" Access portal. jpg "alt=" wkiol1fc3nis8k2vaabyywbjx0u422.jpg "/>

Parsing: Found two mount points of the same file content, at this time because,/boot capability is a mount point, the device is /dev/sda1,

Then use mount point to mount the corresponding directory, just provide two access portals


Prohibit normal users from running program files at specified mount points

#切换到/DEV/SDB1 mount point [[email protected] ~]# cd/mnt/sdb1/[[email protected] sdb1]# pwd/mnt/sdb1# Create a script file [[email protected] sdb1]# echo "echo xxxx" > hello.sh# Add all users have execute permission [[email protected] sdb1]# chmod +x hello.sh #切换到普通用户 [[email protected] SD b1]# Su hadoop# because the ordinary user for other people, all have execute permission can execute [[email protected] sdb1]$./hello.sh xxxx# exit from normal user [email protected] sdb1]$ Exitexit #挂载为禁止普通用户运行程序, footstep file [[email protected] sdb1]# mount-o remount,noexec/dev/sdb1# switch again [[email protected] sdb1]# su hadoop# Even though the file has execute permissions, the mount point prohibits the normal user from running the program file [[email protected] sdb1]$./hello.shbash:./hello.sh:permission denied


This article is from the "Excalibur Trunks-kun" blog, please be sure to keep this source http://mengzhaofu.blog.51cto.com/10085198/1843600

Linux Entry Disk Management (3) file system mount

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.