How to Force Unmount an S3FS-FUSE Mount Point When “Device or Resource Busy” Error Occurs


20 views

When working with S3FS-FUSE mounts, you might encounter the frustrating "Device or resource busy" error when trying to unmount your S3 bucket. This typically happens when there are active processes accessing the mount point or when file handles haven't been properly released.

Before attempting a forced unmount, let's verify what's keeping the mount busy:


# Check for open files
lsof /mnt/s3

# Find processes using the mount point
fuser -vm /mnt/s3

# Alternative process check
ps aux | grep /mnt/s3

If you've confirmed no critical processes are using the mount, try these methods:


# Basic unmount attempt
fusermount -u /mnt/s3

# Force unmount with lazy option
fusermount -uz /mnt/s3

# Alternative system unmount
umount -l /mnt/s3

For stubborn mounts that refuse to unmount, you may need to terminate the FUSE process:


# Find the s3fs process
pgrep s3fs

# Kill it forcefully
sudo kill -9 [process_id]

# Then attempt unmount again
fusermount -u /mnt/s3

When remounting with specific permissions like mp_umask, ensure proper syntax:


s3fs mybucket /mnt/s3 -o mp_umask=0022,uid=1000,gid=1000

For persistent cases, examine the system logs:


journalctl -xe
dmesg | tail -20

When working with S3FS-FUSE mounts in Linux environments, you might encounter the frustrating "Device or resource busy" error when attempting to unmount. This typically occurs when processes are actively accessing files or when the mountpoint has open file descriptors.

Before attempting to force unmount, it's crucial to identify what's keeping the mount busy:

# Check for processes using the mountpoint
lsof +D /mnt/s3

# Alternative approach using fuser
fuser -vm /mnt/s3

Here are several methods to successfully unmount a busy S3FS-FUSE mount:

Method 1: Lazy Unmount

umount -l /mnt/s3

This detaches the filesystem immediately but performs cleanup when it's no longer busy.

Method 2: Force Unmount

fusermount -uz /mnt/s3

The -z option forces an unmount by terminating any active connections.

Method 3: Combined Approach

# First try normal unmount
fusermount -u /mnt/s3 || \
# Fall back to force unmount if needed
fusermount -uz /mnt/s3

If the above methods fail, consider these additional steps:

# Check for zombie processes
ps aux | grep s3fs

# Verify mount status
mount | grep s3fs

# Kill related processes (use cautiously)
pkill -f s3fs

To avoid unmount problems:

  • Always close all files and directories before unmounting
  • Consider using --nonempty mount option if needed
  • Implement proper cleanup in scripts with trap handlers

Here's how to properly unmount and remount with mp_umask:

# Force unmount existing mount
fusermount -uz /mnt/s3

# Remount with desired permissions
s3fs mybucket /mnt/s3 -o mp_umask=0022,allow_other