Today's article is about mounted partitions...

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
11,810
Reaction score
10,377
Credits
97,689
We often use things like /dev/sd* in our paths. This is especially true with commands like 'dd', where we should double check our paths to avoid a catastrophic result.

There are many ways to show the mounted partitions. This article details two of them. The two chosen methods were chosen because of the output. The output is nice and easy to understand. I may cover other methods at some point, but this article just details a couple of ways.


Enjoy!
 


I didn't see it in your article, but you could also just type...

mount

.. and will list the mounted filesystems, even the virtual ones.
 
The mount command is quite condensed on screen and is made easier to read with a column command:
Code:
[flip@flop ~]$ mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,nosuid,relatime,size=4015264k,nr_inodes=1003816,mode=755,inode64)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,nodev,noexec,relatime,size=808708k,mode=755,inode64)
/dev/sda2 on / type ext4 (rw,relatime,errors=remount-ro)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
<snip>

but with column,

Code:
[flip@flop ~]$ mount | column -t
sysfs        on  /sys                       type  sysfs            (rw,nosuid,nodev,noexec,relatime)
proc         on  /proc                      type  proc             (rw,nosuid,nodev,noexec,relatime)
udev         on  /dev                       type  devtmpfs         (rw,nosuid,relatime,size=4015264k,nr_inodes=1003816,mode=755,inode64)
devpts       on  /dev/pts                   type  devpts           (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs        on  /run                       type  tmpfs            (rw,nosuid,nodev,noexec,relatime,size=808708k,mode=755,inode64)
/dev/sda2    on  /                          type  ext4             (rw,relatime,errors=remount-ro)
securityfs   on  /sys/kernel/security       type  securityfs       (rw,nosuid,nodev,noexec,relatime)
<snip>

Note that the mount command shows the options used on the mounted items. This info is however also available with the findmnt command mentioned in the linux-tips article, though not showing the output there:

Code:
[flip@flop ~]$ findmnt
TARGET                         SOURCE      FSTYPE          OPTIONS
/                              /dev/sda2   ext4            rw,relatime,errors=remount-ro
├─/sys                         sysfs       sysfs           rw,nosuid,nodev,noexec,relatime
│ ├─/sys/kernel/security       securityfs  securityfs      rw,nosuid,nodev,noexec,relatime
│ ├─/sys/fs/selinux            selinuxfs   selinuxfs       rw,nosuid,noexec,relatime
│ ├─/sys/fs/cgroup             cgroup2     cgroup2         rw,nosuid,nodev,noexec,relatime,nsdelegate,memory_recursiveprot
│ ├─/sys/fs/pstore             pstore      pstore          rw,nosuid,nodev,noexec,relatime
│ ├─/sys/firmware/efi/efivars  efivarfs    efivarfs        rw,nosuid,nodev,noexec,relatime
│ ├─/sys/fs/bpf                bpf         bpf             rw,nosuid,nodev,noexec,relatime,mode=700
│ ├─/sys/kernel/debug          debugfs     debugfs         rw,nosuid,nodev,noexec,relatime
│ ├─/sys/kernel/tracing        tracefs     tracefs         rw,nosuid,nodev,noexec,relatime
│ ├─/sys/fs/fuse/connections   fusectl     fusectl         rw,nosuid,nodev,noexec,relatime
│ └─/sys/kernel/config         configfs    configfs        rw,nosuid,nodev,noexec,relatime
├─/proc                        proc        proc            rw,nosuid,nodev,noexec,relatime
│ └─/proc/sys/fs/binfmt_misc   systemd-1   autofs          rw,relatime,fd=31,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=14705
│   └─/proc/sys/fs/binfmt_misc binfmt_misc binfmt_misc     rw,nosuid,nodev,noexec,relatime
├─/dev                         udev        devtmpfs        rw,nosuid,relatime,size=4015264k,nr_inodes=1003816,mode=755,inode64
│ ├─/dev/pts                   devpts      devpts          rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000
│ ├─/dev/shm                   tmpfs       tmpfs           rw,nosuid,nodev,inode64
│ ├─/dev/mqueue                mqueue      mqueue          rw,nosuid,nodev,noexec,relatime
│ └─/dev/hugepages             hugetlbfs   hugetlbfs       rw,nosuid,nodev,relatime,pagesize=2M
├─/run                         tmpfs       tmpfs           rw,nosuid,nodev,noexec,relatime,size=808708k,mode=755,inode64
│ ├─/run/lock                  tmpfs       tmpfs           rw,nosuid,nodev,noexec,relatime,size=5120k,inode64
│ └─/run/user/1000             tmpfs       tmpfs           rw,nosuid,nodev,relatime,size=808704k,nr_inodes=202176,mode=700,uid=1000,gid=1000,inode64
│   ├─/run/user/1000/gvfs      gvfsd-fuse  fuse.gvfsd-fuse rw,nosuid,nodev,relatime,user_id=1000,group_id=1000
│   └─/run/user/1000/doc       portal      fuse.portal     rw,nosuid,nodev,relatime,user_id=1000,group_id=1000
├─/boot/efi                    /dev/sda1   vfat            rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro
└─/home                        /dev/sda4   ext4            rw,relatime

So it turns out that findmnt output is a very good accompaniment to the "df -aTh" command, since the df command shows sizes of the mounts, among other info as shown in the output in the article, and the findmnt command shows the options used. Great article for the terminal explorer :)
 
Last edited:
I didn't see it in your article, but you could also just type...
Yeah, but the output is more confusing for newbies.

Great article for the terminal explorer :)

This is Linux. There are probably a dozen other methods that I didn't even consider. I'm not sure if I'll ever completely run out of ideas to write about. I didn't even consider piping anything to the column command.

Now, for the both of you...

What I don't know is why the virtual partitions aren't the same in the various outputs. I haven't got a clue.

It's not something that keeps me up at night, but I did do a quick search and found no reasons why. I didn't dig very deep, I just moved on. So long as it showed the real partitions, I was pretty content with the output.
 
It should probably be noted that some distributions load the driver responsible for /dev/sd*, sd_mod, as a module. This will make the assignment of drives /dev/sd[abc...] somewhat random between boots. On such systems, if /dev/sda is the currently assigned to the root drive, after a reboot it may become /dev/sdc. Because of this, it's not a good habit to think-of, or refer-to, a drive or partition via /dev/sd* in any permanent way, such as in /etc/fstab.

There are a lot of examples out there that don't mention any issues with referring to /dev/sd*. Most utilities only list /dev/sd* in the output. Of course, those with only one drive may never see this issue. But it pays to remember to be careful and check before using a reference to /dev/sd*.

Depending on the distribution, there may work-arounds for regaining a more stable assignment of /dev/sd* by adding dependencies to the module probe in the initrd, however, I'm not sure if many do so by default.

Generally permanent references to partitions are done by UUID or file-system label, and whole disks by UUID. See /dev/disk for ways of obtaining UUIDs or other identifiers:

Code:
ls -l /dev/disk/
ls -l /dev/disk/by_uuid/
 

Staff online

Members online


Latest posts

Top