Total Pageviews

Friday 29 December 2017

利用curlftpfs挂载ftp,解决存储空间不足问题

虚拟空间大部分只提供 ftp 连接, 也有一部分提供 sftp 连接, 于是在想要是有一个这类空间把 ftp 挂载到自己的 vps 上就好了, 后来查阅资料发现了 curlftpfs 这个东西, 通过百度得到的资料也是千篇一律的 copy, 去 google 搜索了下找到了项目地址和几篇安装的文章, 自己在 centos6.X 上安装成功, 成功挂载了 byet.org分销的免费空间, 于是便将方法分享出来.
 1. 首先需要找一个空间, 这里使用 by 分销的免费空间, 网上随便一搜就能找到, 很好申请, 但是 by 分销限制单个文件大小和文件数量, 传大文件会自动删除, 不建议使用.

 2. 安装依赖和下载 / 解压 / 编译 / 安装 这就不细讲了, 各软件编译几乎一个样 依赖是直接 copy 过来的 centos 的, ubuntu/debian 用户可以自己查找对应依赖的名称进行安装.
yum install glib2-devel
yum install fuse-devel
yum install libcurl-devel -y
wget http://nchc.dl.sourceforge.net/project/curlftpfs/curlftpfs/0.9.2/curlftpfs-0.9.2.tar.gz
tar zxvf curlftpfs-0.9.2.tar.gz
cd curlftpfs-0.9.2
./configure
make && make install

3. 挂载 ftp
先创建个文件夹用于挂载mkdir /mnt/fsda1,然后运行命令:
curlftpfs -o rw,allow_other,uid=0,gid=0 ftp://user:passwd@host /mnt/fsda1即可.
这里主要说下创建完文件夹最好将文件夹先设置下权限, 神经大条直接 777 即可, 不放心的根据自己需要设置权限, 挂载命令中的 uid 和 gid 根据自己账户改, 查看这俩 id 的方法网上一搜一大片, 上面的语句是为了方便其它用户访问, 如果只需要当前用户访问直接:
curlftpfs -o ftp://user:passwd@host /mnt/fsda1即可.
----------

Linux VPS通过安装CurlFtpFS来挂载FTP,可用来备份文件

说明:关于VPS挂载网盘的方法,现在再说个挂载FTP的方法,就是通过安装CurlFtpFS来挂载FTP,不仅可以增加VPS空间,还可以进行文件备份,关键是可以挂载虚拟主机的FTP空间,这是很不错的,毕竟虚拟主机便宜,而且出现数据丢失的情况也是很小的。

安装

系统要求:DebianUbuntuCentOS
1、安装CurlFtpFS
#CentOS系统
yum -y install epel-release
yum -y install curlftpfs

#Debian/Ubuntu系统
apt-get install curlftpfs -y
2、挂载FTP
#创建目录,路径及名称自己定
mkdir /home/ftp
#挂载FTP
curlftpfs ftp.yourserver.com /home/ftp -o user=username:password
参数说明:
ftp.yourserver.com  #FTP地址
/home/ftp  #本地目录
username  #FTP用户名
password  #FTP密码
3、检查
输入df -h命令查看下是否挂载成功。

最后可以将文件上传至本地文件夹/home/ftp进行备份了。
如果在挂载的时候出现如下错误:
fuse: mountpoint is not empty
fuse: if you are sure this is safe, use the 'nonempty' mount option
最简单的解决方法就是让挂载的本地目录变成空文件夹即可.
----------

CurlFtpFS (简体中文)

Packages

有不少软件可以挂载FTP,你可以将FTP挂载到某个目录下,然后就像本地文件系统一样操作。
  • curlftpfs [推荐]
  • fuseftp
  • lufs [过时了]
这三个都是基于FUSE库。

curlftpfs

安装
# pacman -S curlftpfs
有必要的话,加载fuse内核模块
# modprobe fuse
有必要的话,创建一个挂载点。
# mkdir /mnt/ftp
# curlftpfs ftp.yourserver.com /mnt/ftp/ -o user=username:password
如果你想让其他用户访问,用以下命令。
# curlftpfs ftp.yourserver.com /mnt/ftp/ -o user=username:password,allow_other
不要添加额外的空格或逗号,否则 allow_other 参数可能无法被程序识别.
如果要使用FTP的 active mode 挂载,请添加 'ftp_port=-':
# curlftpfs ftp.yourserver.com /mnt/ftp/ -o user=username:password,allow_other,ftp_port=-
你也可以把这一行加入 /etc/fstab 来自动在开机时后挂载。
curlftpfs#USER:PASSWORD@ftp.domain.org /mnt/mydomainorg fuse auto,user,uid=1000,allow_other 0 0
译者注,似乎这样用也是可以到。
sudo curlftpfs -o rw,allow_other ftp://username:password@ftp.yourserver.com /mnt/ftp
如果中文出现乱码,你可能需要指定编码:
sudo curlftpfs -o codepage=gbk -o rw,allow_other ftp://username:password@ftp.yourserver.com /mnt/ftp 
 
 from  https://wiki.archlinux.org/index.php/CurlFtpFS_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)

 

 

No comments:

Post a Comment