0

I maintain a ubuntu 20.04 LTS headless server and I can manually mount the B2 bucket using fuse s3fs for backup.

How to add a line to fstab to automatically mount the B2 bucket at powerup?

I know that altering fstab can be tricky. The mount script I have obtained from Backblaze FAQ:

sudo s3fs \
     mybucket \
     /path/to/mountpoint \
     -o passwd_file=/etc/passwd-s3fs \
     -o url=https://s3.your-region.backblazeb2.com

1 Answers1

0

The fstab entry format is documented on the s3fs Readme:

mybucket /path/to/mountpoint fuse.s3fs allow_other,use_path_request_style,url=https://s3.your-region.backblazeb2.com,passwd_file=/etc/passwd-s3fs 0 0

Note: it's probably not a great idea to do this as an /etc/fstab entry. Why? because you need network to be up before you can mount it, but it could happen that /etc/fstab to be read first, before you have network! (You can add _netdev to the mount options, but I don't know whether Ubuntu20.04 honors that – ran into trouble with it).

Instead, you should just have a systemd .mount unit. That can say "hey, I depend on network connectivity!", and the mounting can then be done automatically when your network works. (Also, you can then also do an .automount, where the mounting happens not as soon as network is available, but as soon as you try to access your /path/to/mountpoint, but that's another story).

I explain how you do that in this answer, but for SSHfs. It's practically identical for s3fs, just replace every occurence of sshfs with s3fs and set What=mybucket. The file name is important! It must be formed according to the mountpoint (see the linked answer):

/etc/systemd/system/path-to-mountpoint.mount:

[Unit]
Description=Backblaze mount
Requires=network-online.target

[Mount] What=mybucket Where=/path/to/mountpoint. Type=fuse.s3fs Options=allow_other,use_path_request_style,url=https://s3.your-region.backblazeb2.com,passwd_file=/etc/passwd-s3fs

Then you can just activate the mount, and it will come up at every boot:

 systemctl enable --now path-to-mountpoint.mount

(leave out the --now if you want to wait until reboot to mount.)