• autofs自动挂载服务


    大部分情况下,我们都需要将挂载信息写入到/etc/fstab文件中,使其能随机器开机时自动挂载。

    但是对于像Samba、NFS等远程资源,建议还是使用autofs自动挂载服务,因为如果挂载的远程资源太多,则会给网络带宽和服务器的硬件资源带来很大负载。

    与mount命令不同,autofs服务程序是一种Linux系统守护进程,当检测到用户试图访问一个尚未挂载的文件系统时,将自动挂载该文件系统。换句话说,将挂载信息填入/etc/fstab文件后,系统在每次开机时都自动将其挂载,而autofs服务程序则是在用户需要使用该文件系统时才去动态挂载,从而节约了网络资源和服务器的硬件资源。

    安装autofs服务程序:

    [root@wu ~]# dnf install autofs
    

     /etc/auto.master是antofs的主配置文件,在autofs服务程序的主配置文件中需要按照“挂载目录 子配置文件”的格式进行填写,挂载目录是设备挂载位置的上一级目录。

    在子配置文件中,应按照“挂载目录 挂载文件类型及权限 :设备名称”的格式进行填写。

    示例1:

    将远程主机172.25.250.10的NFS文件系统/rhome/file1挂载到本地/haha/hehe目录下

    主配置文件

    [rootwu ~]# vim /etc/auto.master
    #
    # Sample auto.master file
    # This is a 'master' automounter map and it has the following format:
    # mount-point [map-type[,format]:]map [options]
    # For details of the format look at auto.master(5).
    #
    /haha  /etc/ceshi.misc   #/haha是本地挂载路径,/etc/ceshi.misc是子配置文件(子配置文件名称需要以.misc结尾)
    /misc   /etc/auto.misc   #参考文件,默认存在
    #
    

    子配置文件

    [rootwu ~]# vim /etc/ceshi.misc
    hehe  -fstype=nfs,rw  172.25.250.10:/rhome/file1  #-fstype指定文件系统的类型,rw定义文件的权限,172.25.250.10:/rhome/file1是待挂载的文件设备

    重启服务

    [root@wu ~]# systemctl start autofs 
    [root@wu ~]# systemctl enable autofs 
    

    使用

    [root@wu ~]#cd /haha/hehe  #当切换到hehe目录中的时候,会将设备信息自动挂载
    

    示例2:

    将光盘设备/dev/cdrom挂载到/media/cdrom目录中。

    主配置文件

    [rootwu ~]# vim /etc/auto.master
    #
    # Sample auto.master file
    # This is a 'master' automounter map and it has the following format:
    # mount-point [map-type[,format]:]map [options]
    # For details of the format look at auto.master(5).
    #
    /media  /etc/iso.misc
    /haha   /etc/ceshi.misc   
    /misc   /etc/auto.misc   #参考文件,默认存在
    #
    

    子配置文件

    [rootwu ~]# vim /etc/iso.misc
    cdrom   -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom
    

    重启服务

    [root@wu ~]# systemctl start autofs 
    [root@wu ~]# systemctl enable autofs 

      

     

      

      

  • 相关阅读:
    Scala 获取当前时间
    mnist 数据集的识别源码解析
    tf.nn.softmax_cross_entropy_with_logits的用法
    softmax函数
    实现手写体 mnist 数据集的识别任务
    MNIST 数据集
    神经网络之激活函数
    模块化神经网络
    np.c_与np.r_
    学习率的选取-滑动平均
  • 原文地址:https://www.cnblogs.com/wushuai2018/p/15987940.html
Copyright © 2020-2023  润新知