How to mount Blob storage as a file system with blobfuse
Blobfuse is a virtual file system driver for Azure Blob storage. Blobfuse allows you to access your existing block blob data in your storage account through the Linux file system. Blobfuse uses the virtual directory scheme with the forward-slash '/' as a delimiter.
This guide shows you how to use blobfuse, and mount a Blob storage container on Linux and access data. To learn more about blobfuse, read the details in the blobfuse repository.
Blobfuse doesn't guarantee 100% POSIX compliance as it simply translates requests into Blob REST APIs. For example, rename operations are atomic in POSIX, but not in blobfuse. For a full list of differences between a native file system and blobfuse, visit the blobfuse source code repository.
Install blobfuse on Linux
Blobfuse binaries are available on the Microsoft software repositories for Linux for Ubuntu and RHEL distributions. To install blobfuse on those distributions, configure one of the repositories from the list. You can also build the binaries from source code following the Azure Storage installation steps if there are no binaries available for your distribution.
Blobfuse supports installation on Ubuntu 14.04, 16.04, and 18.04. Run this command to make sure that you have one of those versions deployed:
Configure the Microsoft package repository
Configure the Linux Package Repository for Microsoft Products.
As an example, on an Enterprise Linux 6 distribution:
sudo rpm -Uvh https://packages.microsoft.com/config/rhel/6/packages-microsoft-prod.rpm
Similarly, change the URL to
.../rhel/7/... to point to an Enterprise Linux 7 distribution.
Another example on an Ubuntu 14.04 distribution:
wget https://packages.microsoft.com/config/ubuntu/14.04/packages-microsoft-prod.deb sudo dpkg -i packages-microsoft-prod.deb sudo apt-get update
Similarly, change the URL to
.../ubuntu/18.04/... to reference another Ubuntu version.
On an Ubuntu/Debian distribution:
sudo apt-get install blobfuse
On an Enterprise Linux distribution:
sudo yum install blobfuse
Prepare for mounting
Blobfuse provides native-like performance by requiring a temporary path in the file system to buffer and cache any open files. For this temporary path, choose the most performant disk, or use a ramdisk for best performance.
Blobfuse stores all open file contents in the temporary path. Make sure to have enough space to accommodate all open files.
(Optional) Use a ramdisk for the temporary path
The following example creates a ramdisk of 16 GB and a directory for blobfuse. Choose the size based on your needs. This ramdisk allows blobfuse to open files up to 16 GB in size.
sudo mount -t tmpfs -o size=16g tmpfs /mnt/ramdisk sudo mkdir /mnt/ramdisk/blobfusetmp sudo chown <youruser> /mnt/ramdisk/blobfusetmp
Use an SSD as a temporary path
In Azure, you may use the ephemeral disks (SSD) available on your VMs to provide a low-latency buffer for blobfuse. In Ubuntu distributions, this ephemeral disk is mounted on '/mnt'. In Red Hat and CentOS distributions, the disk is mounted on '/mnt/resource/'.
Make sure your user has access to the temporary path:
sudo mkdir /mnt/resource/blobfusetmp -p sudo chown <youruser> /mnt/resource/blobfusetmp
Configure your storage account credentials
Blobfuse requires your credentials to be stored in a text file in the following format:
accountName myaccount accountKey storageaccesskey containerName mycontainer
accountName is the prefix for your storage account - not the full URL.
Create this file using:
Once you've created and edited this file, make sure to restrict access so no other users can read it.
chmod 600 fuse_connection.cfg
If you have created the configuration file on Windows, make sure to run
dos2unix to sanitize and convert the file to Unix format.
Create an empty directory for mounting
For a full list of mount options, check the blobfuse repository.
To mount blobfuse, run the following command with your user. This command mounts the container specified in '/path/to/fuse_connection.cfg' onto the location '/mycontainer'.
sudo blobfuse ~/mycontainer --tmp-path=/mnt/resource/blobfusetmp --config-file=/path/to/fuse_connection.cfg -o attr_timeout=240 -o entry_timeout=240 -o negative_timeout=120
You should now have access to your block blobs through the regular file system APIs. The user who mounts the directory is the only person who can access it, by default, which secures the access. To allow access to all users, you can mount via the option
cd ~/mycontainer mkdir test echo "hello world" > test/blob.txt
Učitavanje povratnih informacija...