CentOS7使用GCSF挂载Google Drive到本地目录
本文最后更新于 1824 天前,其中的信息可能已经有所发展或是发生改变。

网上挂载Google Drive一般都是使用rclone,但这个方法有许多局限性(比如使用filerun无法识别),于是我就找到了一个它的替代方案:GCSF,据说比google-drive-ocamlfuse快4-7倍。这里就说一下在CentOS7下如何安装GCSF来挂载Google Drive到本地目录。

GCSF项目地址:https://github.com/harababurel/gcsf

安装GCSF

安装依赖
yum install cargo fuse-devel openssl-devel pkg-config -y
安装GCSF
cargo install gcsf
设置环境变量
cat >> ~/.bash_profile <<EOF
export PATH="$HOME/.cargo/bin:$PATH"
EOF
source ~/.bash_profile

GCSF的使用

授权挂载
更改GCSF授权方式
sed -i 's/authorize_using_code = false/authorize_using_code = true/g' $HOME/.config/gcsf/gcsf.toml
登录Google Drive并授权
gcsf login ito

使用本命令创建一个名为ito的会话,终端提示如下:

Please direct your browser to https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/drive&redirect_uri=[...], follow the instructions and enter the code displayed here:

复制https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/drive&redirect_uri=[...]字段,到能访问谷歌的浏览器上登陆谷歌账户并授权,你将得到一段代码,将这段代码复制到终端回车就可以了。我们可以用gcsf list这条命令查看授权是否成功

挂载测试
mkdir /mnt/gcsf
gcsf mount /mnt/gcsf -s ito

创建/mnt/gcsf这个文件夹进行挂载测试,挂载后访问该文件夹查看是否挂载成功,验证后可以用fusermount -u /mnt/gcsf卸载Google Drive

设置自启动

测试可以成功挂载Google Drive后,我们可以设置开机自动挂载。将下面代码中ExecStartExecStop字段中的命令做相对应的修改后直接放在终端运行就可以了开机启动了(如果授权时都是完全按照上面命令没有修改的可以直接复制运行)

cat >> /usr/lib/systemd/system/gcsf.service  <<EOF
[Unit]
Description=GCSF
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target

[Service]
GuessMainPID=yes
ExecStart=/root/.cargo/bin/gcsf mount /mnt/gcsf -s ito
ExecStop=/usr/bin/fusermount -u /mnt/gcsf
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
EOF

systemctl start gcsf
systemctl enable gcsf

其他

教程写下时用到的环境信息
主程序 /root/.cargo/bin/gcsf
主配置文件 /root/.config/gcsf/gcsf.toml
服务脚本 /usr/lib/systemd/system/gcsf.service
版本号 0.1.25
GCSF相关命令
gcsf help Prints this message or the help of the given subcommand(s)
gcsf list List sessions.
gcsf login Login to Drive (create a new session).
gcsf logout Logout (delete a given session).
gcsf mount Mount the file system.
暂无评论

发送评论 编辑评论


|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