Select Page

How to Mount a B2 Bucket on Linux

The Short Answer:

Setup rclone using rclone config then use the mount command rclone mount remote:bucket/folder/file

The Long Answer Mixed With Personal Experience:

This is a little bit embarrassing, but I’ve been using Backblaze for years at this point and I’ve only mounted my first B2 bucket just now. I have no idea why it’s taken me so long, and I just sort of stumbled across the solution as I was making manual backups to some folders and my mind was blown.

As you may (or may not) already know, Backblaze B2 has a somewhat limited number of options when it comes to interfacing with your files on Linux. At the time of this writing, Backblaze lists just 3 options for essentially using their B2 service on Linux. I’ve only tried Rclone, and over the last few years it’s been fine.

After taking a few minutes to familiarize myself with the docs, I was able to easily set up my B2 bucket. Once I had it set up, I used it as an extremely simple way to just upload large files. It should be noted that also, at the time of this writing, B2’s web interface limits uploads to around 200MB. Anything larger requires you to connect to the server directly via some supported application.

At the beginning, I was just excited to get something to work. After setting up my B2 bucket, I was able to upload and download files and folders using the [bash]rclone copy[/bash] command. And that worked for a bit. Then one day I ran into an issue where I was looking for a specific photo I’d backed up. I knew I’d backed it up, but I didn’t have a way to really search for it especially since it was named something like IMG_0023523.jpg or whatever. And technically, yes, you can preview image files on their web interface, but it is wildly impractical. So that was the first issue I ran into with my limited knowledge of Rclone.

At the time, I also didn’t have a practical way of automating backups to run in the background. It was just up to me to decided whenever I had time to figure out which folders I wanted to backup and figure out where I wanted to save them by either memorizing the exact file path on the B2 bucket, or finding it using rclone lsd remote:bucket to list all directories in a given filepath. Still not very usable or practical. So far, it had been working for folder manual backups and for client file deliveries.

However, just this week, I ran into some issues with my computer which caused the POST to fail, so when I hit the power button to boot up, the lights would come on, and the fans would start spinning, but the screen just stayed black. Absolutely scary considering my terrible backup solution. Ended up fixing the issue and got the machine to boot, but now I’m taking this opportunity to back up everything.

So of course, I went at it using the only way I knew at the time: rclone copy path/to/local/folder/ remote:bucket/folder. And off it went. It’s a sizable backup, and it will take a while, and that’s fine. I was looking around Backblaze’s newly redesigned site and I don’t even know how or what I was looking for, but I came across this mysterious rclone mount command. My mind is will be forever blown and all my issues of previewing image files and scheduling backups will now be a distant memory.

Once you’ve set up and configured Rclone, you’ll need to create an empty folder to mount your B2 bucket inside of. I’ve already got several internal storage drives mounted at /mnt/. Yours may be mounted elsewhere, but I think that’s a pretty standard mount location. Once you’ve created your folder, you’ll want to confirm it has the correct permissions to work with rclone mount.

[bash]sudo mkdir /mnt/MyB2MountPoint[/bash] and then [bash]ls -l /mnt/[/bash]. The -l flag will display all the read/write/execute permissions as well as ownership of the files and folders targeted with ls. If you created your mountpoint folder using sudo like I did, there’s a hot chance that owner of your newly created mount directory will be root. Depending on how you’ve set up your permissions, this may or may not work. In my case, it didn’t.

To fix this, I simply changed folder ownership to my username. chown username /mnt/MyB2MountPoint. After I’d done that, I was able to run rclone mount remote:bucket/folder /mnt/MyB2MountPoint. Just keep in mind, this command was run in the foreground (running in the foreground is the default) which means as soon as that terminal window is closed, or the program is killed with CTRL+C or receiving a SIGINT or SIGTERM signal, the mount should be automatically stopped.

If you prefer, you can mount your B2 drive in the background with rclone mount remote:bucket/folder /mnt/MyB2MountPoint --daemon. If you do this, in order to unmount, you’ll have to do so manually using fusermount -u /path/to/local/mount.

Check out more articles

How to Generate a Ranger Config File

ranger --copy-config=all This will copy all the default config files from /usr/local/lib so you can make edits without messing anything up. Huge shout out to https://dquinton.github.io/debian-install/config/ranger.html for explaining this and so much more. Took me a...

First Open Source Contribution

Surprise! I genuinely did not plan on making my first ever open source contribution today. In fact, I didn't plan on a lot of things happening this week at all. I recently got an awesome opportunity to work on a site that is being hosted on a platform called Pantheon,...

How to Exclude Specific Posts and Pages from WP_QUERY

For the sake of having something to work with, let's suppose we've got the following query:In this query, inside the $args array, there's a special parameter that allows you to exclude specific posts and pages from the query. This parameter is called post__not_in and...

Configure SSH For Password-less Connections

Preamble I'm slightly embarrassed to admit this, but it was a long time before I figured out how amazing this little file is and how exactly to put it to good use. The file I'm talking about is the SSH config file. By default, when you first connect to a server via...

WordPress Site Stuck in Maintenance Mode

Plugin Error Code 500 During Update While I was updating a WordPress plugin locally, something happened on my local server to trigger a 500 error code as the plugin was updating. On the frontend, I refreshed the page and was greeted with "Briefly Unavailable for...

Creating a WordPress Plugin Downloader

How it Started I was recently tasked with the challenge of creating a WordPress theme generator. The idea being, instead of writing your style.css file from scratch, you'd be able to just answer a few simple questions about how you'd like your theme set up, and those...

Fix Audio on XFCE Chromebook

The Problem After moving from GalliumOS to Xubuntu, I noticed that playing YouTube videos on both Firefox and Chromium would result in decent playback for a few minutes, but suddenly the audio would turn into a solid beeping tone while the YouTube video displayed the...

Adjust Trackpad Sensitivity XFCE

xinput set-prop "Elan Touchpad" "Synaptics Finger" 1 1 1 What are the values 1 1 1? This sets the sensitivity as close to the original ChromeOS as possible. Larger numbers will decrease sensitivity of various aspects. I never looked into which individual value...

Fireworks (Short Film)

https://vimeo.com/395077249 About the film Year: 2020 Director/DP: Tim Searfoss Writers: Matt Jones, Tim Searfoss Sound Mix: Matt Jones

Hosting Multiple Sites Using LocalWP

I've done a write-up on hosting local WordPress sites before, but I definitely prefer this method over the previous one. If you've never tried hosting multiple sites using LocalWP, then I'd encourage you to check it out. I've had really bad issues with it in the past,...