畑乃おいも / Hatano Oimo
662 字
3 分鐘
Google cloud vm掛載storage
介紹
Google cloud vm 虛擬器掛載 storage,使用 BT 腳本下載至 storage,如此可以下載非常多的檔案不怕空間不夠,最近剛好看到玩了一下真的很實用,如果買一個 VPS 也可以這樣搞,掛載到 storage,storage 拿來當個人儲存硬碟價格滿便宜的,有興趣可以去 google storage 看看可以試算價格,介紹如何掛載 storage。
作業系統及工具
- ubuntu 16.04
- gcsfuse(在新分頁開啟)
- FileZilla(在新分頁開啟)
建立 storage
建立一個資料夾
資料名稱依個人喜好,Downloads
下載 storage 金鑰
保存好金鑰,等等需要上傳到伺服器。
將金鑰上傳至伺服器
使用 SSH 網頁版上傳檔案,你也可以使用 FTP,FTP 上傳權限可以看這篇
輸入 ls 確認有出現檔案。
建立資料夾
sudo mkdir /mnt/plextvdrivesudo mkdir /mnt/資料夾名稱改資料夾權限
sudo chmod -R 777 /mnt/plextvdrivesudo chmod -R 777 /mnt/資料夾名稱設定 gcsfuse
export GCSFUSE_REPO=gcsfuse-`lsb_release -c -s`echo "deb http://packages.cloud.google.com/apt $GCSFUSE_REPO main" | sudo tee /etc/apt/sources.list.d/gcsfuse.listcurl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -安裝 gcsfuse
sudo apt-get updatesudo apt-get install gcsfuse掛載設定
注意:金鑰 json 檔案名稱請改成你的金鑰 json
Bucket 名稱 也就是在 storage 建立所取的名稱
/mnt/plextvdrive 之前建立的資料夾位置
gcsfuse -o allow_other --gid 0 --uid 0 --file-mode 777 --dir-mode 777 --key-file /home/用戶名/causal-block-252001-c10b9c3c082e.json Bucket名稱 /mnt/plextvdrive輸入之後會有一個問題,將 user_allow_other 打開
打開 user_allow_other
sudo nano /etc/fuse.conf將#user_allow_other 的# 拿掉,儲存快捷鍵 Ctrl + x 按下 Y
再次執行 gcsfuse 命令
gcsfuse -o allow_other --gid 0 --uid 0 --file-mode 777 --dir-mode 777 --key-file /home/用戶名/causal-block-252001-c10b9c3c082e.json Bucket名稱 /mnt/plextvdrive
檢查是否有掛載成功
df -h成功掛載,並顯示空間有 1.0 P 相當於 1000TB。
設定掛載路徑
掛載路徑是在/mnt/plextvdrive,但是需要下載到 storage 的 Downloads 資料夾才是正確的位置,所以正確路徑為/mnt/plextvdrive/Downloads。
關機虛擬器之後再次開機掛載消失
只需要在執行一次掛載指令就可以掛載成功
gcsfuse -o allow_other --gid 0 --uid 0 --file-mode 777 --dir-mode 777 --key-file /home/用戶名/causal-block-252001-c10b9c3c082e.json Bucket名稱 /mnt/plextvdrive筆記指令
sudo apt-get updatesudo mkdir /mnt/nameofyourplexfoldersudo chmod -R 777 /mnt/nameofyourplexfolderexport GCSFUSE_REPO=gcsfuse-`lsb_release -c -s`echo "deb http://packages.cloud.google.com/apt $GCSFUSE_REPO main" | sudo tee /etc/apt/sources.list.d/gcsfuse.listcurl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -sudo apt-get updatesudo apt-get install gcsfusesudo nano /etc/fuse.confgcsfuse -o allow_other --gid 0 --uid 0 --file-mode 777 --dir-mode 777 --key-file /path_to_your_keyFile_that_you_just_uploaded.json nameOfYourBucket /path/to/mount參考資料:(在新分頁開啟)https://www.youtube.com/watch?v=OJlLPJ2WU-4(在新分頁開啟)
Google cloud vm掛載storage
https://aishuafei.com/posts/google-cloud-vm掛載storage/