linux使用windows磁盘,挂载共享目录
实例说明:客户两台服务器,一台web服务器(linux)只有50G,课程资源太多太大导致磁盘不够用;客户的文档服务器(windows)磁盘很大超过1T,所以产生了,将web资源使用文档服务器磁盘的想法;
windows文档服务器
192.168.-.-
用户名administrator,密码Y123!
203.86.-.-
做共享前先备份哦(先挂着个共享目录,后将资源复制到共享目录中;取消挂载;重新挂载共享目录中复制的资源;删除本地资源;)
文档服务器上创建共享目录 E:\share 复制链接share (file://YUETONG226/share)
测试 在linux服务器上创建要挂载目录 /www/htdocs/webapps/jtcbs/learnspace/testShare
执行挂载命令(testShare下内容没了,直接使用share 文件内容)
mount -t cifs //192.168.-.-/share/learnspace/incoming /www/htdocs/webapps/jtcbs/learnspace/incoming -o username=administrator,password=Y123\!,rw,uid=501,gid=501
具体步骤:
查用户pid,uid
cat /etc/passwd | grep jtcbs
查挂载状态
# df -h
卸载
umount /www/htdocs/webapps/jtcbs/learnspace/testShare(报错的话先切换到其他目录)
挂载操作步骤:
1 文档服务器上创建共享目录 E:\share
2 在linux服务器上创建要挂载目录 /www/htdocs/webapps/jtcbs/learnspace/testShare
3 执行挂载命令(testShare下内容没了,直接使用share 文件内容,密码为Y123!使用\转义!)
mount -t cifs //192.168.-.-/share/learnspace/incoming /www/htdocs/webapps/jtcbs/learnspace/incoming -o username=administrator,password=Y123\!,rw,uid=501,gid=501
4 执行 cp -r /www/htdocs/webapps/jtcbs/learnspace/incoming /www/htdocs/webapps/jtcbs/learnspace/testShare,将incoming目录下的资源文件复制到windows共享目录;
5 删除挂载umount /www/htdocs/webapps/jtcbs/learnspace/testShare(报错的话先切换到其他目录)
6 执行挂载
mount -t cifs //192.168.-.-/share/learnspace/incoming /www/htdocs/webapps/jtcbs/learnspace/incoming -o username=administrator,password=Y123\!,rw,uid=501,gid=501
7 修改挂载目录权限给jtcbs用户; chowm -R jtcbs:jtcbs /www/htdocs/webapps/jtcbs/learnspace/*;执行 df -h查看挂载是否成功
8 遇到的问题
问题1 :命令:
mount -t cifs //192.168.-.-/share/incoming2 /www/htdocs/webapps/jtcbs/manage/testShare -o username=administrator,password=Y123\!,rw,uid=501,gid=501
Couldn’t chdir to /www/htdocs/webapps/jtcbs/manage/testShare: No such file or directory
修改:中间一个空格:
mount -t cifs //192.168.-.-/share/incoming2 /www/htdocs/webapps/jtcbs/manage/testShare -o username=administrator,password=Y123\!,rw,uid=501,gid=501
问题2 :错误命令:非root用户无写权限
mount -t cifs -o username=administrator,password=Y123! //192.168.-.-/share/learnspace/incoming /www/htdocs/webapps/jtcbs/learnspace/incoming
9 开机自启动
Vi /etc/rc.local
写入命令
mount -t cifs //192.168.-.-/share/learnspace/incoming /www/htdocs/webapps/jtcbs/learnspace/incoming -o username=administrator,password=Y123\!,rw,uid=501,gid=501