Linux挂载WebDav盘
Linux挂载WebDav盘
简单挂载
安装davfs2工具
# CentOS yum install davfs2 # Ubuntu/Debian apt install davfs2
挂载 WebDAV 磁盘
先在 Linux 系统上创建个要挂载的文件目录,再挂WebDAV到本地目录,和平时挂载U盘形式一样
mkdir /cloud mount -t davfs https://pan.cloud.com/dav /cloud
然后输入账号密码即可。
开机自动挂载在WebDAV
普通挂载后,重启就会发现通过 WebDAV 挂载的磁盘没有了,也就意味着你每次重启 Linux 系统,都需要重新挂载,这时候需要更改几个设置来实现开机自动挂载。
第一步、编辑davfs2.conf配置文件,将use_locks的1改为0
vim /etc/davfs2/davfs2.conf
# davfs2 configuration file 2012-07-19 # version 9 # ------------------------------------ # Copyright (C) 2006, 2007, 2008, 2009, 2012 Werner Baumann # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. # Please read the davfs2.conf (5) man page for a description of the # configuration options and syntax rules. # Available options and default values # ==================================== # General Options # --------------- # dav_user davfs2 # system wide config file only # dav_group davfs2 # system wide config file only # kernel_fs fuse # buf_size 16 # KiByte # WebDAV Related Options # ---------------------- # use_proxy 1 # system wide config file only # proxy # system wide config file only # servercert # clientcert # secrets ~/.davfs2/secrets # user config file only # ask_auth 1 use_locks 0 # lock_owner # lock_timeout 1800 # seconds # lock_refresh 60 # seconds # use_expect100 0 # if_match_bug 0 # drop_weak_etags 0 # allow_cookie 0 # precheck 1 # ignore_dav_header 0 # server_charset # connect_timeout 10 # seconds # read_timeout 30 # seconds # retry 30 # seconds # max_retry 300 # seconds # add_header # Cache Related Options # --------------------- # backup_dir lost+found # cache_dir /var/cache/davfs2 # system wide cache # ~/.davfs2/cache # per user cache # cache_size 50 # MiByte # table_size 1024 # dir_refresh 60 # seconds # file_refresh 1 # second # delay_upload 10 # gui_optimize 0 # Debugging Options # ----------------- # debug # possible values: config, kernel, cache, http, xml, # httpauth, locks, ssl, httpbody, secrets, most
第二步、修改secrets文件,添加账号信息
vim /etc/davfs2/secrets
在底部添加账号信息,如
https://pan.cloud.com/dav user password
第三步、添加开机挂载命令
vim /etc/rc.local
末尾添加挂载命令,和挂在U盘一样
mount -t davfs https://pan.cloud.com/dav /cloud
重启即可自动挂载。
最后一步、测试
进入挂载路径,查看是否已经存在文件
注意事项
1. 开机没有自动挂载
如果开机没有自动挂载,有可能是rc.local文件没有权限,需要先执行chmod +x /etc/rc.local再重启系统。WebDAV服务商网络连接质量好的话,使用将非常顺滑,而且不占用本地磁盘空间。国外的VPS可以使用国外的知名的云盘运营商,他们的链路质量相对比较优秀,国内的大部分野鸡云也会提供该选项,但是有跑路的风险,无论如何,这羊毛是可以试试的
2. 成功mount后,不能看到webdav本身的文件内容
原因是 webdav 进程无法访问 lost+found 目录。直接把这个目录删除就解决了
免责声明:我们致力于保护作者版权,注重分享,被刊用文章因无法核实真实出处,未能及时与作者取得联系,或有版权异议的,请联系管理员,我们会立即处理!
部分文章是来自自研大数据AI进行生成,内容摘自(百度百科,百度知道,头条百科,中国民法典,刑法,牛津词典,新华词典,汉语词典,国家院校,科普平台)等数据,内容仅供学习参考,不准确地方联系删除处理!
图片声明:本站部分配图来自人工智能系统AI生成,觅知网授权图片,PxHere摄影无版权图库和百度,360,搜狗等多加搜索引擎自动关键词搜索配图,如有侵权的图片,请第一时间联系我们,邮箱:ciyunidc@ciyunshuju.com。本站只作为美观性配图使用,无任何非法侵犯第三方意图,一切解释权归图片著作权方,本站不承担任何责任。如有恶意碰瓷者,必当奉陪到底严惩不贷!