Linux file system types check

Ways to Determine the File System Type in Linux

In computing, a filesystem is a layout or format used to store files in a storage device. A filesystem is used to logically divide a storage device to keep different files organized nicely in the storage device to be searched, accessed, modified, removed, etc. easily from the storage device.

There are many filesystems available today. Different filesystems have different structures, logics, features, flexibility, security, etc. Some of the most common filesystems are Ext4, Btrfs, XFS, ZFS, NTFS, FAT32, etc.

There are times when a Linux system administrator will need to determine the filesystem type to simply mount the filesystem or to diagnose problems with the filesystem. Different filesystems have different tools for diagnosing problems, checking for errors and fixing them, etc. So, you have to know the filesystem a storage device is using to determine the maintenance tool/tools to use.

In this article, I will show you different ways you can determine the filesystem type in Linux. So, let’s get started.

Way 1: Using the df Command-Line Tool

The df command-line program is preinstalled on almost every Linux distribution you will find. You can use the df command-line program to find the Filesystem type all the mounted storage devices and partitions.

To find the filesystem type of all the mounted storage devices and partitions of your computer, run the df command as follows:

The df command will show you the following information:
Filesystem: The storage device name or partition name that is currently mounted.

Mounted on: The directory where the storage device/partition (Filesystem) is mounted.

Type: The filesystem type of the mounted storage device/partition.

Size: The size of the mounted storage device/partition.

Used: The disk space that is used from the mounted storage device/partition.

Use%: The percentage of disk space that is used from the mounted storage device/partition.

Avail: The amount of free disk space of the mounted storage device/partition.

On Ubuntu, the df command will show you many loop devices as you can see in the screenshot below.

You can hide the loop devices with the -x option of the df command as follows:

You can also hide the tmpfs devices from the output of the df command.

To hide the tmpfs devices from the output of the df command as well, run the df command with the -x option as follows:

Now, the output looks much cleaner. If you want, you can remove the udev devices from the df command’s output.

To remove the udev devices from the output of the df command as well, run the df command as follows:

Only the physical storage devices and partitions will be displayed in the output of the df command. The output looks much nicer than before as well.

Читайте также:  Linux postgresql добавление пользователей

Way 2: Using the lsblk Command

The lsblk command-line program is preinstalled on almost every Linux distribution you will find. You can use the lsblk command-line program to find the Filesystem type of all (mounted and unmounted) the storage devices and partitions of your computer.

To find the filesystem type of all (mounted and unmounted) the storage devices and partitions of your computer, run the lsblk command as follows:

The lsblk command will show you the following information:
NAME: The storage device name or partition name of a storage device.

MOUNTPOINT: The directory where the storage device/partition (Filesystem) is mounted (if mounted).

FSTYPE: The filesystem type of the storage device/partition.

LABEL: The filesystem label of the storage device/partition.

UUID: The UUID (Universally Unique IDentifier) of the filesystem of the storage device/partition.

FSUSE%: The percentage of disk space that is used from the storage device/partition.

FSAVAIL: The amount of free disk space of the storage device/partition

Just as before, you can hide the loop devices from the output of the lsblk command.

To hide the loop devices from the output of the lsblk command, run the lsblk command with the -e7 option as follows:

As you can see, all the loop devices are removed from the output of the lsblk command. The output looks a lot cleaner than before.

Way 3: Using the blkid Command

The blkid command-line program is preinstalled on almost every Linux distribution you will find. You can use the blkid command-line program to find the Filesystem type of all (mounted and unmounted) the storage devices and partitions of your computer.

To find the filesystem type of all (mounted and unmounted) the storage devices and partitions of your computer, run the blkid command as follows:

The lsblk command will show you the following information:
NAME: The name of the storage device or partition name of the storage device. i.e. /dev/sda1, /dev/sda5.

UUID: The UUID (Universally Unique IDentifier) of the filesystem of the storage device/partition.

TYPE: The filesystem type of the storage device/partition.

PARTUUID: The UUID (Universally Unique IDentifier) of the partition.

You can also hide the loop devices from the output of the blkid command as before.

To hide the loop devices from the output of the blkid command, run the blkid command as follows:

As you can see, the loop devices are not displayed in the output of the blkid command. The output looks much nicer than before.

Way 4: Using the file Command

The file command-line program is preinstalled on almost every Linux distribution you will find. You can use the find command-line program to identify the file type of a file on Linux. As every device is considered a file in Linux, you can use the find command-line program to determine the filesystem type of a storage device or partition in Linux.

For example, to determine the filesystem type of the partition sdb1, you can run the file command as follows:

If you read the file command’s output, you can see that the sdb1 partition is using the FAT32 filesystem.

In the same way, you can find the filesystem type of the sda5 partition with the file command as follows:

As you can see, the partition sda5 is using the EXT4filesystem.

Читайте также:  Команда линукс текущее время

Way 5: Using the mount Command and /etc/mtab File

The /etc/mtab file contains an entry for all the mounted storage devices and partitions of your computer. You can read this file to find the filesystem type of your storage devices and partitions. The mount command-line program also prints the contents of the /etc/mtab file. So, you can use the mount command-line program as well to find the same data.

You can read the contents of the /etc/mtab file with the following command:

As you can see, there is a lot of mount information in the /etc/mtab file.

You can find the same information with the mount command as you can see in the screenshot below.

As the /etc/mtab file or the mount command’s output has many mount entries, it’s hard to interpret it. You can use the grep command to filter the output and find what you need very easily.

