COSFS工具如何開機自動掛載騰訊COS對象存儲


*注意記得將我的bucketname、my-mount-point等修改成自己的信息。

fstab模式

此模式適用於ubuntu14.04, CentOS6.5

在 /etc/fstab 文件中添加如下的內容

cosfs#example-1253972369 /mnt/cosfs fuse _netdev,allow_other,url=https://cos.ap-XXX .myqcloud.com,dbglevel=info

其中_netdev 選項使得網絡准備好后再執行掛載命令。

使用 /etc/fstab 設定 COSFS 開機自動掛載,但是執行 mount -a, 卻報錯 "wrong fs type, bad option,bad superblock on cosfs"?

該錯誤通常是由於您的機器上缺乏 fuse 庫所致,建議您執行下列命令安裝 fuse 庫:

sudo yum install fuse

 

自啟動腳本mount模式

此模式適用於CentOS

首先在/etc/init.d/目錄下建立文件cosfs

vi /etc/init.d/cosfs

i進入編輯模式,將以下代碼根據自己情況修改后拷貝進去

#! /bin/bash
#
# cosfs Automount Tencentyun COS Bucket in the specified direcotry.
# chkconfig: 2345 90 10
# description: Activates/Deactivates cosfs configured to start at boot time.

cosfs 1253972369:example  /mnt/cosfs -ourl=cos.ap-XXX.myqcloud.com -odbglevel=info -oallow_other

添加執行權限

chmod a+x /etc/init.d/cosfs

添加啟動腳本作為其他服務實現開機自啟動

chkconfig cosfs on

這樣就實現了開機自動掛載COS。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM