Linux list all filesystems

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.

Источник

10 basic & powerful commands to check file system type in Linux/Unix

Table of Contents

Any operating system must be able to access and manage files on storage devices; however, the manner in which the files are organized on a storage device is actually set by the underlying filesystem.With Linux and Unix there are various filesystem types, so in this article I will share multiple commands and methods to check file system type in Linux and Unix.

Before we try to determine and check file system type, we must be familiar with the term «File System».

What is a FileSystem?

As you probably know, or at least can guess, hard drives are not monolithic entities with data simply spread haphazardly around the hard drive. Hard drives are organized into sectors and clusters. Data of any type is organized into files. Whether it is a document, image, spreadsheet, or even an executable program, it is a file. That file may be stored in one or more clusters.

Filesystems are responsible to organize, find, and work with those files that are on the hard drive. There are issues that any filesystem must address in order to handle files effectively.

The first issue occurs because many files are larger than a single sector or cluster. So, locating the entirety of a file on a hard drive is an issue that must be addressed. The operating system may need to check several clusters, not necessarily contiguous, to find a file.

Another problem is how to store the files in clusters and sectors. Also, a filesystem must address how to handle space left due to deleted or moved files.

Now since we know what is a File System, Let us start with the actual agenda of this article.

Commands to check file system type in Linux or Unix

1. blkid

blkid can determine the type of content (e.g. filesystem or swap) that a block device holds, and also the attributes (tokens, NAME=value pairs) from the content metadata (e.g. LABEL or UUID fields).

You must execute blkid as root user without any directives and check » TYPE » field to check file system type of respective partition or device in Linux or Unix.

With -t, —match-token NAME=value , you can search for block devices with tokens named NAME that have the value value, and display any devices which are found. Common values for NAME include TYPE , LABEL , and UUID

Читайте также:  Чтобы посмотреть версию windows

For example to list and check file system type for ext4 FS:

2. lsblk

lsblk lists information about all available or the specified block devices. lsblk command provides more information, better control on output formatting, easy to use in scripts and it does not require root permissions to get actual information.

df is another popular and most used command to display the amount of disk space available on the file system containing each file name argument. If no file name is given, the space available on all currently mounted file systems is shown.

Using -T directive with df command you can print file system type of all the mounted file systems.

Alternatively you can specify a device with df command to check file system type of the respective device

4. findmnt

findmnt will list all mounted filesystems or search for a filesystem. The findmnt command is able to search in /etc/fstab , /etc/mtab or /proc/self/mountinfo . If device or mountpoint is not given, all filesystems are shown.

Using —fstab directive, findmnt command will search in /etc/fstab and with -t it will limit the set of printed filesystems

If used without any directive, findmnt command will give you long list of output with all bind mounts

5. file

file command is normally only attempts to read and determine the type of argument files. Specifying the -s option causes file to also read argument files which are block or character special files. This is useful for determining and to check file system types of the data in raw disk partitions, which are block special files

6. udevadm

udevadm command queries the udev database for device information stored in the udev database. It can also query the properties of a device from its sysfs representation to help creating udev rules that match this device.

Using —query you can query the database for the specified type of device data. The below command gives a long output so we will grep the required data to check file system type for our device /dev/sda1

Some more commands and methods to determine filesystem type in Linux or Unix

Now above were some of the most used commands to check file system type but there are many other methods using which you can determine filesystem type

7. File /etc/fstab content

Normally all the devices we use are mounted via /etc/fstab file to make the mounting reboot persistent. So you can always refer /etc/fstab file to check file system type, for example:

Here the first column of the file specifies the partition device path while the third column shows the file system type of the respective device.

8. File /etc/mtab content

Similar to /etc/fstab you can also refer /etc/mtab to get the list of currently mounted file system along with the file system type.

Here also the first column of the file specifies the partition device path while the third column shows the file system type of the respective device.

9. File /proc/mounts

Now /proc/mounts file refers /etc/mtab so this is not a new method but just another file which you can look into to check file system type in Linux or Unix.

10. mount command

Again, mount command will also refer /etc/mtab file to get the list of mounted file systems and can also help you determine file system type of individual devices.

