Linux list all filesystems

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?

I can’t help linking to What is /etc/mtab in Linux? because it covers non-Linux details that none of the answers here give.

5 Answers 5

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 .

Источник

4 Commands to List Mounted File Systems in Linux

The Linux operating system provides multiple filesystems, including ext4, xfs, tmpfs, securityfs, and many more. This guide demonstrates various ways to list all mounted file systems in a Linux system.

1. View Linux Mounted Filesystem Using /proc Filesystem

The /proc/mounts file is a file that displays the status of all filesystems that are currently mounted on the system. The file format closely resembles that of the /etc/fstab file. The file reports the status of mounted filesystems as recorded by the Linux kernel.

Читайте также:  Send mail from linux to linux

Thus, to view all the mounted filesystems, view the /proc/mounts file using the cat command as shown.

View Currently Mounted Linux Filesystems

2. List Linux Mounted Filesystem Using df Command

The df command is mostly used to check disk space utilization on mounted file systems. It lists, among other statistics, total disk space and available disk space on each mounted filesystem.

When the -a option is included, the df command lists all the mounted filesystems.

List Mounted Linux Filesystems

3. Print Linux Mounted Filesystems Using findmnt Command

The findmnt command is yet another powerful command that displays all mounted filesystems on your Linux system in a tree-like format.

To print all the mounted filesystems, simply run the command without any arguments.

This prints the output in a tree-like format as shown.

Print Mounted Linux Filesystems

You can pass the -D option which will print the output similar to the df -Th command

List Linux File System with Disk Usage

Pass the -t option followed by the filesystem type to print specific filesystems. For example, to view all the mounted EXT4 filesystems, run the command:

List Ext4 Mounted File System

To view all EXT4 filesystems mounted in the /etc/fstab file, run the command:

Check Linux Ext4 Mounted File System

4. Show Mounted Linux Filesystem Using mount Command

You can also use the mount command to list all mounted file systems. Without any arguments, it lists all the mounted filesystems.

Show Mounted Linux Filesystems

Summing Up

In this guide, we have explored four ways that you can use to list all mounted file systems in a Linux system. Your views and feedback on this guide are welcome.

Источник

How to list disks, partitions and filesystems in Linux? [duplicate]

In Windows, if you type LIST DISK using DiskPart in a command prompt it lists all physical storage devices, plus their size, format, etc. What is the equivalent of this in Linux?

3 Answers 3

There are many tools for that, for example fdisk -l or parted -l , but probably the most handy is lsblk (aka list block devices):

Example

$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 238.5G 0 disk ├─sda1 8:1 0 200M 0 part /boot/efi ├─sda2 8:2 0 500M 0 part /boot └─sda3 8:3 0 237.8G 0 part ├─fedora-root 253:0 0 50G 0 lvm / ├─fedora-swap 253:1 0 2G 0 lvm [SWAP] └─fedora-home 253:2 0 185.9G 0 lvm 

It has many additional options, for example to show filesystems, labels, etc. As always man lsblk is your friend.

@Dor it is worth explaining what additional options do, if you are recommending their use. -f or —fs shows the information about filesystems, such as format, crypto, raid member, etc. It is somewhat slower than the default though.

You’ll like this : you can do sudo lsblk —scsi and this shows the disk types including name(sda,sdb. ), scsi addr, type,vendor, model, rev, .. it’s easy to find which is which when you want to physically locate the disk.

Читайте также:  Linux от новинки до

Another way to quickly see the filesystems is the command df. On my machine (Finnish localization) it shows like this:

ptakala@athlon:/mnt$ df Tiedostojärjestelmä 1K-lohkot Käyt Vapaana Käy% Liitospiste /dev/root 38317204 19601752 16762352 54% / devtmpfs 4063816 0 4063816 0% /dev tmpfs 4097592 81988 4015604 3% /dev/shm tmpfs 4097592 10120 4087472 1% /run tmpfs 5120 8 5112 1% /run/lock tmpfs 4097592 0 4097592 0% /sys/fs/cgroup /dev/sda9 535267140 287403688 220666804 57% /work /dev/sda7 288239836 201635356 71956016 74% /home tmpfs 819520 4 819516 1% /run/user/113 tmpfs 819520 8 819512 1% /run/user/1000 /dev/sda1 39070048 37083304 1986744 95% /mnt/sda1 /dev/sda10 22662140 14032580 8629560 62% /mnt/sda10 /dev/sda5 29280176 20578032 8702144 71% /mnt/sda5 

It won’t show the file system type, but usually that is non-essential, and you see by one eyedrop everything needed.

