Linux detect file system

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.

Читайте также:  Удаленное управление linux через ssh

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]

Источник

How to determine the filesystem of an unmounted device? [duplicate]

I’m looking for a command that yields the filesystem type as mount would use/detect it, without actually mounting it. It should also work e.g. for LUKS encrypted devices (where file -s yields «LUKS encrypted file» instead of «crypto_LUKS»). Surely there is a more convenient way than parsing fsck -N /dev/whatever ‘s output (which may use stderr depending on the existence of a corresponding fsck.TYPE )?

@StephaneChazelas that’s not a duplicate, df reads mount table and doesn’t show about unmounted ones.

1 Answer 1

There are multiple ways to get this information. Most of them require you to parse the output of another command.

Читайте также:  Linux program files x86

    Run # fdisk /dev/sdX -l to get a basic idea of the filesystem structure. The output is something like this:

Disk /dev/sda: 320.1 GB, 320072933376 bytes, 625142448 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 identifier: 0x9f7685a8 Device Boot Start End Blocks Id System /dev/sda1 63 289169 144553+ 83 Linux /dev/sda2 289170 459121634 229416232+ 83 Linux /dev/sda3 459121635 461129759 1004062+ 82 Linux swap / Solaris /dev/sda4 * 461129760 625142447 82006344 7 HPFS/NTFS/exFAT 
/dev/sda1: LABEL="boot" UUID="aa84c5a8-6408-4952-b577-578f2a67af86" TYPE="ext2" /dev/sda2: LABEL="root" UUID="a430e0ef-fd35-432f-8b9a-75a49b89ad8a" TYPE="ext4" /dev/sda3: LABEL="swap" UUID="e388806a-dc27-4f4e-a136-3d1ff4e53962" TYPE="swap" /dev/sda4: UUID="088E027A8E026114" TYPE="ntfs" 
Model: ATA WDC WD3200BEVT-7 (scsi) Disk /dev/sda: 320GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 32.3kB 148MB 148MB primary ext2 2 148MB 235GB 235GB primary ext4 3 235GB 236GB 1028MB primary linux-swap(v1) 4 236GB 320GB 84.0GB primary ntfs boot 
Filesystem Type 1K-blocks Used Available Use% Mounted on rootfs rootfs 225815276 99381340 114963128 47% / dev devtmpfs 1538396 0 1538396 0% /dev run tmpfs 1541260 416 1540844 1% /run /dev/sda2 ext4 225815276 99381340 114963128 47% / tmpfs tmpfs 1541260 360 1540900 1% /dev/shm tmpfs tmpfs 1541260 0 1541260 0% /sys/fs/cgroup tmpfs tmpfs 1541260 900 1540360 1% /tmp /dev/sda1 ext2 139985 30386 102372 23% /boot /dev/sda4 fuseblk 82006340 79676036 2330304 98% /mnt 

Another command that can come handy is # file -sL /dev/sdXY . This has one downside in that it does not work with the full block device. Requires the exact device to be passed. The output is quite neat though:

/dev/sda1: Linux rev 1.0 ext2 filesystem data (mounted or unclean), UUID=aa84c5a8-6408-4952-b577-578f2a67af86, volume name "boot" 

All of these will always be output to stdout. You can parse them in a script if required.

Источник

How to Show File System Type in Linux

Every object in a Linux computer is considered a file. A Linux file system is an organization that is used to store and manage files on a storage device. The storage device is logically divided using the file system to keep different types of files arranged for effective search, access, deletion, and modification. Linux supports various file systems, including ext2, ext3, and ext4.

In this tutorial, we will learn how to show file system type in Linux. We can determine it using different methods.

1. Using df — T Command

The df command, also known as disk file system type, in Linux is used to check the disk usage on a storage device. This command-line utility is pre-installed on most of the major Linux operating system distributions. By default, the df command displays only the available and used disk space, but you can use the -T flag to display the file system of all the storage devices that are mounted:

Showing filesystem type using df

The df command in this output shows the following information:

  • Filesystem – name of the currently mounted partition or the storage device.
  • Type – storage device or partition file system types.
  • Size – total size of the mounted partition or storage device.
  • Used – consumed disk space of the mounted partition or storage device.
  • Avail – amount of available disk space of the mounted partition or storage device.
  • Use% – percentage of used disk space in the mounted partition or storage device.
  • Mounted on – name of the directory where the partition or storage device is mounted.
Читайте также:  Установка alt linux ubuntu

To display the metadata of a specific storage device or partition, specify the partition name with the df command. For example, to check the FS of the root partition, type:

2. Using lsblk -fs Command

To identify the filesystem type -fs option with lsblk:

Источник

8 способов определить тип файловой системы в Linux (Ext2, Ext3 или Ext4, FAT32, NTFS)

Файловая система — это способ, которым файлы именуются, хранятся, извлекаются, а также обновляются на диске или разделе хранения; это способ организации файлов на диске.

Файловая система разделена на два сегмента, которые называются: данные пользователя и метаданные (имя файла, время его создания, время изменения, его размер и расположение в иерархии каталогов и т. д.).

В этом руководстве мы расскажем о семи способах определения типа файловой системы Linux, например Ext2, Ext3, Ext4, BtrFS, GlusterFS и многих других.

1. Использование команды df

Команда df сообщает об использовании дискового пространства файловой системой, чтобы включить тип файловой системы в конкретный раздел диска, используйте флаг -T, как показано ниже:

Полное руководство по использованию команды df можно найти в наших статьях:

2. Использование команды fsck

fsck используется для проверки и, при необходимости, для восстановления файловых систем Linux, она также может печатать тип файловой системы на указанных разделах диска.

Флаг -N отключает проверку файловой системы на наличие ошибок, он просто показывает, что будет сделано (но нам нужен только тип файловой системы):

fsck -N /dev/sda fsck -N /dev/sdb2

3. Использование команды lsblk

lsblk отображает блочные устройства, при использовании с параметром -f он также печатает тип файловой системы на разделах:

Вариант этой команды, выводящей краткие сведение об имени и файловой системе:

4. Использование команды mount

Команда mount используется для монтирования файловой системы в Linux, её также можно использовать для монтирования образа ISO, монтирования удалённой файловой системы Linux и многого другого.

При запуске без аргументов она выводит информацию о разделах диска, включая тип файловой системы, как показано ниже:

5. Использование команды blkid

Команда blkid используется для поиска или печати свойств блочного устройства, просто укажите раздел диска в качестве аргумента, например:

6. Использование команды file

Команда file определяет тип файла, флаг -s разрешает чтение блочных или символьных файлов, а -L разрешает переход по символическим ссылкам:

7. Использование findmnt

Программа findmnt показывает множество информации о блочных устройствах, точках монтирования, опциях монтирования и прочей сопутствующей информации. В том числе выводится информация о файловой системе устройств:

8. Использование файла fstab

Файл /etc/fstab — это файл статической информации о файловой системе (такой, как точка монтирования, тип файловой системы, параметры монтирования и т. д.):

Всё готово! В этом руководстве мы объяснили восемь способов определить тип файловой системы Linux. Вы знаете какой-либо метод, не упомянутый здесь? Поделитесь с нами в комментариях.

Связанные статьи:

Источник

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