How can I know if a partition is mounted or unmounted?
The mount
command is the usual way. On Linux, you can also check /etc/mtab, or /proc/mounts.
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
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