All files in a Linux filesystem are arranged in form of a big tree rooted at ‘/‘.These files can be spread out on various devices based on your partition table, initially your parent directory is mounted(i.e attached) to this tree at ‘/‘, others can be mounted manually using GUI interface(if available) or using mount command.
mount command is used to mount the filesystem found on a device to big tree structure(Linux filesystem) rooted at ‘/‘. Conversely, another command umount can be used to detach these devices from the Tree.
mount -t type device dir
mount [-l|-h|-V] mount -a [-fFnrsvw] [-t fstype] [-O optlist] mount [-fnrsvw] [-o options] device|dir mount [-fnrsvw] [-t fstype] [-o options] device dir
These commands tells the Kernel to attach the filesystem found at device to the dir.
- If you leave the dir part of syntax it looks for a mount point in /etc/fstab.
- You can use –source or –target to avoid ambivalent interpretation.
mount --target /mountpoint
- /etc/fstab usually contains information about which device is need to be mounted where.
- Most of the devices are indicated by files like /dev/sda4, etc. But it can be different for certain filesystems. Please refer below for more information.
Note: It is important to note that we are only discussing the standard form of mount command given as syntax. Different forms are somewhat discussed because it has certain limitations on different kernels.
Some Important Options:
- l : Lists all the file systems mounted yet.
- h : Displays options for command.
- V : Displays the version information.
- a : Mounts all devices described at /etc/fstab.
- t : Type of filesystem device uses.
- T : Describes an alternative fstab file.
- r : Read-only mode mounted.
- Displays information about file systems mounted:
- Mounts file systems:
- Displays version information:
- Unmounts file systems: