Linux starts through one large file system with the root directory (/) on the top, that does not necessarily reside on a single storage device. The Linux mount command integrates multiple storage devices into the tree-like hierarchy or directory structure. The deeper directories accessed using the forward slash like /var/log sequentially using paths.
Linux supports various storage formats like EXT3, EXT4, BTRFS, XFS having their metadata structure to define, how to store and access data. The Linux virtual file system enables to access all types of file systems using specific device drivers. Further, the device driver interprets the standard set of file system commands to ones specific to the file system on the partition or logical volume.
/ (root filesystem)
It is the top-level directory and contains all the required executables and library files required to boot the Linux system before other file systems are mounted.
After the system is booted, all other file systems mounted on standard, defined mount points as sub-directories of the root file system.
- /lib – contains shared library files required to boot the system
- /bin – contains user-executable files
- /sbin – system binary executables files used for system administration
- /boot – contains the static bootloader and kernel executable and configuration files required to boot a Linux computer
- /dev – contains the device files for every hardware device attached to the system to facilitate access to those devices
- /opt – contains optional files such as vendor-supplied application programs
- /var – stores variable data files like log files, MySQL, and other database files, web server data files, email inboxes, and much more
- /usr – contains shareable, read-only files, which include executable binaries and libraries, man files, and other types of documentation
- /etc – contains the local system configuration files for the host computer
- /tmp Temporary directory used by the operating system and many programs to store temporary files. It is safe to delete the content of this directory, hence advised not to use it to store relevant data
- /home The directory storage for user files. Each user has a sub-directory in it.
- /root – home directory for the root user, not to be confused with the root (/) file system
- /media – A place to mount external removable media devices such as USB thumb drives to connect them to the host
- /mnt – A temporary mount point for regular filesystems used by the administrators for repairing or working on a filesystem
Mounting of filesystems during the startup process is managed by the /etc/fstab configuration file.
fstab – file system table is a list of filesystems that are to be mounted, with their designated mount points, and any options that might require for specific filesystems.
mount /dev/sdb1 /mnt
where /dev/sdb1 is the device and /mnt is the directory where to mount it. Any directory used as a mount point should be empty although Linux does not prevent users from mounting one file system over one that is already there or on a directory that contains files. But, the original contents will get hidden, and only the content of the newly mounted file system will be visible.
sd – storage device
a – first disk
b – second disk
sda1 – first disk, first partition
sdb1 – second disk, first partition
Mount the cdrom to /media/cdrom
mount /dev/cdrom /media/cdrom
You can mount a partition or logical volume formatted with a specific type of filesystem with that specified mount point only on a Linux file system.
Mount the partition-1 of the hard drive ‘a' which is in vfat format to the /mnt/c_drive directory
mount -t vfat /mnt/sda1 /mnt/c_drive
The umount command dismounts devices before removed from the system. It works only if no files on the device are in use.
unmount /mnt/sdb1 [disconnects the /dev/sdb1 device]
It shows recent kernel activity, including newly detected devices
To display the partitions available on the device