ptakala@athlon:/mnt$ df -h Tiedostojärjestelmä Koko Käyt Vapaa Käy% Liitospiste /dev/root 37G 19G 16G 54% / devtmpfs 3,9G 0 3,9G 0% /dev tmpfs 4,0G 89M 3,9G 3% /dev/shm tmpfs 4,0G 9,9M 3,9G 1% /run tmpfs 5,0M 8,0K 5,0M 1% /run/lock tmpfs 4,0G 0 4,0G 0% /sys/fs/cgroup /dev/sda9 511G 275G 211G 57% /work /dev/sda7 275G 193G 69G 74% /home tmpfs 801M 4,0K 801M 1% /run/user/113 tmpfs 801M 8,0K 801M 1% /run/user/1000 /dev/sda1 38G 36G 1,9G 95% /mnt/sda1 /dev/sda10 22G 14G 8,3G 62% /mnt/sda10 /dev/sda5 28G 20G 8,3G 71% /mnt/sda5 

Источник

How do I see all mounts in Linux?

I was asked how to see all mount points in Linux. Even though I always did it for myself using the mount command, I was surprised when I found there was no more human-friendly way I could explain. Thus I decided to write a tutorial that includes different techniques to achieve it.

While running commands to get mount points information is pretty easy, dealing with the output may not be comfortable for some users. After reading this tutorial, you’ll know how to get different outputs through different available commands: cat, findmnt, mount and df. Yet no format is really human friendly.

See mount points using findmnt:

The command findmnt lists all mount points. To do this the findmnt reads files /etc/fstab, /etc/fstab.d, /etc/mtab or /proc/self/mountinfo.

To run it, simply just the command below.

As you can see in the output, there are 4 columns:

  • TARGET: This column shows the mount point.
  • SOURCE: In this column, you can see the mounted device.
  • FSTYPE: Here is described the file system.
  • OPTIONS: This column shows mount point options, such as Read-Only or Writable.

You can get additional information on findmnt at https://linux.die.net/man/8/findmnt.

Show mount points using cat:

The most accurate technique to see mount points in Linux is reading the /proc/mounts file using cat. This is also the less human-friendly way, with the worse visual output.

The advantage of this method is that the kernel directly provides the information to see mount points over more human-friendly ways as alternatives explained in this tutorial

To see all mount points using cat, run the command as shown below.

As you can see, the output isn’t user friendly, but it is considered the most accurate method to check mounted devices in Linux.

Читайте также:  Линукс монтирование при загрузке

See mount points using the mount command:

The mount is probably the most known command explained in this tutorial. Once we needed to run it every time we wanted to mount a device, it wasn’t automatic like today. By running it, you’ll get an output with all mounted filesystems. If followed by the -l flag, it will also show the mount point name; the output is similar to the mount command without flags.

As you can see, in the last two lines, there is a mounted pen drive containing a Kali Linux distribution.

Show mount points using df (Disk Free):

The df (Disk Free) command is also useful to print all mount points. The df command is mainly used to show available and used space on all storage devices.

To get an output with all mount points using df, just run it without additional options, as shown below.

Again you can see in the last line the /dev/sdb1 storage device is mounted.

This output displays 4 columns:

  • Filesystem: This column shows the filesystem.
  • 1K-Blocks: Here, you can see the size.
  • Used: This column shows used space (in 1K blocks).
  • Available: Available used space (in 1K blocks).
  • Use%: Percentage of used space
  • Mounted on: Mount point.

You can get more information on df at Linux Commands for Disk Space.

What happens when we mount or unmount a device in Linux?

When you mount a filesystem, like a cd, or a hard disk or USB stick, you create a mount point within your system. This mount point means virtually storing the cd, hard disk or USB stick’s content within your system. The files are not really stored in your system’s storage, but the system makes them accessible from itself by importing them under its filesystem hierarchy.

When you unmount a device, do exactly the opposite and instruct the system to stop providing mount points for external files.

Today mounting devices isn’t a common task since more user-friendly Linux distributions took over the market. Once, users needed to mount every external device manually, specifying the external device path and filesystem.

Conclusion:

As you can see, seeing all mounts in Linux is pretty easy. Linux offers you a variety of techniques to achieve this task by just running a command. As highlighted in the tutorial, the cat method is the most accurate and less human-friendly.

Other tools like findmnt feature a little improvement in the format, making it more user-friendly. Mounting, unmounting, and checking mount points status is a basic knowledge any Linux user-level must hold. Some Unix-like Linux distributions like Slackware don’t include automount enabled by default.

Thank you for reading this tutorial explaining how to see all mounts in Linux. Keep following Linux Hint for more Linux tips and tutorials.

About the author

David Adams

David Adams is a System Admin and writer that is focused on open source technologies, security software, and computer systems.

Источник

Оцените статью
Adblock
detector