lsblk command to view mounted devices briefly. While this command provides a concise overview, it lacks details like filesystem types and specific mount options. For a comprehensive view of all mounted filesystems, use the findmnt command.
For example, running findmnt might yield output similar to the following, showing that the /dev/vdb1 partition with the XFS filesystem is mounted in the mybackups directory:
Keep in mind that on larger systems,
findmnt may produce additional output lines for virtual filesystems (like proc) that are mounted in memory.-t option:
findmnt only displays currently mounted filesystems; those defined on a partition but not mounted will not appear.
The OPTIONS column in the output indicates how each filesystem is mounted. For example, the rw option for /dev/vdb1 means that the filesystem is mounted with read-write permissions. If it were set to ro, the filesystem would be mounted as read-only, which becomes evident when you attempt to create a file:
rw to ro will make the filesystem read-only.
To mount a filesystem with specific options, use the -o switch with the mount command. For example, to remount a filesystem as read-only:
Applying Multiple Mount Options
In addition to the basicro (read-only) option, you can enhance security using options such as noexec and nosuid:
- noexec: Prevents the execution of any executable files stored on the filesystem.
- nosuid: Disables the SUID (Set User ID) bit, preventing programs from running with elevated privileges without using
sudo.
findmnt:
remount option:
Filesystem-Specific Options
The options we have discussed so far are generally applicable across multiple filesystem types. However, some options are filesystem-specific. For instance, XFS provides an option calledallocsize which defines the buffered I/O end-of-file preallocation size during delayed allocation writeout. The allocsize value can be specified in powers-of-2 increments from the page size (typically 4 KiB) up to 1 GiB. By default, XFS uses dynamic allocation based on heuristics, and specifying a fixed allocsize disables this dynamic behavior.
Before applying filesystem-dependent options, ensure that the filesystem is unmounted if necessary, then mount it with your desired option. For example:
Automatic Mounting with /etc/fstab
So far, we have covered manual mounting techniques. These mount configurations can also be automated during system boot via the/etc/fstab file. A typical fstab entry might initially look like this:
Always consult the relevant manual pages (e.g.,
man mount, man xfs, or man ext4) for a comprehensive list of options and their effects.