DEV Community

Cover image for Mount a Azure Blob storage container on Linux with blobfuse.
Surya Shankar
Surya Shankar

Posted on • Updated on

Mount a Azure Blob storage container on Linux 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.

Follow This Link

https://docs.microsoft.com/en-us/azure/storage/blobs/storage-how-to-mount-container-linux
Enter fullscreen mode Exit fullscreen mode

Install blobfuse on Linux

sudo rpm -Uvh https://packages.microsoft.com/config/centos/8/packages-microsoft-prod.rpm
Enter fullscreen mode Exit fullscreen mode

Similarly, change the URL to .../ubuntu/16.04/... or .../ubuntu/18.04/... to reference another Ubuntu version.

Image description

Install blobfuse

On an Enterprise Linux distribution:

sudo yum install blobfuse
Enter fullscreen mode Exit fullscreen mode

(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 mkdir /mnt/ramdisk
Enter fullscreen mode Exit fullscreen mode
sudo mount -t tmpfs -o size=16g tmpfs /mnt/ramdisk
Enter fullscreen mode Exit fullscreen mode
sudo mkdir /mnt/ramdisk/blobfusetmp
Enter fullscreen mode Exit fullscreen mode

Image description

Authorize access to your storage account

For example, suppose you are authorizing with the account access keys and storing them in a config file. The config file should have the following format:

accountName myaccount
accountKey storageaccesskey
containerName mycontainer

Image description

Image description

Create this file using:

touch /path/to/fuse_connection.cfg
Enter fullscreen mode Exit fullscreen mode

Once you've created and edited this file, make sure to restrict access so no other users can read it.

chmod 600 /path/to/fuse_connection.cfg
Enter fullscreen mode Exit fullscreen mode

Image description

Create an empty directory for mounting

mkdir /mycontainer
Enter fullscreen mode Exit fullscreen mode

Image description

Mount

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'.

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
Enter fullscreen mode Exit fullscreen mode

Image description
Image description

Now you permanently mount it using this:

inside vi /etc/fstab
Enter fullscreen mode Exit fullscreen mode

paste the following path shown below as per your naming.

Image description

After rebooting You can see the container mounted too

Image description

Top comments (0)