- Обозначения дисков и дисковых разделов в системах linux.
- Диски.
- Разделы.
- 7 Ways to Determine the File System Type in Linux (Ext2, Ext3 or Ext4)
- 1. Using df Command
- 2. Using fsck Command
- 3. Using lsblk Command
- 4. Using mount Command
- 5. Using blkid Command
- 6. Using file Command
- 7. Using fstab File
- Related Posts
- 15 thoughts on “7 Ways to Determine the File System Type in Linux (Ext2, Ext3 or Ext4)”
Обозначения дисков и дисковых разделов в системах linux.
Один из основных постулатов Unix/Linux — «всё есть файл», и жесткие диски — не исключение.
Каждый найденный ядром диск, отображается в виде файла в специальном каталоге устройств «/dev»
Диски.
SATA/ SCSI HDD, а также многие переносные накопители типа USB flash:
На новых Linux-ядрах >=2.6.21 для некоторых чипсетов может действовать новая система именования IDE-дисков, при которой IDE-устройства именуются также как и SATA/ SCSI .
Приведем наглядный пример:
сохранит MBR c первого диска SATA/ SCSI в системе в обычный файл MY_SATA_MBR.BIN.
Получить список обнаруженных системой дисков можно выполнив команду fdisk -l:
v-serv:~# fdisk -l Disk /dev/sda: 200.0 GB, 200048565760 bytes 255 heads, 63 sectors/track, 24321 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 3824 30716248+ c W95 FAT32 (LBA) /dev/sda2 3825 4532 5687010 83 Linux /dev/sda3 4533 5140 4883760 83 Linux /dev/sda4 5141 24321 154071382+ 5 Extended /dev/sda5 5141 5991 6835626 83 Linux /dev/sda6 5992 7207 9767488+ 83 Linux /dev/sda7 7208 10854 29294496 83 Linux /dev/sda8 10855 24321 108173646 83 Linux Disk /dev/sdb: 320.0 GB, 320071851520 bytes 255 heads, 63 sectors/track, 38913 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdb1 1 365 2931831 83 Linux /dev/sdb2 366 1216 6835657+ 83 Linux /dev/sdb3 1217 1277 489982+ 82 Linux swap / Solaris /dev/sdb4 1278 38913 302311170 5 Extended /dev/sdb5 1278 4924 29294496 83 Linux /dev/sdb6 4925 5046 979933+ 83 Linux /dev/sdb7 5047 6870 14651248+ 83 Linux /dev/sdb8 6871 7478 4883728+ 83 Linux /dev/sdb9 7479 8086 4883728+ 83 Linux /dev/sdb10 8087 21553 108173646 83 Linux /dev/sdb11 21554 33711 97659103+ 83 Linux /dev/sdb12 33712 38913 41785033+ 83 Linux
Разделы.
Конкретный раздел (синонимы — том, партиция) определяется по номеру, после обозначения устройства, начиная с 1. Например: hdc5 — пятый том мастера на втором контроллере IDE, sde3 — третий том пятого SATA/ SCSI накопителя.
Например: как быстро уничтожить форматированный раздел — заполним нулевыми байтами первые 10MB:
dd if=/dev/zero count=Разделы могут быть:
расширенными (Extended) — логические разделы (обычно только один) с которыми нельзя работать, контейнер для дополнительных разделов;
Кроме номера и размера, каждый раздел имеет свой тип, который обозначен одним байтом:
7 Ways to Determine the File System Type in Linux (Ext2, Ext3 or Ext4)
A file system is the way in which files are named, stored, retrieved as well as updated on a storage disk or partition; the way files are organized on the disk.
A file system is divided in two segments called: User Data and Metadata (file name, time it was created, modified time, it’s size and location in the directory hierarchy etc).
In this guide, we will explain seven ways to identify your Linux file system type such as Ext2, Ext3, Ext4, BtrFS, GlusterFS plus many more.
1. Using df Command
df command reports file system disk space usage, to include the file system type on a particular disk partition, use the -T flag as below:
$ df -Th OR $ df -Th | grep "^/dev"
For a comprehensive guide for df command usage go through our articles:
2. Using fsck Command
fsck is used to check and optionally repair Linux file systems, it can also print the file system type on specified disk partitions.
The flag -N disables checking of file system for errors, it just shows what would be done (but all we need is the file system type):
$ fsck -N /dev/sda3 $ fsck -N /dev/sdb1
3. Using lsblk Command
lsblk displays block devices, when used with the -f option, it prints file system type on partitions as well:
4. Using mount Command
mount command is used to mount a file system in Linux, it can also be used to mount an ISO image, mount remote Linux filesystem and so much more.
When run without any arguments, it prints info about disk partitions including the file system type as below:
5. Using blkid Command
blkid command is used to find or print block device properties, simply specify the disk partition as an argument like so:
6. Using file Command
file command identifies file type, the -s flag enables reading of block or character files and -L enables following of symlinks:
7. Using fstab File
The /etc/fstab is a static file system info (such as mount point, file system type, mount options etc) file:
That’s it! In this guide, we explained seven ways to identify your Linux file system type. Do you know of any method not mentioned here? Share it with us in the comments.
Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.
Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.
Related Posts
15 thoughts on “7 Ways to Determine the File System Type in Linux (Ext2, Ext3 or Ext4)”
will create a ext2 filesystem on image1, if its not big enough (warning “Filesystem too small for a journal” means a filesystem without a journal, a.k.a. ext2, is created) If you don’t realize this and nevertheless mount it as ext4. The df and mount methods above will mirror back ext4:
$ df -Th /tmp/mnt* Filesystem Type Size Used Avail Use% Mounted on /dev/loop4 ext4 1003K 24K 908K 3% /tmp/mnt1 /dev/loop5 ext4 987K 33K 812K 4% /tmp/mnt2 $ mount | grep mnt . /home/mallikab/image1 on /tmp/mnt1 type ext4 (rw,relatime,seclabel) /home/mallikab/image2 on /tmp/mnt2 type ext4 (rw,relatime,seclabel,data=ordered)
$ fsck -N /tmp/mnt1 fsck from util-linux 2.23.2 [/sbin/fsck.ext2 (1) -- /tmp/mnt1] fsck.ext2 /tmp/mnt1 $ fsck -N /tmp/mnt2 fsck from util-linux 2.23.2 [/sbin/fsck.ext4 (1) -- /tmp/mnt2] fsck.ext4 /home/mallikab/image2 $ file -sL /home/mallikab/image2 /home/mallikab/image2: Linux rev 1.0 ext4 filesystem data, UUID=b4e8e086-54ca-4d9d-9f38-32bbed211e6b (needs journal recovery) (extents) (64bit) (huge files) $ file -sL /home/mallikab/image1 /home/mallikab/image1: Linux rev 1.0 ext2 filesystem data (mounted or unclean), UUID=09b3a8c9-0b6d-43c5-b195-c45f6c091765 (extents) (64bit) (huge files) hm, although fsck doesn't indicate ext2 unless the images are mounted, i.e. $ fsck -N ~/image1 fsck from util-linux 2.23.2 [/sbin/fsck.ext4 (1) -- /home/mallikab/image1] fsck.ext4 /home/mallikab/image1
The only working method for me was ‘ lsblk -f ‘; the other replied “fuseblk“, “HPFS/NTFS/exFAT” or nothing. Reply