For example, to find the filesystem type of the sda1 partition using either the mount command or /etc/mtab file, run one of the following commands:

As you can see, the filesystem type of the sda1 partition is FAT32/vfat

.

In the same way, to find the filesystem type of the sda5 partition using either the mount command or /etc/mtab file, run one of the following commands:

As you can see, the filesystem type of the sda5 partition is EXT4.

Way 6: Using the /etc/fstab File

The /etc/fstab file keeps an entry for each of the storage devices or partitions that is to be mounted automatically at boot time. So, you can read this file to find the filesystem type of your desired storage device or partition.

Suppose your computer is not configured to mount a storage device or partition at boot time automatically. In that case, it’s very likely that there won’t be any entry for that storage device or partition in the /etc/fstab file. In that case, you won’t find any information on that storage device or partition in the /etc/fstab file. You will have to use the other methods described in this article to find the storage device’s filesystem type or partition.

You can read the contents of the /etc/fstab file with the following command:

The contents of the /etc/fstab file.

You can see that the storage device or partition with the UUID 3f962401-ba93-46cb-ad87-64ed6cf55a5f uses the EXT4 filesystem.

The storage device or partition that has the UUID dd55-ae26 is using the vfat/FAT32 filesystem.

The lines starting with a # in the /etc/fstab file is a comment. These lines don’t have a real purpose. They are used for documentation purposes only.

If you want, you can hide them using the grep command as follows:

As you can see, the comments are gone, and the output looks a lot cleaner than before.

The /etc/fstab file uses UUID instead of the storage device name or partition name by default. You can use the blkid command to convert the UUID to storage device name or partition name.

For example, to convert the UUID 3f962401-ba93-46cb-ad87-64ed6cf55a5f to the name of the storage device or partition, run the blkid command as follows:

As you can see, the partition sda5 has the UUID 3f962401-ba93-46cb-ad87-64ed6cf55a5f.

In the same way, you can find the storage device or partition name that has the UUID DD55-AE26 as follows:

Читайте также:  Настройка proxy kali linux

As you can see, the partition sda1 has the UUID DD55-AE26.

Conclusion:

This article has shown you different ways to determine the filesystem type of a storage device/partition in Linux. I have shown you how to use the df, lsblk, blkid, file, and mount command to determine the filesystem type of the Linux storage devices and partitions. I have also shown you how to determine the filesystem type of the storage devices and partitions of your Linux system by reading the /etc/mtab and /etc/fstab files.

References:

About the author

Shahriar Shovon

Freelancer & Linux System Administrator. Also loves Web API development with Node.js and JavaScript. I was born in Bangladesh. I am currently studying Electronics and Communication Engineering at Khulna University of Engineering & Technology (KUET), one of the demanding public engineering universities of Bangladesh.

Источник

Как узнать файловую систему Linux

Файловая система определяет каким образом будут хранится файлы, какие правила их именования будут применяться какой максимальный размер файла, а также можно ли увеличивать или уменьшать размер раздела. В Linux существует огромное количество файловых систем. Самая популярная из них это Ext4, но кроме неё существуют Btrfs, XFS, ZFS, RaiserFS, GlusterFS и многие другие.

В этой статье мы поговорим о том как определить в какую файловую систему отформатирован раздел. Это довольно простая задача и для её решения существует множество различных утилит.

Как узнать файловую систему Linux

1. Утилита Gnome Диски

В графическом интерфейсе можно определить файловую систему с помощью утилиты Gnome Диски. Откройте программу из главного меню, затем выберите нужный диск, а потом нужный раздел. Тут вы сможете видеть куда примонтирован этот раздел и его файловую систему:

2. Утилита Gparted

Программа Gparted тоже предоставляет такую информацию. Если программа ещё не установлена для установки выполните:

Затем запустите её из главного меню и выберите нужный диск. Файловая система отображается в одноимённой колонке:

3. Команда df

Программа df в Linux позволяет узнать список примонтированных разделов, свободное место на них, а также узнать файловую систему Linux, но для этого надо добавить опцию -T. Для просмотра файловой системы только на физических дисках выполните:

В выводе утилиты много лишнего, поэтому я отфильтровал только разделы на NVMe диске.

4. Команда fsck

Если раздел ещё не примонтирован, а вам надо узнать его файловую систему в терминале, то следует использовать программу fsck. Обычно она применяется для восстановления файловых систем, но опция -N позволяет узнать файловую систему:

Вместо nvme0n1p6 вам нужно указать ваш раздел диска, например, /dev/sda1.

5. Команда lsblk

Утилита lsblk тоже позволяет выводить файловую систему. Для этого надо использовать опцию -f:

6. Команда mount

Команда mount показывает всё примонтированные разделы и их точки монтирования если её запустить без параметров. Например:

7. Команда blkid

Утилита blkid позволяет узнать параметры блочного устройства. Очень часто используется для просмотра UUID, однако может показать и файловую систему. Просто укажите устройство раздела:

8. Команда file

Обычно утилита file используется для просмотра информации о файлах. Но если применить её к блочному устройству с опцией -s, то она покажет информацию и о нём, включая файловую систему. Чтобы открывать символические ссылки используйте опцию -L:

sudo file -sL /dev/nvme0n1p6

Выводы

Из этой статьи вы узнали как узнать тип файловой системы Linux. Как видите, существует огромное количество способов, а какими пользуетесь вы? Напишите в комментариях!

Обнаружили ошибку в тексте? Сообщите мне об этом. Выделите текст с ошибкой и нажмите Ctrl+Enter.

Источник

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