Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Remove a Mount in Linux: Safe unmounting explained

· 5 min read · Home Tech

In this article
  1. What a mount means in Linux
  2. How to unmount a filesystem
  3. Before removing a USB drive or disk
  4. When Linux says the mount is busy
  5. Mounts that return after reboot
  6. Unmounting versus deleting a mount point
  7. Frequently Asked Questions

To remove a mount in Linux, unmount the filesystem with umount, followed by its mount point or device name—for example, sudo umount /mnt/data. Do not simply delete the mount-point directory: unmounting detaches the filesystem, while deleting a directory is a different operation and can destroy data if the filesystem is still mounted.

What a mount means in Linux

Linux makes storage devices, network shares, and other filesystems available by attaching them to a directory in one unified directory tree. That attachment is a mount. A USB drive might appear at /media/alex/WORK, while an extra disk could be mounted at /mnt/data. The directory where it appears is called the mount point.

Unmounting removes that attachment from the directory tree. It does not normally erase the filesystem or its files; the device can be mounted again later. The word is spelled umount in the command, not “unmount,” for historical reasons. On many distributions, desktop file managers provide an equivalent Eject or Safely Remove option for removable drives.

How to unmount a filesystem

First identify the exact mount point. Use findmnt to inspect current mounts:

findmnt
findmnt /mnt/data

You can also list block devices and their mount points with lsblk:

lsblk -f

Then unmount by mount point, which is usually clearest:

sudo umount /mnt/data

You may instead specify the device shown by findmnt or lsblk, such as /dev/sdb1. Avoid guessing device names: they can change between boots or when devices are connected in a different order. If the command succeeds, it typically prints nothing. Check with findmnt /mnt/data or mount to confirm it is no longer mounted there.

Unmounting usually requires administrator privileges. Some desktop systems let the logged-in user unmount removable media through the file manager without using sudo. For a drive with multiple mounted partitions, unmount each mounted filesystem separately before disconnecting the device.

Before removing a USB drive or disk

Unmounting is important because Linux may delay writing cached data to storage. Pulling a drive out while it is mounted can leave writes incomplete and damage files or filesystem metadata. Before unmounting, save your work and close files on the device. Then run the command or use the desktop’s Eject option, and wait for confirmation before unplugging it.

  • Check that file copies and other transfers have finished.
  • Close terminals, file-manager windows, and applications that are using the mounted filesystem.
  • Unmount every relevant partition, not just one of several mounted partitions.
  • For a device that offers a separate power-off or safe-removal option, use it when appropriate after unmounting.

Do not use umount -f or umount -l as routine substitutes for a normal unmount. The force option is intended for particular situations, especially some unreachable network filesystems, and can have risks. A lazy unmount detaches the mount from the directory tree immediately but lets references to it persist until they are no longer busy; it does not guarantee that pending writes are safely finished before you unplug a physical drive.

When Linux says the mount is busy

A common error is “target is busy.” It means a process is still using the filesystem. A shell whose current directory is somewhere under the mount point is enough to cause this, as are open files, running applications, or a service working with the mounted data.

Find processes using the mount with tools such as fuser or lsof:

sudo fuser -vm /mnt/data
sudo lsof +f -- /mnt/data

Options and output vary slightly by system. Close the listed applications or files, and move any terminal out of the mounted directory—for example, run cd ~. Then try sudo umount /mnt/data again. Do not kill an unfamiliar process just to make the error disappear; determine what it is doing first, particularly on a server.

Mounts that return after reboot

If a filesystem is mounted again after restarting, it may be configured to mount automatically. The usual configuration file for persistent mounts is /etc/fstab. Inspect it before changing anything:

cat /etc/fstab

An entry there can mount a disk by UUID, a network share, or another filesystem during startup. Removing the active mount with umount does not remove this configuration, so the mount may return at the next boot. If you want to stop automatic mounting, carefully edit or comment out the relevant entry, using a reliable backup and checking that you have identified the correct line. A mistake in /etc/fstab can affect startup or other mounts. For removable drives managed by a desktop environment, automatic mounting may instead be controlled by desktop settings.

Unmounting versus deleting a mount point

Unmounting and removing a directory are not interchangeable. If /mnt/data is an empty directory that served as a mount point, you may remove it after unmounting with rmdir /mnt/data. The directory must be empty. There is usually no need to remove standard mount-point directories such as /mnt or directories created by a desktop environment.

Never use a recursive delete command on a mount point as a way to “remove the mount.” While the filesystem is mounted, commands such as rm -rf /mnt/data/* operate on the mounted filesystem’s contents. They can delete the actual files on the disk rather than detach it. If you only want the drive to disappear from the directory tree, use umount.

Frequently Asked Questions

What is the command to unmount a drive in Linux?
Use sudo umount /path/to/mount, replacing the example path with the actual mount point. You can find it with findmnt or lsblk -f.

Can I unmount a drive by its device name?
Yes. For example, sudo umount /dev/sdb1 can work if that device is mounted. Confirm the device and mount point first; the device name may not be stable across reboots or connections.

Does unmounting delete my files?
No. A normal unmount detaches the filesystem; it is not a formatting or deletion command. Files remain on the device unless you separately delete or overwrite them.

Why does umount say the target is busy?
A process is using the filesystem, perhaps through an open file or a terminal currently inside the mount. Close the relevant program or move out of the mounted directory, then retry.

Can I unplug a USB drive after running umount?
Once the unmount completes successfully, it is generally safe to disconnect the drive. If your desktop offers Eject or Safely Remove, use it and wait for its confirmation; never unplug during active writes.