12

maybe this is a simple thing but I have the following doubt.

If I perform fdisk -l, in the output I can find these devices that represent 2 partitions on the /dev/sdb device that is my SD card:

Dispositivo Boot      Start         End      Blocks   Id  System
/dev/sdb1            8192      122879       57344    c  W95 FAT32 (LBA)
/dev/sdb2          122880    15523839     7700480   83  Linux

From this output can I know is these partitions are mounted or unmounted ? (I think no).

What can I do to know if a specific partition is mounted on my system?

11

The mount command is the usual way. On Linux, you can also check /etc/mtab, or /proc/mounts.

| improve this answer | |
  • 1
    Note that mount simply displays the contents of /etc/mtab, which is a static file that can become out-of-date (most notably if the root fs is mounted read-only, but also if mounts are changed via direct syscalls rather than using the mount and umount utilities). /proc/mounts is guaranteed to be accurate, but obviously only exists if the /proc filesystem is correctly mounted. df reads /etc/mtab via the functions in <mntent.h>, so is no more reliable than this method. – Jules Jun 4 '14 at 0:34
  • @Jules, on some distros, /etc/mtab is actually a symlink to /proc/mounts. – cjm Jun 4 '14 at 5:55
  • @cjm I didn't know that; I'm a long-time debian/ubuntu user, where it isn't. – Jules Jun 4 '14 at 6:13
13

You can also use df, which will give you a nicer printout and show the disk usage of the mounted file systems:

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        27G  8.6G   17G  35% /
dev             2.0G     0  2.0G   0% /dev
run             2.0G  488K  2.0G   1% /run
tmpfs           2.0G  456K  2.0G   1% /dev/shm
tmpfs           2.0G     0  2.0G   0% /sys/fs/cgroup
tmpfs           2.0G  738M  1.3G  38% /tmp
/dev/sdb2       715G  515G  164G  76% /home
tmpfs           396M  4.0K  396M   1% /run/user/1000
| improve this answer | |
9

lsblk is a nice way for humans to see devices and mount-points. See also this answer.

$ lsblk
NAME            MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda               8:0    0   7.3T  0 disk
└─dataGB-dataVB 253:1    0  14.6T  0 lvm  /mnt/dataB
sdb               8:16   0   7.3T  0 disk
└─dataGB-dataVB 253:1    0  14.6T  0 lvm  /mnt/dataB
sdc               8:32   0   7.3T  0 disk
└─sdc1            8:33   0   7.3T  0 part
  └─dataG-data  253:0    0   7.3T  0 lvm  /mnt/data
sdd               8:48   0   7.3T  0 disk
└─sdd1            8:49   0   7.3T  0 part
sde               8:64   0   9.1T  0 disk
└─sde1            8:65   0   9.1T  0 part /mnt/dataC
nvme0n1         259:0    0 232.9G  0 disk
└─nvme0n1p1     259:1    0 232.9G  0 part /

findmnt is useful for scripting or to query a specific device:

$ findmnt /dev/sde1
TARGET     SOURCE    FSTYPE OPTIONS
/mnt/dataC /dev/sde1 xfs    rw,relatime,attr2,inode64,noquota
| improve this answer | |
  • 1
    Best answer under my opinion. Displayed the exact information I needed, in a well-formatted way. +1 – Soutzikevich Jan 30 '19 at 16:31
2

I suppose you could use the command blkid to list what is mounted (DQMOT). I would suggest setting up your sudo gedit /etc/fstab - if you didn't know of it - with the outputs for the hard drives blkid picks up. The UUIDs "universally unique identifier" are a better way of mounting than other methods.

For example:

# <file system> <mount point>                   <type>  <options>                      <dump>  <pass>
UUID=9ee10f9f-c7fa-4c94-93dc-d8ca02db9c2f /     ext4    errors=remount-ro              0       1
UUID=48ee8-657-3154044569-d52005b00ded-68 none  swap    sw                             0       0
UUID=C8CE6F14CE6EF9D8 /media/john/windows       ntfs    defaults                       0       0
UUID=F4644D2D644CF3C0 /media/john/e             ntfs    defaults                       0       0

You can also often see in the file manager GUI: win+e and look at whether or not the disks are mounted with the up-turned arrows. You can also mount/un-mount from this menu.

enter image description here

| improve this answer | |
  • Thanks, but this shows what's mounted, but not the device node, so it wouldn't answer the original question - how can I see which device nodes are actually mounted? Is there a way of showing device nodes in this GUI? – Rich Homolka Jun 3 '14 at 19:47
1

The simplest way is use the command mount:

 $ mount
 /dev/sda1 on / type ext4 (rw,errors=remount-ro)
 proc on /proc type proc (rw,noexec,nosuid,nodev)
 sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
 none on /sys/fs/cgroup type tmpfs (rw)
 none on /sys/fs/fuse/connections type fusectl (rw)
 none on /sys/kernel/debug type debugfs (rw)
 none on /sys/kernel/security type securityfs (rw)
 udev on /dev type devtmpfs (rw,mode=0755)
 devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
 tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
 none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)
 none on /run/shm type tmpfs (rw,nosuid,nodev)
 none on /run/user type tmpfs (rw,noexec,nosuid,nodev,size=104857600,mode=0755)
 none on /sys/fs/pstore type pstore (rw)
 /dev/sda6 on /home type ext4 (rw)
 binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
 rpc_pipefs on /run/rpc_pipefs type rpc_pipefs (rw)
 systemd on /sys/fs/cgroup/systemd type cgroup (rw,noexec,nosuid,nodev,none,name=systemd)

This information is stored in /etc/mtab, you can see by yourself that the output of mount is nearly identical to that of /etc/mtab

| improve this answer | |
1

How about gnome-disks? Depending on the Ubuntu release, it appears in classic menus as Disks under either Accessories or Utilities?

It gives a graphical map of each disc unit and full details of device name, size, mount status, etc, and also allows mount/dismount. It has the advantage over mount of showing both mounted and unmounted partitions, but as a GUI program it does not have an output that can be piped to other processes in a script. Unlike blkid it does not need root priveleges.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.