Ubuntu 18.04.5 挂载阿里云OSS作为本地磁盘

1.挂载命令:

wget http://gosspublic.alicdn.com/ossfs/ossfs_1.80.5_ubuntu16.04_amd64.deb
sudo apt-get update
sudo apt-get install gdebi-core
sudo gdebi ossfs_1.80.5_ubuntu16.04_amd64.deb
echo bj-xxxxxx-01:xxxxfRCuDPGtsPQxxxx:y1YdxxxxxxcbipMr0RYaxxxxxw > /etc/passwd-ossfs
chmod 640 /etc/passwd-ossfs
mkdir /myoss
ossfs bj-xxxxxx-01 /myoss -ourl=http://oss-cn-beijing-internal.aliyuncs.com

2.卸载命令:

fusermount -u /myoss

3.开机自动挂载OSS:

检查系统目录/lib/systemd/system/rc-local.service,如果没有自己新建,文件内容为(如果文件存在本身是没有[Install]项的,需要自己添加进去)

[Unit]
Description=/etc/rc.local Compatibility
Documentation=man:systemd-rc-local-generator(8)
ConditionFileIsExecutable=/etc/rc.local
After=network.target
 
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
RemainAfterExit=yes
GuessMainPID=no
 
####  需要自己添加
[Install]
WantedBy=multi-user.target
Alias=rc-local.service

4.创建/etc/rc.local脚本文件,并写入想要运行的脚本程序

#! /bin/bash
echo 'ossfs bj-xxxxxx-01 /myoss -ourl=http://oss-cn-beijing-internal.aliyuncs.com' >> /etc/rc.local
sudo chmod +x /etc/rc.local
sudo systemctl enable rc-local
sudo systemctl start rc-local.service
sudo systemctl status rc-local.service

5.验证重启

sudo reboot

Comments

发表评论

邮箱地址不会被公开。 必填项已用*标注