The mount
command is used to both mount filesystems and lists the mounted filesystems. In this tip we’re going to be looking at ways of improving the output of mount
when listing mounted filesystems (and why you may not want to use mount
at all for that purpose).
The Simple Case
By default, mount
will list the device, mountpoint, filesystem type and attributes, with a space between each element. Even with relatively few filesystems, the output is hard to read (for clarity, I’ve truncated the mount attributes in the examples below):
$ mount -t ext4 /dev/mapper/vg--awe-root on / type ext4 (rw,[...] /dev/mapper/vg--awe-tmp on /tmp type ext4 (rw,[...] /dev/mapper/vg--awe-home on /home type ext4 (rw,[...] /dev/mapper/vg--awe-var on /var type ext4 (rw,[...]
Improving The Output
Piping the output through column -t
will replace the single spaces above with sufficient spaces to align the columns and form a table. The difference in clarity that such a small change can make is surprising:
$ mount -t ext4|column -t /dev/mapper/vg--awe-root on / type ext4 (rw,[...] /dev/mapper/vg--awe-tmp on /tmp type ext4 (rw,[...] /dev/mapper/vg--awe-home on /home type ext4 (rw,[...] /dev/mapper/vg--awe-var on /var type ext4 (rw,[...]
Better Still
But there’s an even better way. The use of mount
to examine mounted filesystems is deprecated in favour of findmnt
. Isn’t the display below even clearer?
$ findmnt -t ext4 TARGET SOURCE FSTYPE OPTIONS / /dev/dm-0 ext4 rw,[...] ├─/tmp /dev/mapper/vg--awe-tmp ext4 rw,[...] ├─/var /dev/mapper/vg--awe-var ext4 rw,[...] └─/home /dev/mapper/vg--awe-home ext4 rw,[...]
Could This Linux Tip Be Improved?
Let us know in the comments below.