Lastly I hope the methods and commands from the article to determine and check file system type on Linux and Unix was helpful. So, let me know your suggestions and feedback using the comment section.

Didn’t find what you were looking for? Perform a quick search across GoLinuxCloud

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

For any other feedbacks or questions you can either use the comments section or contact me form.

Thank You for your support!!

Источник

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.)

Читайте также:  Как правильно настроить ssd под windows 10 64 bit

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 .

Источник

Как посмотреть диски в Linux

Системные администраторы ОС Linux обычно просматривают диски, чтобы проверить все дисковое пространство и его использование. Список дисков также помогает увидеть подключенные диски к системе, разделы и файловую систему, используемую дисками.

В системе Linux существует несколько способов посмотреть все жесткие диски. Из этой статьи вы узнаете, как посмотреть диски в Linux с помощью командной строки.

1. lsblk

lsblk (list block devices) используется для просмотра информации обо всех доступных блочных устройствах, таких как жесткий диск и флэш-накопители.

Просто набрав команду lsblk, вы получите список всех блочных устройств в виде древовидного формата. Это удобный и простой способ посмотреть диски.

sda 8:0 0 238.5G 0 disk
├─sda1 8:1 0 529M 0 part
├─sda2 8:2 0 100M 0 part /boot/efi
├─sda3 8:3 0 16M 0 part
├─sda4 8:4 0 165.8G 0 part
├─sda5 8:5 0 70G 0 part /
└─sda6 8:6 0 2G 0 part [SWAP]
zram0 252:0 0 8G 0 disk [SWAP]

2. df -h

Команда df используется для просмотра объема доступного дискового пространства. Так же команда df отобразит имя устройства, общее количество блоков, используемое дисковое пространство, доступное дисковое пространство, процент используемого пространства, точку монтирования файловой системы, а также покажет удаленно смонтированные файловые системы, такие как NFS.

Команда df -h покажет доступное пространство всех дисков в удобочитаемом виде.

Ответ в терминале:

Filesystem Size Used Avail Use% Mounted on
devtmpfs 5.8G 0 5.8G 0% /dev
tmpfs 5.8G 90M 5.7G 2% /dev/shm
tmpfs 2.4G 11M 2.4G 1% /run
tmpfs 4.0M 0 4.0M 0% /sys/fs/cgroup
/dev/sda5 69G 62G 3.1G 96% /
tmpfs 5.8G 4.7M 5.8G 1% /tmp
/dev/sda2 96M 41M 56M 43% /boot/efi
tmpfs 1.2G 200K 1.2G 1% /run/user/1000

3. fdisk -l

Команда fdisk — это текстовая утилита, используемая для управления разделами диска. С помощью fdisk вы можете отобразить разделы диска, создать новый раздел, удалить существующий раздел жесткого диска и просмотреть размер раздела.

Для этого используется команда fdisk -l отобразит все доступные разделы диска

Ответ в терминале:

Disk /dev/sda: 238.47 GiB, 256060514304 bytes, 500118192 sectors
Disk model: SK hynix SC300B
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: FF57C955-D98A-49C4-B1ED-835A44F2A0A4
Device Start End Sectors Size Type
/dev/sda1 2048 1085439 1083392 529M Windows recovery environment
/dev/sda2 1085440 1290239 204800 100M EFI System
/dev/sda3 1290240 1323007 32768 16M Microsoft reserved
/dev/sda4 1323008 349122559 347799552 165.8G Microsoft basic data
/dev/sda5 349122560 495923199 146800640 70G Linux filesystem
/dev/sda6 495923200 500117503 4194304 2G Linux swap
Disk /dev/zram0: 8 GiB, 8589934592 bytes, 2097152 sectors
Units: sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk /dev/loop0: 207.15 MiB, 217214976 bytes, 424248 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop1: 99.18 MiB, 103993344 bytes, 203112 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

4. parted -l

Parted — это полезный и мощный инструмент используемый для управления разделами жесткого диска из терминала (командной строки). Обладает способностями такими как список, создание, сжатие, удаление, поиск и восстановление разделов диска. С помощью команды parted вы можете легко управлять всеми разделами жесткого диска.

