endmntent - Linux


Overview

The endmntent command is used to complete the process of unmounting a filesystem from the Linux kernel. It is typically used in conjunction with the mntent utility to manage entries in the /etc/mtab file, which maintains a list of mounted filesystems and their mount points.

Syntax

endmntent [-v] mtab -

Options/Flags

  • -v: Verbose mode. Prints additional debug information during execution.

Examples

Simple usage:

endmntent /etc/mtab -

This will unmount all filesystems listed in the /etc/mtab file.

Complex usage:

mntent /etc/mtab -I -A -u -t proc -

This command will remove all proc filesystems from the /etc/mtab file and unmount them.

Common Issues

Permission denied:

If you encounter a permission denied error, ensure that you are running the command as the root user or with sudo privileges.

Filesystem busy:

If you receive a message that the filesystem is busy and cannot be unmounted, try closing all applications that may be accessing the filesystem. You may also need to force unmount the filesystem using the -f flag with the umount command.

Integration

endmntent is commonly used in scripts and systemd units to manage mounted filesystems during system startup and shutdown.

Related Commands

  • mntent: Manages entries in the /etc/mtab file.
  • umount: Unmounts a filesystem from the kernel.