Linux is pretty good about handling media devices. If it has a drive and at least one partition with a filesystem on it, Linux will automatically add them to its directory in a process called mounting. Even if it only has the drive, you can use Bash to create and manage partitions and filesystems, and you can find your devices in the /dev directory. Mount and fstab are two tools you can use to manage your mounted devices.
Fstab is not a proper command in the usual sense, but a file that can be used to view and manage information about filesystems. It can be read but not written to by programs and managed by the system administrator using commands like mount and umount. The first field, fs spec, contains information about the device or remote filesystem to be mounted. It links to a block special device node reserved for the device, such as /dev/cdrom. An administrator can also identify the filesystem to be mounted, such as ext4 or xfs, or the UUID, which is usually a long string of lower-case letters and numbers.
The second field, fs file, identifies the filesystem's mount point. For swap files, the field will typically have an entry of “none”. It can handle spaces by escaping them as “\040”.
The third field, fs vfstype, identifies the filesystem type, such as vfat, ntfs,ext3, and ext4. The fourth field, fs mntops, denotes the mount options associated with the system to be mounted. Some default options include rw, suid, dev, exec, nouser, auto and async.
The fifth field, fs freq, determines how often the filesystem needs to be dumped, or examined to determine which files and directories need to be backed up. A value of 0 or null will cause the system to assume that the media doesn't need to be dumped.
The sixth and final field, fs passno, determines the order in which filesystem checks are performed when a system is booted. The root filesystem typically has a fs passno value of 1 and is the first to be checked. Other systems have a fs passno of 2. A value of 0 will cause the system to assume that the associated system does not need to be checked.
Mount and Umount
Mount is the command used when you need to manually mount a device. Essentially, it tells Bash to create a spot for the device's filesystem on the Linux system's larger directory tree. The usual syntax for mounting a device is mount -t type device dir, which tells Bash to mount the filesystem found on a device of a specific type in a specific area of the directory. If you wish to inspect already mounted devices, mount -l will give you a list of mounted devices, and mount -l -t type will give you a list of all devices of a specific type.
The umount command detaches a specific device's filesystem from the directory tree. This is a useful thing to do just before you disconnect devices like flash drives, so that the main kernel won't think the device is still there when it's not. It's like poking at a tooth that should be there but isn't. Before unmounting a device, don't forget to close, and save if necessary, all open files associated with the device.
What's In It For You?
While fstab can't be accessed directly, it can be inspected and modified using related commands in Bash. Mount and umount are two of the commands used to manage the fstab file that keeps track of devices mounted on your system.