You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Cloud Storage FUSE is an open-source adapter that allows you to mount Cloud Storage buckets as local file systems on Linux and macOS machines. It presents objects in a bucket as files and prefixes as directories, enabling applications that expect a POSIX file system interface to read from and write to Cloud Storage without modification.
FUSE (Filesystem in Userspace) is a Linux kernel module that allows non-privileged users to create file systems without editing kernel code. Cloud Storage FUSE (gcsfuse) uses this interface to translate file system operations (open, read, write, close) into Cloud Storage API calls.
| Feature | Detail |
|---|---|
| Protocol | Translates POSIX file operations to Cloud Storage REST API calls |
| Platform | Linux and macOS |
| Authentication | Uses Application Default Credentials or service account keys |
| Performance | Suitable for data analytics and batch processing; not for latency-sensitive applications |
| Consistency | Eventually consistent for some operations; not a replacement for a POSIX file system |
| Cost | Free to use; you pay only for the underlying Cloud Storage operations |
# Add the gcsfuse repository
export GCSFUSE_REPO=gcsfuse-\$(lsb_release -c -s)
echo "deb https://packages.cloud.google.com/apt \$GCSFUSE_REPO main" | \
sudo tee /etc/apt/sources.list.d/gcsfuse.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | \
sudo apt-key add -
# Install gcsfuse
sudo apt-get update
sudo apt-get install -y gcsfuse
sudo tee /etc/yum.repos.d/gcsfuse.repo > /dev/null <<EOF
[gcsfuse]
name=gcsfuse (packages.cloud.google.com)
baseurl=https://packages.cloud.google.com/yum/repos/gcsfuse-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=0
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOF
sudo yum install -y gcsfuse
# Create a mount point
mkdir -p /mnt/gcs-data
# Mount a bucket
gcsfuse my-data-bucket /mnt/gcs-data
# Verify
ls /mnt/gcs-data
df -h /mnt/gcs-data
# Mount read-only
gcsfuse --read-only my-data-bucket /mnt/gcs-data
# Mount a specific "directory" (prefix)
gcsfuse --only-dir=data/analytics my-data-bucket /mnt/gcs-data
# Mount with a specific service account key
gcsfuse --key-file=/path/to/key.json my-data-bucket /mnt/gcs-data
# Mount with file caching for better read performance
gcsfuse --file-cache-capacity-mb=1024 \
--file-cache-max-size-mb=100 \
my-data-bucket /mnt/gcs-data
# Mount with implicit directories (create directory objects automatically)
gcsfuse --implicit-dirs my-data-bucket /mnt/gcs-data
# Add to /etc/fstab for automatic mounting on boot
my-data-bucket /mnt/gcs-data gcsfuse rw,user,implicit_dirs,allow_other 0 0
# Unmount the bucket
fusermount -u /mnt/gcs-data
# Force unmount
fusermount -uz /mnt/gcs-data
Cloud Storage FUSE translates every file operation into an HTTP REST API call, which introduces latency. It is not a drop-in replacement for a local disk or NFS.
| Operation | Local Disk | FUSE |
|---|---|---|
| Metadata (stat, ls) | Microseconds | Tens of milliseconds |
| Small file read | Microseconds | Tens of milliseconds |
| Sequential large file read | Disk-speed | Network-speed (can be fast with caching) |
| Random read | Fast | Slow (each seek is an HTTP request) |
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.