挂载mount指令

挂载注意事项

1.一个目录、同一时间只能被一个设备挂载
2.一个设备可以挂载多个目录
3.如果一个目录被多个设备挂载,只能看到最后一个挂载的设备数据,其他的设备数据会被隐藏。
4.工作里建议用新的文件夹,作为挂载点。

mount命令

参数
解释
-l
显示系统以挂载的设备信息
-a
加载文件/etc/fstab中设置的所有设备
-t
t<文件系统类型> 指定设备的文件系统类型。如果不设置,mount自行选择挂载的文件类型 minix Linux最早使用的文件系统。 ext2 Linux目前的常用文件系统。 msdos MS-DOS 的 FAT。 vfat Win85/98 的 VFAT。 nfs 网络文件系统。 iso9660 CD-ROM光盘的标准文件系统。 ntfs Windows NT的文件系统。 hpfs OS/2文件系统。Windows NT 3.51之前版本的文件系统。 auto 自动检测文件系统。
-o
添加挂载选项,是安全、性能优化重要参数
-r
只读,等于-o ro
-w
读写,等-o rw
 

mount -o选项详解

参数
含义
async
以异步方式处理文件系统I/O操作,数据不会同步写入磁盘,而是写到缓冲区,提高系统性能,但损失数据安全性
sync
所有I/O操作同步处理,数据同步写入磁盘,性能较弱,数据安全性高
atime/noatime
文件被访问时是否修改时间戳,不更改时间,可以提高磁盘I/O速度
auto/noauto
通过-a参数可以自动被挂载/不自动挂载
defaults
默认值包括rw、suid、dev、exec、auto、nouser、async,/etc/fstab大多默认值
exec/noexec
是否允许执行二进制程序,取消提供安全性
suid/nosuid
是否允许suid(特殊权限)生效
user/nouser
是否允许普通用户挂载
remount
重新挂载
ro
只读
rw
读写

只读挂载

 
1
2
3
4
5
6
7
8
[root@lamp-241 ~]# mount -o ro /dev/sdb6 /mnt
[root@lamp-241 ~]#
[root@lamp-241 ~]# ls /mnt
[root@lamp-241 ~]#
[root@lamp-241 ~]# touch /mnt/超哥牛逼.txt
touch: cannot touch ‘/mnt/超哥牛逼.txt’: Read-only file system
[root@lamp-241 ~]#

  

禁止可执行文件

复制代码
[root@lamp-241 ~]# mount -o noexec,rw /dev/sdb6 /mnt #不写rw也可以,因为默认rw
[root@lamp-241 ~]#
[root@lamp-241 ~]# cd /mnt
[root@lamp-241 mnt]# echo 'echo "爱的供养"' > music.sh
[root@lamp-241 mnt]#
[root@lamp-241 mnt]# chmod 777 music.sh
[root@lamp-241 mnt]# ll
total 4
-rwxrwxrwx 1 root root 20 Mar  2 17:54 music.sh
[root@lamp-241 mnt]#
[root@lamp-241 mnt]# ./music.sh
-bash: ./music.sh: Permission denied
[root@lamp-241 mnt]#
重新挂载之后,默认是允许执行 挂载目录的 文件的

#查看挂载目录信息。
[root@lamp-241 ~]# mount -l |grep mnt
/dev/sdb6 on /mnt type xfs (rw,relatime,attr2,inode64,noquota)

参数解释
rw 读写
relatime   mount 选项 relatime(relative atime 的意思)。relatime 的意思是访问文件时,仅在 atime 早于文件的更改时间时对 atime 进行更新。

attr2   在磁盘上存储内联扩展属性,提升性能
inode64 允许在文件系统的任意位置创建 inode
noquota 强制关闭所有文件系统限额功能
复制代码

 

 

 

posted @   雷滚滚  阅读(122)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示