How to Mount Cloud Storage Buckets Using Cloud Storage FUSE on Linux VMs in GCP
Mounting Google Cloud Storage (GCS) buckets on your Google Cloud Platform (GCP) Linux VMs can greatly simplify access to your data. By using Cloud Storage FUSE, you can mount GCS buckets as file systems, making them accessible like any other directory on your VM. This guide covers the installation and setup process for different Linux distributions.
For detailed installation instructions based on your Linux distribution, please refer to the official GCS FUSE installation guide.
Mounting GCS Buckets
Once you’ve installed Cloud Storage FUSE, follow these steps to mount your GCS bucket:
- Ensure you have the necessary authentication and storage access.
- Manually mount a GCS bucket to the VM:
sudo mkdir -p /gcsfuse
cd /gcsfuse
mkdir test
sudo gcsfuse --only-dir test <bucket-name> /gcsfuse
Troubleshooting
- Check Mounted File Systems:
mount
Check Logs for More Details:
journalctl | grep gcsfuse
Check FUSE Process:
ps aux | grep gcsfuse
Check Mount Information:
mount | grep gcsfuse
Setting Up Bucket Mount via System Service
- Create a directory to mount the bucket:
sudo mkdir -p /bucket/<local-directory>
2. Create the mount script:
sudo vi /etc/mount-gcsfuse.sh
Add the following content to the script:
#!/bin/bash
gcsfuse -o allow_other --only-dir=<bucket-folder-name> --uid=<uid> --gid=<gid> <bucket-name> /bucket/<local-directory>
3. Make the script executable:
sudo chmod +x /etc/mount-gcsfuse.sh
4. Create the systemd service file:
sudo vi /etc/systemd/system/gcsfuse-mount.service
Add the following content to the service file:
[Unit]
Description=Mount GCS Buckets using gcsfuse
Wants=network-online.target
After=network-online.target
[Service]
Type=oneshot
ExecStart=/etc/mount-gcsfuse.sh
User=root
Group=root
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
5. Reload systemd, enable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable gcsfuse-mount.service
sudo systemctl start gcsfuse-mount.service
sudo systemctl status gcsfuse-mount.service
Check the service logs:
sudo journalctl -u gcsfuse-mount.service -b
By following these steps, you can efficiently mount GCS buckets on your GCP Linux VMs using Cloud Storage FUSE, allowing seamless integration and access to your cloud storage directly from your VM.
If you found this post helpful, please give it a clap! Your support inspires me to share more valuable insights. If you have any topics in mind or questions you’d like me to address, feel free to reach out. Connect with me on LinkedIn through the bio. Thank you for reading!
Happy Learning and Growing! 🙂📚