乐云主机笔记

  • 首页
  • 主机优惠
  • 学习记录
  • 新手教程
  • 自用主机
  • 资源下载
  • 网赚项目
  • 其他
  • pingtest

  1. 首页
  2. 学习记录
  3. 正文

利用davfs2挂载 WEBDAV 网盘为虚拟硬盘

2017年9月27日 2845点热度 1人点赞 0条评论

转自liyuans.com

简介

  • webdav,是一组基于超文本传输协议的技术集合,有利于用户间协同编辑和管理存储在万维网服务器文档。国外的很多网盘,包括 owncloud 都支持 webdav, 本文以 yandex 为例子介绍,挂载在 Linux 上。

介绍

  • davfs2 或者 fusedav 将 WebDAV 共享挂载成 Coda 或者 FUSE 文件系统。
  • KDE 将 WebDAV 作为 kio_http 的一部分提供原生支持。Dolphin,Konqueror 等其他 KDE 应用程序可以直接与 WebDAV 服务器交互。
  • Nautilus 也提供内置支持。
  • cadaver 命令行工具提供类 FTP 命令集,也包含在很多 Linux 发行版中。
  • Apache HTTP 服务 提供基于 davfs 和 Apache Subversion 的 WebDAV 模块。

Windows

  • NetDrive:挂载为网络硬盘机

Mac

  • Finder:系统内置程式
    本文就是利用 davfs2 挂载 wendav。

安装

Linux 主要的源中都有 davfs2, 也可以自己编译,需要准备好环境。

1
2
3
4
5
6
7
8
9
apt-get install davfs2
mkdir /mnt/webdav
mount -t davfs https://webdav.yandex.ru /mnt/webdav
Please enter the username to authenticate with server
https://webdav.yandex.ru or hit enter for none.
Username: test
Please enter the password to authenticate user test with server
https://webdav.yandex.ru or hit enter for none.
Password:

配置

可以把账号密码写入配置文件,以普通用户来挂载。
usermod -a -G network username
编辑 /etc/fstab文件,在后面添加(username 自己替换):
https://webdav.example.com /home/username/webdav davfs user,noauto,uid=username,file_mode=600,dir_mode=700 0 1

创建账号密码配置:

1
2
3
mkdir ~/.davfs2/
echo "https://webdav.example.com webdavuser webdavpassword" >> ~/.davfs2/secrets
chmod 0600 ~/.davfs2/secrets

yandex url 是
https://webdav.yandex.ru

如果是 owncloud, url 是:
https://webdav.example.com/remote.php/webdav

多用户配置

1
2
3
4
/home/username/disk1 webdavuser1 "webdavpassword1"
/home/username/disk2 webdavuser1 "webdavpassword2"
.........
/home/username/diskN webdavuserN "webdavpasswordN"

Now you should be able to mount and unmount ~/webdav:
mount ~/webdav

取消挂载
fusermount -u ~/webdav

错误

如果在复制剪切文件遇到错误,编辑/etc/davfs2/davfs2.conf,修改配置如下,

1
2
3
[...]
use_locks 0
[...]

参考
https://wiki.archlinux.org/index.php/Davfs
https://yandex.com/support/disk/webdav.html
https://zh.wikipedia.org/wiki/WebDAV

开机启动

以stackstorage的1TB网盘在centos中挂载为例
1、启用用户锁,编辑/etc/davfs2/davfs2.conf 找到“use_locks”,去掉前面的 # 然后把 1 改为 0 后保存。
2、保存用户名密码,编辑/etc/davfs2/secrets 增加以下内容

https://{请用你的用户名替换}.stackstorage.com/remote.php/webdav/ 用户名 密码

此时你卸载挂载后再重新挂载,是不用再输入用户名密码了,那么我们只要再开机的时候,运行一遍挂载代码便可以完成开机自动挂载了。但是,挂载TransIP较慢,可能会导致开机挂载失败。

3、开机自动挂载,编辑/etc/rc.local在最后面加上:

mount -t davfs https://{请用你的用户名替换}.stackstorage.com/remote.php/webdav /mnt/tip

重启你的VPS吧!重启之后,请务必多等片刻,因为挂载TransIP较慢

苏苏试了几次,开机挂载都失败了,都需要手动输入代码挂载

标签: 暂无
最后更新:2018年3月20日

letvps

这个人很懒,什么都没留下

打赏 点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

分类
  • 主机优惠
  • 其他
  • 域名优惠
  • 学习记录
  • 新手教程
  • 网赚项目
  • 脚本源码
  • 自用主机
  • 资源下载
书签
  • AdvinServers.com
  • 猫云云计算

COPYRIGHT © 2021 Letcloud.cn. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang

粤ICP备15031609号-3