Home

Managing Mount Points & Ghost Directories in Linux

Context: The Ghost Directory Problem

When moving source folders that are used as mount points (e.g., for Nextcloud backups), the system often recreates empty “stub” directories. This guide covers how to unmount, clean up, and prevent these folders from reappearing.

1. Immediate Cleanup (Manual)

If a directory is “stuck” or recreating itself, it is likely still defined as an active mount point in the kernel.

Unmount the Directory

Use the Lazy flag to detach the mount even if the system thinks it’s busy:

sudo umount -l /path/to/ghost_folder

Delete the Stub

Once unmounted, the folder is just an empty directory on your disk. Remove it:

rmdir /path/to/ghost_folder

2. Permanent Fix (Configuration)

The system recreates folders because a configuration file tells it to. You must update these locations.

Check /etc/fstab

This is the most common place for persistent mounts.

  1. Open the file: sudo nano /etc/fstab
  2. Comment out (add a #) or Update the lines pointing to the old moved folders.
  3. Refresh the system: sudo mount -a

Check for Systemd Mounts

If you are on a modern Linux/WSL setup, check for custom mount units:

Quick Reference Table

Command Action
mount | grep /path Find mounts for a specific path
sudo umount -l Lazy unmount (works when busy)
sudo umount -f Force unmount (use with caution)
lsblk List all block devices and their mount points
findmnt Show tree-style view of all mounts (recommended)

Key Takeaways

Tags: LinuxCliTroubleshootingNextcloud