команда parted-l покажет расположение разделов дисков.

Ответ в терминале:

Model: ATA SK hynix SC300B (scsi)
Disk /dev/sda: 256GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 556MB 555MB ntfs Basic data partition hidden, diag
2 556MB 661MB 105MB fat32 EFI System Partition boot, esp
3 661MB 677MB 16.8MB Microsoft reserved partition msftres
4 677MB 179GB 178GB ntfs Basic data partition msftdata
5 179GB 254GB 75.2GB ext4
6 254GB 256GB 2147MB linux-swap(v1) swap
Model: Unknown (unknown)
Disk /dev/zram0: 8590MB
Sector size (logical/physical): 4096B/4096B
Partition Table: loop
Disk Flags:
Number Start End Size File system Flags
1 0.00B 8590MB 8590MB linux-swap(v1)

5. cfdisk

Cfdisk немного отличается от вышеприведенных команд, эта команда обеспечивает графическое представление в терминальном интерфейсе. С помощью cfdisk вы можете просматривать, создавать, удалять и изменять разделы.

Disk: /dev/sda Size: 238.47 GiB, 256060514304 bytes, 500118192 sectors Label: gpt, identifier: FF57C955-D98A-49C4-B1ED-835A44F2A0A4 Device Start End Sectors Size Type
/dev/sda1 2048 1085439 1083392 529M Windows recovery environment
/dev/sda2 1085440 1290239 204800 100M EFI System
/dev/sda3 1290240 1323007 32768 16M Microsoft reserved
/dev/sda4 1323008 349122559 347799552 165.8G Microsoft basic data
/dev/sda5 349122560 495923199 146800640 70G Linux filesystem
/dev/sda6 495923200 500117503 4194304 2G Linux swap
┌──────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Partition name: Basic data partition │
│ Partition UUID: E73F9719-F144-42A8-87BC-862FB470828B │
│ Partition type: Windows recovery environment (DE94BBA4-06D1-4D40-A16A-BFD50179D6AC) │
│ Attributes: RequiredPartition │
│ Filesystem UUID: 8C0A62C30A62A9C2 │
│Filesystem LABEL: Recovery │
│ Filesystem: ntfs │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────┘
[ Delete ] [ Resize ] [ Quit ] [ Type ] [ Help ] [ Write ] [ Dump ]

Команда для просмотра дисков в Linux cfdisk

Читайте также:  Драйвер для acer aspire 5750g для windows 10

6. sfdisk -l

sfdisk — это редактор таблиц разделов. Он может показать разделы, показать размер раздела, проверить разделы на устройстве и подготовить устройство.

Команда sfdisk -l покажет разделы каждого диска.

Ответ в терминале:

Disk /dev/sda: 238.47 GiB, 256060514304 bytes, 500118192 sectors
Disk model: SK hynix SC300B
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: FF57C955-D98A-49C4-B1ED-835A44F2A0A4
Device Start End Sectors Size Type
/dev/sda1 2048 1085439 1083392 529M Windows recovery environment
/dev/sda2 1085440 1290239 204800 100M EFI System
/dev/sda3 1290240 1323007 32768 16M Microsoft reserved
/dev/sda4 1323008 349122559 347799552 165.8G Microsoft basic data
/dev/sda5 349122560 495923199 146800640 70G Linux filesystem
/dev/sda6 495923200 500117503 4194304 2G Linux swap
Disk /dev/zram0: 8 GiB, 8589934592 bytes, 2097152 sectors
Units: sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/loop0: 207.15 MiB, 217214976 bytes, 424248 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop1: 99.18 MiB, 103993344 bytes, 203112 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

7. ls -l /dev/disk/by-id

команда ls — это очень простая, но мощная команда, используемая для отображения файлов и каталогов. Мы можем посмотреть диски, посмотреть каталог /dev/disk/by-id.

$ ls -l /dev/disk/by-id

Ответ в терминале:

