- How to List Mounted Drives on Linux
- 1) Listing from /proc using cat command
- 2) Using Mount Command
- 3) Using df command
- 4 ) Using findmnt
- Conclusion
- Linux Command: Show Mounted Hard Drives Partition
- Examples
- How do I check where devices are mounted?
- 3 Answers 3
- How to get the complete and exact list of mounted filesystems in Linux?
- 4 Answers 4
- Is there a command to see where a disk is mounted?
- 6 Answers 6
How to List Mounted Drives on Linux
In this tutorial, I will show you the different ways to list mounted drives on Linux. We can use mount, findmnt, and df commands to list mounted device any Linux distribution like Ubuntu or Centos.
In Linux, mount command mounts a storage device or filesystem, and let’s go through commands that can display all those mounts.
1) Listing from /proc using cat command
To list mount points you can read contents of the file /proc/mounts.
In the following example, I have used cat command to read the /proc/mounts file:
2) Using Mount Command
You can use mount command to list mount points. When you run mount command without any options it will list mount points.
3) Using df command
You can use df command to list mount points.
The following command shows the output of df with -aTh option:
You can use -t followed by filesystem type (say ext3, ext4, nfs) to display respective mount points. For examples below df command display all NFS mount points.
4 ) Using findmnt
Findmnt is a powerful tool to find mounted filesystems. This command comes with lots of options to list mount filesystems.
The following command print all mounted filesystems:
Print mount point by specific filesystem type:
Search and list fstab contents:
Display all /etc/fstab file and converts LABEL= and UUID= tags to the real device names:
Conclusion
In this tutorial, we learned commands to list mounted drives or filesystems on Linux. I hope you enjoyed reading and please leave your suggestion in the comment section.
Источник
Linux Command: Show Mounted Hard Drives Partition
[a] df command – Shoe file system disk space usage.
Tutorial details | |
---|---|
Difficulty level | Easy |
Root privileges | No |
Requirements | Linux |
Est. reading time | N/A |
[b] mount command – Show all mounted file systems. [c] /proc/mounts or /proc/self/mounts file – Show all mounted file systems.
Examples
Open a terminal or login using ssh into the remote server and type the following command:
$ cat /proc/mounts
OR
$ cat /proc/self/mounts
Sample outputs:
Type the mount command as follows to get same information:
Type the df command shows more human readable output:
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
Fig.01: df command in action
🐧 Get the latest tutorials on Linux, Open Source & DevOps via
Category | List of Unix and Linux commands |
---|---|
Documentation | help • mandb • man • pinfo |
Disk space analyzers | df • duf • ncdu • pydf |
File Management | cat • cp • less • mkdir • more • tree |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Linux Desktop Apps | Skype • Spotify • VLC 3 |
Modern utilities | bat • exa |
Network Utilities | NetHogs • dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop |
Searching | ag • grep • whereis • which |
Shell builtins | compgen • echo • printf |
Text processing | cut • rev |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Comments on this entry are closed.
command not found…
Which command will display the number of devices in my system (routers/switches/AP)
I purchased the Hp 15-n018 model laptop, when i checking with vendor they said will not support for Linux operating and i didn’t found the driver in internet….. i able found in win 8 and 8.1….
But am very interested in Linux operating system…. any one can please help me where i can the driver.
Sudinhar: it really depends on what driver you’re talking about for which specific device and for which specific Linux distribution.
The laptop itself may require any number of drivers, including HD, CD/DVD, sound, display, network, etc.
Many Linux distributions come with drivers for a wide variety of systems & devices, and you can generally get Linux up & running on just about anything these days with enough patience.
You can generally repartition your hard drive without losing any data using tools provided in distribution ISOs/DVDs & install Linux as a dual boot without fear of not being able to also use Windows if necessary as a backup.
I first installed Linux on a laptop back in the 90s, and it was difficult to get all the drivers but I did eventually & it worked ok.
These days it’s usually much simpler and any up to date Linux distribution should run just fine on your laptop with a little setup & TLC.
As a side note, I’d like to thank the author of this article, the commands worked as advertised & provided the information I required.
Linux has a long history of not “playing well” with laptops, and unless you get a laptop that is “certified” to run with Linux, you’re bound to have headaches. Something else you might try is keeping the laptop as is, and installing Virtual Box, by Sun (Oracle?) I believe it’s available on-line at no charge. This is a VM system, which will allow you to load a real copy of Linux, as it emulates a real computer. Personally, I use VMware Workstation (I’ve had it for years, but it’s a commercial product) which does the same thing, but I’ve heard nothing but good things about Virtual Box. You can then launch Linux in a window, and it’s a “real” linux version, which you will install from the distribution ISO.
Let’s say I want to display on the i3status bar whether a device/share is mounted.
How would that be accomplished?
I’m kind of new to i3, but as of what I’ve found online about the wm, it is a matter of finding the right parameter on i3status or i3blocks (whichever you use).
Источник
How do I check where devices are mounted?
What is the command that lets me see what and where devices are mounted?
I’m having trouble changing songs on my old iPod, and I have a feeling it’s because of the mount point.
3 Answers 3
There are at least three programs I know of that list device mount points:
mount — mount a filesystem (used for general mount info too):
df — report file system disk space usage
lsblk — list block devices
Of these three, mount lists all the mountpoints, AFAICT. The others have their weaknesses.
findmnt suggested by @webwurst is now my favourite tool for the job. It’s a Swiss Army knife when it comes to output control (newer versions can output in JSON too):
findmnt is the tool to use:
findmnt will list all mounted filesytems or search for a filesystem. The findmnt command is able to search in /etc/fstab , /etc/fstab.d , /etc/mtab or /proc/self/mountinfo . If device or mountpoint is not given, all filesystems are shown.
The command prints all mounted filesystems in the tree-like format by default.
If it’s an iPod, it will probably be mounted by gvfs.
Have a look in /run/user/1000/gvfs/afc* (assuming your uid is 1000)
The other command that might help is gvfs-mount -l
Источник
How to get the complete and exact list of mounted filesystems in Linux?
I usually use mount to check which filesystems are mounted. I also know there is some connection between mount and /etc/mtab but I’m not sure about the details. After reading How to check if /proc/ is mounted I get more confused.
My question is: How to get the most precise list of mounted filesystems? Should I just use mount , or read the contents of /etc/mtab , or contents of /proc/mounts ? What would give the most trustworthy result?
4 Answers 4
The definitive list of mounted filesystems is in /proc/mounts .
If you have any form of containers on your system, /proc/mounts only lists the filesystems that are in your present container. For example, in a chroot, /proc/mounts lists only the filesystems whose mount point is within the chroot. (There are ways to escape the chroot, mind.)
There’s also a list of mounted filesystems in /etc/mtab . This list is maintained by the mount and umount commands. That means that if you don’t use these commands (which is pretty rare), your action (mount or unmount) won’t be recorded. In practice, it’s mostly in a chroot that you’ll find /etc/mtab files that differ wildly from the state of the system. Also, mounts performed in the chroot will be reflected in the chroot’s /etc/mtab but not in the main /etc/mtab . Actions performed while /etc/mtab is on a read-only filesystem are also not recorded there.
The reason why you’d sometimes want to consult /etc/mtab in preference to or in addition to /proc/mounts is that because it has access to the mount command line, it’s sometimes able to present information in a way that’s easier to understand; for example you see mount options as requested (whereas /proc/mounts lists the mount and kernel defaults as well), and bind mounts appear as such in /etc/mtab .
Источник
Is there a command to see where a disk is mounted?
Is there a simple command that takes a disk’s device node as input, and tells me where (and whether) that disk is mounted? Is it possible to get the mount point by itself, so I can pass it to another command?
I’m working on a Debian Squeeze live system with a minimal install (I can install extra packages if need be).
6 Answers 6
On Linux, you can now use the findmnt command from util-linux (since version 2.18):
Or lsblk (also from util-linux , since 2.19):
That one is also useful to find all the file system mounted under a specific device (disk or partition. ):
To get the mountpoint only:
Above findmnt does return with a failure exit status if the device is not mounted, not lsblk .
Under Linux, you can get mount point information directly from the kernel in /proc/mounts . The mount program records similar information in /etc/mtab . The paths and options may be different, as /etc/mtab represents what mount passed to the kernel whereas /proc/mounts shows the data as seen inside the kernel. /proc/mounts is always up-to-date whereas /etc/mtab might not be if /etc was read-only at some point that wasn’t expected by the boot scripts. The format is similar to /etc/fstab .
In both files, the first whitespace-separated field contains the device path and the second field contains the mount point.
or if you don’t have awk:
There are a number of edge cases where you might not get what you expect. If the device was mounted via a different path in /dev that designates the same device, you won’t notice it this way. In /proc/mounts , bind mounts are indistinguishable from the original. There may be more than one match if a mount point shadows another (this is unusual).
In /proc/self or /proc/$pid , there is a per-process mounts file that mimics the global file. The mount information may vary between processes, for example due to chroot . There is an additional file called mountinfo that has a different format and includes more information, in particular the device major and minor numbers. From the documentation:
So if you’re looking for a device by number, you can do it like this:
Источник