The mount command performs two different functions. The primary use of the mount command is to attach (mount) a block storage device to the Linux file system (directory hierarchy). This is accomplished by designating a directory within the hierarchy to be the mountpoint. Then the mount command is used to create a mapping between that mountpoint and the disk file system on a block storage device. This is referred to as mounting a drive.
The example in Figure 4.6 (on page ) demonstrates how to use themkdir command to create a workspace directory in the user’s home drive. This will be the mountpoint. Then mount is used to create a mapping between the workspace directory and the ext4 disk file system on /dev/sdb1.
When executed without command line options, the mount command displays all of the block storage devices, both physical and virtual, that are currently attached (mounted) to the Linux file system. In addition, it displays the disk file system type of each block device and any disk file system specific options that were used. On modern systems this output can be quite verbose. The output in Figure 4.7 (on page ) shows that the ext4 disk file system on sdb1 has been mounted to the /home/alice/workspace directory in the Linux file system.
To disconnect (unmount) a block storage device, use the umount command. That is not a typo. The command to unmount an attached storage device is called umount. :) See Figure 4.8 on page ).
Storage devices mounted using the mount command are not persistent, meaning that if you reboot the computer they will no longer be attached and must manually be mounted again. A file called the file system table (fstab) is used to determine which storage devices are mounted automatically at boot. To add a storage device to the file system table, you'll need to open /etc/fstab in a text editor (such as kwrite or vim) and add a new entry for the storage device. See Figure 4.9 (on page ) for details.
Each line in the fstab is white-space delimited (space/tab). The first field is the block storage device containing the disk file system. The second field is the mountpoint (directory). The third field is the specific type of disk file system. The third is the disk file system options. The last two relate to when the block storage device is mounted, whether it is required to boot the system, and how frequently it is checked for errors.