total 0
lrwxrwxrwx 1 root root 9 Jun 20 23:26 ata-SK_hynix_SC300B_HFS256G39MND-3510B_FI68N023911308NC9 -> ../../sda
lrwxrwxrwx 1 root root 10 Jun 20 23:26 ata-SK_hynix_SC300B_HFS256G39MND-3510B_FI68N023911308NC9-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10 Jun 20 23:26 ata-SK_hynix_SC300B_HFS256G39MND-3510B_FI68N023911308NC9-part2 -> ../../sda2
lrwxrwxrwx 1 root root 10 Jun 20 23:26 ata-SK_hynix_SC300B_HFS256G39MND-3510B_FI68N023911308NC9-part3 -> ../../sda3
lrwxrwxrwx 1 root root 10 Jun 20 23:26 ata-SK_hynix_SC300B_HFS256G39MND-3510B_FI68N023911308NC9-part4 -> ../../sda4
lrwxrwxrwx 1 root root 10 Jun 20 23:26 ata-SK_hynix_SC300B_HFS256G39MND-3510B_FI68N023911308NC9-part5 -> ../../sda5
lrwxrwxrwx 1 root root 10 Jun 20 23:26 ata-SK_hynix_SC300B_HFS256G39MND-3510B_FI68N023911308NC9-part6 -> ../../sda6
lrwxrwxrwx 1 root root 9 Jun 20 23:26 wwn-0x5ace42e0900dd482 -> ../../sda
lrwxrwxrwx 1 root root 10 Jun 20 23:26 wwn-0x5ace42e0900dd482-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10 Jun 20 23:26 wwn-0x5ace42e0900dd482-part2 -> ../../sda2
lrwxrwxrwx 1 root root 10 Jun 20 23:26 wwn-0x5ace42e0900dd482-part3 -> ../../sda3
lrwxrwxrwx 1 root root 10 Jun 20 23:26 wwn-0x5ace42e0900dd482-part4 -> ../../sda4
lrwxrwxrwx 1 root root 10 Jun 20 23:26 wwn-0x5ace42e0900dd482-part5 -> ../../sda5
lrwxrwxrwx 1 root root 10 Jun 20 23:26 wwn-0x5ace42e0900dd482-part6 -> ../../sda6

Вы также можете посмотреть:

8. lshw -class disk

lshw — это инструмент Linux, который используется для получения подробной информации об аппаратной конфигурации системы.

Используйте -class disk для просмотра информации о диске.

Ответ в терминале:

*-disk
description: ATA Disk
product: SK hynix SC300B
physical id: 0.0.0
bus info: scsi@1:0.0.0
logical name: /dev/sda
version: 0P00
serial: FI68N023911308NC9
size: 238GiB (256GB)
capabilities: gpt-1.00 partitioned partitioned:gpt
configuration: ansiversion=5 guid=ff57c955-d98a-49c4-b1ed-835a44f2a0a4 logicalsectorsize=512 sectorsize=4096

Кроме того, можно вывести class disk as-json или -html или-xml.

Ответ в терминале:

<
«id» : «disk»,
«class» : «disk»,
«claimed» : true,
«handle» : «GUID:ff57c955-d98a-49c4-b1ed-835a44f2a0a4»,
«description» : «ATA Disk»,
«product» : «SK hynix SC300B»,
«physid» : «0.0.0»,
«businfo» : «scsi@1:0.0.0»,
«logicalname» : «/dev/sda»,
«dev» : «8:0»,
«version» : «0P00»,
«serial» : «FI68N023911308NC9»,
«units» : «bytes»,
«size» : 256060514304,
«configuration» : <
«ansiversion» : «5»,
«guid» : «ff57c955-d98a-49c4-b1ed-835a44f2a0a4»,
«logicalsectorsize» : «512»,
«sectorsize» : «4096»
>,
«capabilities» : <
«gpt-1.00» : «GUID Partition Table version 1.00»,
«partitioned» : «Partitioned disk»,
«partitioned:gpt» : «GUID partition table»
>,
«children» : [
]
>

Заключение

Для всех команд, кроме lsblk и ls-l dev/disk, требуется root — доступ или разрешения суперпользователя для его запуска.

В этой статье мы узнали, как посмотреть диски в Linux с помощью командной строки.

Источник

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