織夢動漫網(wǎng)站模版深圳網(wǎng)頁搜索排名提升
Created by?Dave On 8Feb.2025
起因:
想下載 StableDiffusion,清理系統(tǒng)文件時把?i/o 搞到 100%,已經(jīng)刪除到 apt 緩存,還差 89MB,只能另想辦法。 在網(wǎng)上找能不能掛在?Google 網(wǎng)盤,百度網(wǎng)盤,或 One Driver 也行??戳丝次臋n,準備用 ?google-drive-ocamlfuse 工具實現(xiàn)在 Ubuntu 中加載谷歌網(wǎng)盤。
官方倉庫: GitHub - astrada/google-drive-ocamlfuse: FUSE filesystem over Google Drive
在 Ubuntu 上使用 Google Drive 網(wǎng)盤
我不保證這個軟件 google-drive-ocamlfuse 的安全性
1. 先添加源
sudo add-apt-repository ppa:alessandro-strada/ppa
2. 安裝?google-drive-ocamlfuseFUSE
sudo apt install google-drive-ocamlfuse
sudo apt install fuse
3.?授權(quán)訪問 Google Drive
這個過程有些復(fù)雜,需要在 Google 控制臺上操作,?訪問:https://console.cloud.google.com
本想介紹一下,但可以寫一篇文章,不但照下面一步步做,也能體會到。就不獻丑了。
1)創(chuàng)建一個項目,看圖中的箭頭
2)創(chuàng)建個項目:ggdrive?
名字隨便起,方便閱讀我用 ggdrive
3)創(chuàng)建可以操作網(wǎng)盤的 API
在控制臺搜索:?google drive
找到 Google Drive API
4)創(chuàng)建?API
點 ENABLE 進入界面
點右上角的 CREATE CREDENTAILS (創(chuàng)建證書)
要訪問自己的網(wǎng)盤,選 Application data
描述一下
選個角兒:
點“CONTINUE" 繼續(xù)操作
如果有分配,自己定義:
最后點 DONE 完成
5)在哪兒找到 API
6)Client ID
點擊后,展開高級設(shè)置,可以找到 Client ID
這個是我們需要的。
7)下載服務(wù)賬號密鑰
8)創(chuàng)建 KEY
選 JSON 格式
成功后如圖:
9)下載 .json 文件
在下載目錄中找?
10)使用 json 文件登錄
文件放到 Ubuntu:/root/scripts/ggdrive-key.json (發(fā)文時,已經(jīng)換位置)
google-drive-ocamlfuse -headless -serviceaccountpath /root/scripts/ggdrive-key.json /root/ggdrive
11)驗證
現(xiàn)在 Google Drive 已經(jīng)加載到 /root/ggdrive 目錄
4.?設(shè)置開機自動加載
1)創(chuàng)建配置文件
vi /etc/systemd/system/google-drive.service
2)文件內(nèi)容
我的 JSON 文件名:ggdrive-key.json ,用實際的替換。
[Unit]
Description=Google Drive FUSE mount
After=network-online.target
Wants=network-online.target[Service]
Type=simple
User=root
ExecStartPre=/bin/mkdir -p /root/ggdrive
ExecStart=/usr/bin/google-drive-ocamlfuse -d -o nonempty -serviceaccountpath /root/scripts/ggdrive-key.json /root/ggdrive
ExecStop=/bin/bash -c 'umount -l /root/ggdrive || true'
Restart=on-failure
RestartSec=30
TimeoutStopSec=20[Install]
WantedBy=multi-user.target
5. Google Drive 上配置文件權(quán)限
最好在網(wǎng)頁登錄,比較直觀。
在搜索框,填入上一步下載的?ggdrive-key.json 文件中記錄的?服務(wù)賬號(daven-jpn-srv@ggdrive-********t.com),并給它 "EDITOR" (修改)權(quán)限。
6. 獲取目錄 ID
最后幾步。? 在瀏覽器打開這個文件夾,獲得目錄 ID
7. 更新配置文件
完成這兩步(目錄ID,添加權(quán)限)后,就可以更新配置文件并重啟服務(wù)了
cat > ~/.gdfuse/default/config << EOF
service_account_credentials_path=/root/scripts/< 下載的 JSON 文件 >
root_folder=<目錄ID>
umask=0o022
EOF
8.?載入daemon、啟用新服務(wù)、開啟服務(wù)、查看服務(wù)
systemctl daemon-reload
systemctl enable google-drive
systemctl start google-drive
systemctl status google-drive
6. 驗證
網(wǎng)盤的目錄中已經(jīng)有另一個帳號上傳的文件。
缺點:
比較慢,太慢