linux挂载共享文件夹

 
挂载windows共享目录或FTP:
方式一:包含密码
Shell代码  收藏代码

    sudo mount //192.168.10.22/FTPServer /windows -o username=user,password=abcdefg -t cifs  


方式二:密码单独输入
Shell代码  收藏代码

    sudo mount //192.168.10.22/FTPServer /windows -o username=user -t cifs  
    password:abcdefg  


卸载:
Shell代码  收藏代码

    umount /FTPServer  



挂载linux共享目录:
【修改server端】
修改/etc/export文件,加入:
Shell代码  收藏代码

    /home/user/source *(rw)  


执行如下命令是新增的共享生效
Shell代码  收藏代码

    $/etc/rc.d/init.d/nfs restart  



【客户端】执行如下命令挂载共享:
Shell代码  收藏代码

    mount -t nfs -o rw 192.168.10.94:/home/user/source /home/user/target  



设置开机启动自动挂载

1、修改mount_AtoB.sh的密码
2、将mount_AtoB.sh文件放到/home/user目录下
3、改变文件的执行权限,执行如下命令:
Shell代码  收藏代码

    chmod 777 mount_AtoB.sh  


4、将文件加入到启动文件中:
Shell代码  收藏代码

    $ echo /home/user/mount_94to93.sh >> /etc/rc.d/rc.local  



mount_AtoB.sh文件内容,其中abcdefg为192.168.10.94的密码:
Mount_atob.sh代码  收藏代码

    set fileformat=unix  
    #!bin/bash  
    mount -t nfs -o rw 192.168.10.94:/home/user/source /home/user/target <<EOF  
    abcdefg  
    EOF  
原文地址:https://www.cnblogs.com/zheh/p/4930412.html