Mount and umount

Disks and devices can’t be used without being mounted. They aren't allowed to be removed without being unmounted. Removing Floppy disks or Flashcards without un-mounting first will block the device. A option to remove such media is eject.Filesystems are mounted with the mount command and unmounted with the umount command.

cat /etc/mtab shows what file systems are mounted.

lsof /mnt/gentoo/boot/ shows the processes that access the directory.

fuser shows the user that blocks the device. This process can be killed to free the device.

fuser /dev/lirc/0 or fuser -m /dev/usbhd to see processes that have mounted the device

/dev/lirc/0: 20123

20123 is the PID of lircd daemon. To get it more verbose

fuser -v /dev/lirc/0 or kill the process kill -9<PID>

df –T shows file systems with there types

/etc/mtab contains actual loaded file system. cat /etc/mtab or mount without any arguments show what is mounted.

There are different ways to mount the file systems automatically. Since those ways can be used in parallel a directory should be mounted just by one way. As example a network filesystem that will be mounted using autoFS should not have entries in fstab.

bind mount

Mount mounts a filesystem (as a disk) under a directory (mounting point). Sometimes it is desired to mount just a directory of a filesystem under a mounting point.

After the bind mount both directories can be accessed and contain the same content

mount --bind /mnt/sda3/home/<username>/<userdir>/ /home/<username>/<userdir>

Bind mounts can also be done in /etc/fstab

/mnt/sda3/home/<username>/<userdir>/ /home/<username>/<userdir>    none    defaults,bind    0 0


A similar effect can be done with links symbolic and hardlinks.


The file/etc/fstab holds defaults for different filesystems and their mounting points and is heavily used during boot. An fstab entry could look as follows:

/dev/sdb1  /mnt/sdb1    ext2          user,exec         0 1

The columns show:

  1. the device file or alternatively UUID=<Universally Unique Identifier> or LABEL=<the string that you set with e.g. e2label <device> <label>>. blkid will print out the UUID and when the label.

  2. the mounting point

  3. the file system

  4. mounting options as the members of the user group can mount it and programs on the file systems are allowed to be executed. See man fstab and man mount

  5. tells if the file system need to be dumped

  6. configures how fsck is used on the file system after boot

The mount options of the storage device can also make use of its UUID or label in/etc/fstab instead of the /dev file).

The command mount -a mounts everything that is in the /etc/fstab file except what is marked with the option noauto. This command is usually launched during boot.


The kernel (of a client computer) can be configured to support auto mount CONFIG_AUTOFS4_FS. If an access to an unmounted file system is requested the kernel request the automounter to try to do the mount.


The automounter can just mount filesystems that are supported by the linux system. This means as example network file systems must be configured first and be working before automounter can mount them.

To get the automounter install on the client autofs and check it options (Gentoo Linux Use flags). There are two configuration files/etc/autofs/auto.master and/etc/autofs/auto.misc.

/etc/autofs/auto.master can hold a single line as

/mnt/auto   /etc/autofs/auto.misc  --timeout=15 --ghost

This defines that all mounting points are under /mnt/auto and are defined in the file/etc/autofs/auto.misc, that it will be tried to unmount it after 15 seconds of the last access and if it creates empty folders when access is not possible.

The/etc/autofs/auto.misc needs to be edited and holds the mounting points

cd              -fstype=iso9660,ro      :/dev/cdrom

Means that the mounting point is the combination of/etc/autofs/auto.master and/etc/auto/auto.misc and results in /mnt/auto/cd and it is a read only iso9660 filesystem using the device /dev/cdrom

A more practical example using a network drive (first make sure manual mount/umount works)

<mountdir>        -fstype=nfs,rw <computer name or ip>:/<path>


Do not create subdirectories under /mnt/auto autofs does this automatically

To start the daemon using OpenRC /etc/init.d/autofs start and rc-update add autofs default

Troubleshooting automounter

Disable automounter as for OpenRC /etc/init.d/autofs stop

Mount the drive manually using the mount command

mount -t nfs /mnt/media

If it can not be mounted manually then also automounter can not do it. So fix the problem with manual mounting.

Mount removable media

Based on plugin events the file systems are mounted. This is used for USB sticks CD/DVD.

Linurs startpage