文章目录[隐藏]
为了上传文件方便一点,所以豆子偷空在vps上装了 rclone,并使用 rclone挂载google drive。为了查找方便,特记录一下步骤。
首先,
vps 需要安装 rclone。操作环境是 ubuntu 20.04,其他系统雷同。
apt install rclone -y
查看 rclone 版本:
rclone --version
显示:
rclone v1.50.2 - os/arch: linux/arm64 - go version: go1.13.8
接下来配置 rclone 挂载
输入:
rclone config
显示:
2023/12/25 09:15:24 NOTICE: Config file "/root/.config/rclone/rclone.conf" not found - using defaults No remotes found - make a new one n) New remote s) Set configuration password q) Quit config n/s/q>
输入 n,回车
然后输入配置的名字(需要英文输入),然后回车
显示:
Type of storage to configure. Enter a string value. Press Enter for the default (""). Choose a number from below, or type in your own value 1 / 1Fichier \ "fichier" 2 / Alias for an existing remote \ "alias" 3 / Amazon Drive \ "amazon cloud drive" 4 / Amazon S3 Compliant Storage Provider (AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, etc) \ "s3" 5 / Backblaze B2 \ "b2" 6 / Box \ "box" 7 / Cache a remote \ "cache" 8 / Citrix Sharefile \ "sharefile" 9 / Dropbox \ "dropbox" 10 / Encrypt/Decrypt a remote \ "crypt" 11 / FTP Connection \ "ftp" 12 / Google Cloud Storage (this is not Google Drive) \ "google cloud storage" 13 / Google Drive \ "drive" 14 / Google Photos \ "google photos" 15 / Hubic \ "hubic" 16 / JottaCloud \ "jottacloud" 17 / Koofr \ "koofr" 18 / Local Disk \ "local" 19 / Mail.ru Cloud \ "mailru" 20 / Microsoft Azure Blob Storage \ "azureblob" 21 / Microsoft OneDrive \ "onedrive" 22 / OpenDrive \ "opendrive" 23 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH) \ "swift" 24 / Pcloud \ "pcloud" 25 / Put.io \ "putio" 26 / SSH/SFTP Connection \ "sftp" 27 / Transparently chunk/split large files \ "chunker" 28 / Union merges the contents of several remotes \ "union" 29 / Webdav \ "webdav" 30 / Yandex Disk \ "yandex" 31 / http Connection \ "http" 32 / premiumize.me \ "premiumizeme"
输入你要挂载的类型,比如豆子挂载的是 google drive,这里就输入 13,然后回车
** See help for drive backend at: https://rclone.org/drive/ ** Google Application Client Id Setting your own is recommended. See https://rclone.org/drive/#making-your-own-client-id for how to create your own. If you leave this blank, it will use an internal key which is low performance. Enter a string value. Press Enter for the default (""). client_id> ##这里输入 client_id,不知道的可以自行 google 然后回车 Google Application Client Secret Setting your own is recommended. Enter a string value. Press Enter for the default (""). client_secret> ## 这里输入密钥,然后回车 Scope that rclone should use when requesting access from drive. Enter a string value. Press Enter for the default (""). ##这里直接回车
然后让你选择权限:
Choose a number from below, or type in your own value 1 / Full access all files, excluding Application Data Folder. \ "drive" 2 / Read-only access to file metadata and file contents. \ "drive.readonly" / Access to files created by rclone only. 3 | These are visible in the drive website. | File authorization is revoked when the user deauthorizes the app. \ "drive.file" / Allows read and write access to the Application Data folder. 4 | This is not visible in the drive website. \ "drive.appfolder" / Allows read-only access to file metadata but 5 | does not allow any access to read or download file content. \ "drive.metadata.readonly" scope>
这里豆子输入的全部权限,也就是 1,然后回车
接着,需要选择挂载硬盘的路径,如果是全盘挂载,那么直接回车,但是豆子是挂载的指定文件夹,所以需要输入 folder 的 id
ID of the root folder Leave blank normally. Fill in to access "Computers" folders (see docs), or for rclone to use a non root folder as its starting point. Note that if this is blank, the first time rclone runs it will fill it in with the ID of the root folder. Enter a string value. Press Enter for the default (""). root_folder_id> ##输入文件夹的 id 后,回车
接着提示是否进行高级配置,这里豆子选 n,然后回车
然后询问是否自动配置,照样选 n,然后回车
Service Account Credentials JSON file path Leave blank normally. Needed only if you want use SA instead of interactive login. Enter a string value. Press Enter for the default (""). service_account_file> Edit advanced config? (y/n) y) Yes n) No y/n> n Remote config Use auto config? * Say Y if not sure * Say N if you are working on a remote or headless machine y) Yes n) No y/n> n
然后会返回一个网址,复制出来,在浏览器中打开,然后授权,会给你一个授权密钥,复制密钥后,返回到 ssh 界面,然后粘贴进去,回车。
然后会询问是否团队协作盘,这里豆子的并非是团队盘,所以选 n,回车。
Configure this as a team drive? y) Yes n) No y/n> n
然后会返回一大堆刚才的配置,接着询问是否完成等等
y) Yes this is OK e) Edit this remote d) Delete this remote y/e/d> y Current remotes: Name Type ==== ==== XXX drive e) Edit existing remote n) New remote d) Delete remote r) Rename remote c) Copy remote s) Set configuration password q) Quit config e/n/d/r/c/s/q> q
到这一步,rclone 配置完成,现在使用命令进行挂载到 vps 上。
创建挂载目录,并进行挂载:
mkdir -p /opt/gd rclone mount XXX: /opt/gd --allow-other --allow-non-empty --vfs-cache-mode writes --daemon
其中opt/gd路径,是可以自己选择自己想要的路径。到这里,就基本完成,如果你vps装的有面板,那么重启一下面板就可以看到你挂载的硬盘已经展示出来了。