- Command line option to check which filesystem I am using?
- 9 Answers 9
- Как узнать файловую систему Linux
- Как узнать файловую систему Linux
- 1. Утилита Gnome Диски
- 2. Утилита Gparted
- 3. Команда df
- 4. Команда fsck
- 5. Команда lsblk
- 6. Команда mount
- 7. Команда blkid
- 8. Команда file
- Выводы
- 6 ways to find out your Linux file system type
- Ways to find out your Linux system’s file type
- 1. The DF command
- 2. The FSCK command
- 3. The lsblk command
- 4. The mount command
- 5. The blkid command
- 6. The file command
Command line option to check which filesystem I am using?
Is there a command that will show which file system (ext3, ext4, FAT32, . ) the various partitions and disks are using? Similar to how sudo fdisk -l lists information about disks and partitions?
What do you mean by «similar to» sudo fdisk -l ? . Even when the drive is not mounted, fisk gives you the file system type, and it is a command line tool. I unmounted two of my drives (a USB, and an Internal) and this worked fine: sudo fdisk -l|grep «^/dev»
@fred fdisk says things like «Linux» and «Linux swap», can’t see that it tells me whether it’s ext3 or ext4.
Don’t go by the name;; go by the filesystem Id . if its 83 , fdisk reports it as «Linux , **gpart** as mentioned by Luke Maurer) reports it as **ext2** ,, same thing.. The drives I tested are Ext4 (but were reported as ‘ext2’ and ‘Linux’ by the two apps), but it seems that this identity is a higher abstraction. Whether you really need to go further is up to you. but the **Id** certainly gives you a pretty closes idea. (if you need to know specifically, perhaps ‘gpart in full scan mode will do it. (I havent tried its full scan, but I suspect it won’t say much more (??)..
9 Answers 9
me@hostname:/$ mount /dev/sda1 on / type ext4 (rw,errors=remount-ro) proc on /proc type proc (rw,noexec,nosuid,nodev) none on /sys type sysfs (rw,noexec,nosuid,nodev) none on /sys/fs/fuse/connections type fusectl (rw)
Except that the disks aren’t mounted — I’m trying to figure out which FS to put in /etc/fstab for a USB external disk
@frabjous Why use Nautilus? Could also just mount it on the command line and then check; this usually works even if you don’t specify the filesystem.
Found a solution in ubuntuforums: blkid
sudo blkid /dev/sda1 /dev/sda1: UUID=". " TYPE="ext4"
sudo blkid /dev/sdf1 /dev/sdf1: LABEL="backup" UUID=". " TYPE="ext3"
sudo blkid /dev/md0 /dev/md0: LABEL="raid" UUID=". " TYPE="ext4"
Mount without specifying filesystem (commenting out any entries in fstab) works as well:
sudo mount /dev/sdf1 /mnt/tmp mount | grep /mnt/tmp /dev/sdf1 on /mnt/tmp type ext3 (rw)
df -h -T will list all disks used with filesystem type.
This command will also let you query which filesystem is in use for an arbitrary given directory.
For example, the following output shows that the /usr/local/lib directory is on the /dev/xvdb device, and it’s formatted with the ext4 filesystem.
user@disp556:~$ sudo df -h -T /usr/local/lib Filesystem Type Size Used Avail Use% Mounted on /dev/xvdb ext4 2.0G 135M 1.8G 7% /usr/local user@disp556:~$
Will give you the filesystem of any attached devices, whether they are mounted or not.
It also gives you other useful information for creating the needed line for your fstab file such as the UUID.
All of the solutions suggested here are valid, but don’t allow to see if for instance a partition is FAT16 or FAT32. For this level of detail, the best command is
/dev/sdc: DOS/MBR boot sector, code offset 0x58+2, OEM-ID "MSWIN4.1", sectors/cluster 32, Media descriptor 0xf8, sectors/track 63, heads 255, sectors 15794176 (volumes > 32 MB) , FAT (32 bit), sectors/FAT 3856, reserved 0x1, serial number 0x4c437f55, unlabeled
It’s somewhat overkill, but there’s always gpart . It’s meant for when the partition table is broken, but it does tell you what type all the filesystems it can find are.
EDIT: This doesn’t seem to work if something on the disk is mounted already, though (I just tried it on my running system).
Theoretically, if you just want it to print the partition table, you can use a command like this (from the man page):
But again I can’t try it right now; not sure if it’ll tell you the filesystems if it’s not doing a scan.
I just tried it. I unmounted my «sdb» data drive via Nautilus.. It’s mounpoint directory showed as «Total 0» via «ls -l» and anothe File Browser (PCMan) prompted me to mount it. but even though it wasn’t mounted gpart did return basic partiton information; in particuar, it did show the filesystem
It works, but a bit slower than the other answers — it takes a while to scan a 1TB disk. Still thanks for the pointer to a useful tool, I’m sure gpart will come in handy.
A nice simple tool to find out information about attached devices. and to do backups is the fsarchiver program.
You probably have to install it to use it.
The command I usually use to find out what is on the system is :
sudo fsarchiver probe simple
and that comes back with something like :
[======DISK======] [=============NAME==============] [====SIZE====] [MAJ] [MIN] [sda ] [WDC WD1001FALS-0 ] [ 931.51 GB] [ 8] [ 0] [sdb ] [ST31000524AS ] [ 931.51 GB] [ 8] [ 16] [sdg ] [DataTraveler 3.0 ] [ 29.31 GB] [ 8] [ 96] [=====DEVICE=====] [==FILESYS==] [======LABEL======] [====SIZE====] [MAJ] [MIN] [sda1 ] [xfs ] [ ] [ 500.00 MB] [ 8] [ 1] [sda2 ] [LVM2_member] [ ] [ 931.02 GB] [ 8] [ 2] [sdb5 ] [ext4 ] [mydisk_data_01 ] [ 931.51 GB] [ 8] [ 21] [sdg1 ] [vfat ] [KINGSTON ] [ 29.30 GB] [ 8] [ 97] [dm-0 ] [xfs ] [ ] [ 100.00 GB] [253] [ 0] [dm-1 ] [swap ] [ ] [ 34.00 GB] [253] [ 1] [dm-2 ] [xfs ] [ ] [ 797.02 GB] [253] [ 2]
Как узнать файловую систему 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.
6 ways to find out your Linux file system type
A ny Operating system in the market whether its Windows, Linux, Unix, macOS, and any other, must be able to access and manage files and data on storage devices.
How an operating system accesses and manages these files is determinant on the file system used. For example, a USB drive formatted using the basic Linux file system (ext4) is inaccessible on a Windows computer.
A lot of Linux distributions support quite a variety of file systems. They include ext, ext2, ext3, ext4, hpfs, iso9660, JFS, minix, msdos, ncpfs nfs, NTFS, proc, Reiserfs, smb, sysv, vfat, XFS, xiafs, and many more.
With Linux operating systems, every data is configured as a file, from text data, images, device drivers, and many more. Every file system is divided into two parts; User data, which contains file system information and metadata, which holds the inode information.
The inode(metadata) holds information like Filename, type of file, file-permission, file-owner, Group-name, file-size, time-created, modified-time, time-deleted, hard-link, and soft-link, location in the directory hierarchy, etc..
Ways to find out your Linux system’s file type
In this post, we will put our focus on the Linux file systems. We will discuss ways that you can use to find out your Linux file system type. Most of them are commands that are executed on the Linux Terminal. Our distro of choice is Ubuntu 19.04 (Disco Dingo) and Fedora.
1. The DF command
The df Linux command stands for Disk File-system. DF command alone displays the disk space utilization on your operating system. However, several parameters can be added to give it a lot more functionality. Execute df –help to see all of the parameters available.
To display the file system, you will need to include the -Th parameter. In case you need elevated privileges, add the sudo command.
fosslinux-tuts:~$ sudo df -Th
The file system-type is listed under the Type column. You can also use it with a combination of other commands like grep to get detailed information. For example, to know the file system of all device ( /dev ) files, execute the command below.
fosslinux-tuts:~$ sudo df -Th | grep dev
Alternatively, use the df command to display the file system of a specific device. For example, the df command below prints the file system of the partition holding your current operating system.
fosslinux-tuts:~$ df -Th /boot
2. The FSCK command
The fsck command checks the Linux file system and attempts repairs in case of an issue. However, with an additional parameter -N and the device path, it shows you the file system type.
fosslinux-tuts:~$ fsck -N /dev/sda
fosslinux-tuts:~$ fsck -N /dev/sdb1
3. The lsblk command
The lsblk command displays all the necessary information about all block devices present or a specific device depending on the path used. lsblk command gathers information by reading the sysfs filesystem and udev db. To display the file system type with lsblk, we will add the -f parameter.
Execute the command lsblk -f or lsblk -fs
fosslinux-tuts:~$ lsblk -f
lsblk -f command
4. The mount command
The mount command is used to load a file system in a Linux operating system. Other than that, it loads a remote file system or loads an ISO image.
fosslinux-tuts:~$ mount | grep "/dev"
5. The blkid command
The blkid command displays the block device information, i.e., filesystem or swap. You will need to add the device label when using the blkid command.
fosslinux-tuts:~$ blkid /dev/sda
6. The file command
The file command determines the type of a file in a Linux system. It displays all the information about a given file. See the below example:
fosslinux-tuts:~$ file DSC_0627.JPG
To determine the disk file system, we will need to add the -s parameter.
fosslinux-tuts:~$ file -sL /dev/sda1
file -sl _dev_sda1 command
Note, the file command might require elevated privileges; in such a case, use the sudo command.
fosslinux-tuts:~$ sudo file -sL /dev/sdb1
That’s it! Those are six ways to use to identify the file system used on your Linux system. Is there another method we have not listed? Please let our readers know in the comment section below.