File systems ext2 ext3 ext4. How to access ext2, ext3, ext4 partitions from Windows? Network file systems

File system (English file system) - an order that determines the way of organizing, storing and naming data on storage media of IT equipment (using portable flash memory cards in portable electronic devices for repeated recording and storage of information: digital cameras, mobile phones, etc.) ) and computer technology. It defines the format of the content and physical storage of information, which is usually grouped in the form of files. The specific file system determines the size of the file name (folder), the maximum possible file and section size, and a set of file attributes. Some file systems provide service capabilities, such as access control or file encryption.

Filesystem tasks

The main functions of any file system are aimed at solving the following tasks:

file naming;

software interface for working with files for applications;

mapping the logical model of the file system to the physical organization of the data warehouse;
organization of file system resilience to power failures, hardware and software errors;

In multi-user systems, another task appears: protecting the files of one user from unauthorized access by another user, as well as ensuring joint work with files, for example, when a file is opened by one of the users, for others the same file will be temporarily available in read-only mode ...

The file system is the basic structure used by a computer to organize information on a hard drive. When installing a new hard drive, it must be partitioned and formatted for a specific file system, after which data and programs can be stored on it. There are three possible file systems on Windows: NTFS, FAT32, and the rarely used legacy FAT system (also known as FAT16).

NTFS is the preferred file system for this version of Windows. It has many advantages over the earlier FAT32 system; some of them are listed below.

Ability to automatically recover from some disk errors (FAT32 does not have this ability).
Improved support for large hard drives.
Higher degree of security. It is possible to use permissions and encryption to deny user access to certain files.

The FAT32 file system and the rarely used FAT system were used in previous versions of Windows, including Windows 95, Windows 98, and Windows Millenium Edition. The FAT32 file system does not provide the level of security provided by NTFS, so if your computer has a partition or volume formatted for FAT32, the files on that partition are visible to anyone with access to the computer. The FAT32 file system also has file size limits. It is not possible to create a FAT32 partition larger than 32GB in this version of Windows. Also, a FAT32 partition cannot contain a file larger than 4GB.

The main reason for using the FAT32 system is that the computer can run both Windows 95, Windows 98, or Windows Millenium Edition, and this version of Windows (multi-operating system configuration). To create such a configuration, it is necessary to install the previous version of the operating system on a partition formatted for FAT32 or FAT, making it the main one (the main partition may contain the operating system). Other partitions accessed from previous versions of Windows must also be formatted for FAT32. Earlier versions of Windows can only access network NTFS partitions or volumes. NTFS partitions on the local computer will be inaccessible.

FAT - pros:

It requires a little RAM to work effectively.
Fast work with small and medium catalogs.
The disk makes fewer head movements on average (compared to NTFS).
Efficient work on slow disks.

FAT - cons:

Catastrophic loss of performance with increased fragmentation, especially for large drives (FAT32 only).
Difficulties with random access to large (say, 10% or more of the disk size) files.
Very slow work with directories containing a large number of files.

NTFS - pros:

Fragmentation of files has almost no consequences for the file system itself - the performance of a fragmented system is degraded only in terms of access to the file data itself.
The complexity of the directory structure and the number of files in one directory do not pose any particular obstacles to performance.
Quick access to an arbitrary fragment of a file (for example, editing large .wav files).
Very fast access to small files (several hundred bytes) - the entire file is in the same place as the system data (MFT record).

NTFS - cons:

Significant requirements for system memory (64 MB is the absolute minimum, more is better).
Slow drives and controllers without Bus Mastering severely degrade NTFS performance.
Medium-sized directories are difficult to work with because they are almost always fragmented.
A disk that works for a long time in a 80% - 90% full state will show extremely low performance.

The following file systems are considered as "native" for Linux (that is, those on which it can be installed and from which it is able to start): ext2fs, ext3fs, ext4fs, ReiserFS, XFS, JFS. It is they who are usually offered to choose from when installing the vast majority of distributions. Of course, there are ways to install Linux on FAT / VFAT / FAT32 file systems, but this is only for those honeys and monsieurs who understand a lot about perversions, and I will not talk about them.

The main criteria when choosing a file system are usually reliability and performance. In some cases, it is also necessary to take into account the factor of compatibility - in this case, it means the ability of other operating systems to access a particular file system.
I'll start with ReiserFS - because the reason for writing this note was the question: what should be considered small files? After all, it is generally known that it is the efficiency of working with small files that is the strong point of this file system.

So, small files mean files smaller than the logical block of the file system, which in Linux in most cases is equal to four kilobytes, although it can be set during formatting within certain limits (depending on the specific FS). There are countless such small files in any Unix-like OS. Typical examples are the files that make up the FreeBSD ports tree, Gentoo ports, and similar port systems.
In most file systems, such mini-files have their own inode (an information node containing meta information about a file) and a data block, which leads to both a waste of disk space and a decrease in the speed of file operations. In particular, this is the reason for the catastrophic reverie of the FreeBSD file system (both old, UFS, and new, UFS2) when working with its own ports system.

In the ReiserFS file system, in such cases, separate blocks for data are not allocated - it manages to cram the file data directly into the area of \u200b\u200bits inode. Due to this, both disk space is saved, and performance increases - literally several times in comparison with all other FS.
Such handling of small files of ReiserFS caused the legend of its unreliability. Indeed, in the event of a file system crash (that is, the destruction of service areas), the data co-located with its inodes disappears along with them - and irrevocably. Whereas in those file systems where inodes and data blocks are always spatially separated, the latter can theoretically be restored. So, for ext2 / ext3 there are even tools to do this.

However, like any legend, this one only gives the impression of reliability. First, irrecoverable data loss applies only to very small files. There are practically no such users among the users, while all the others are easily restored from the distribution kit.
Secondly, speaking about the possibility of recovering data from blocks that have lost their binding to their inodes, I did not accidentally use the word "theoretical". Because in practice, this activity is extremely laborious and does not give a guaranteed result. Everyone who has had to do this will agree that it is possible to surrender to it only out of complete despair. And this applies to all Linux file systems. So this aspect can be neglected when choosing a file system.

In terms of overall performance, ReiserFS is definitely faster than all other journaling FS, and in some respects it surpasses ext2. Comparison of the speed of some common file file operations can be found here.
But with the compatibility of ReiserFS, the situation is somewhat worse. As far as I know, it is impossible to access it from an OS of the Windows family. Some BSD operating systems (DragonFlyBSD, FreeBSD) support this file system, but in read-only mode. Even the chances that an arbitrary Linux LiveCD of yesteryear does not have ReiserFS support is not zero.

And here it is just right to remember ext3fs. Its advantage is not at all greater reliability - this is the same legend as the instability of ReiserFS. I've heard as much about ext3fs crashes as I have heard from ReiserFS. I myself have not been able to destroy either one or the other. Unless it worked with ext2 - but that was a long time ago, during the days of the 2.2 kernel (or even 2.0).

No, the main advantage of ext3fs is its compatibility - it is guaranteed to be read by any Linux system. For example, when recovering from some ancient LiveCD henchman - a situation that is practically not so incredible, I had to get into it. Again, most BSD systems understand ext3fs easily (albeit without journaling). For Windows, there are also, as far as I know, all kinds of drivers and plug-ins for common file managers (such as Total Commander) that provide access to partitions with ext2fs / ext3fs.

In terms of performance, ext3fs is controversial. First, its performance is highly dependent on the logging mode, which are three: with full data logging, partial data logging and only metadata logging. In each of the modes it shows different performance on different types of file operations. However, in no case is the performance a record.

However, if the performance requirement is put in the first place, then ext2fs turns out to be out of competition - however, in this case you will have to accept the absence of journaling at all. And, consequently, with lengthy checks of the file system in case of any incorrect shutdown - and with the size of modern disks, this can take oh how long ...

The following can be said about XFS. In terms of compatibility, everything is the same as that written for ReiserFS - moreover, until some time it was not supported by the standard Linux kernel. From the point of view of performance, it does not shine on XFS either, acting in total at about the same level as ext3fs. And at the operation of deleting files, it generally demonstrates depressing slowness.
In my experience, the use of XFS pays off when working not just with large, but with very large files - which are actually just DVD images and video files.

Returning to the question of reliability. A banal power off during normal user work, as a rule, painlessly migrates all journaled file systems (and none of them ensures the safety of user operations not written to disk - rescuing drowning people here remains the work of the drowning themselves). True, for any file system, you can simulate a situation in which turning off the power will lead to more or less serious damage to it. However, in real life, such situations are unlikely to occur. And you can completely eliminate them by purchasing an uninterruptible power supply - it will give more confidence in the safety of data than the type of file system. Well, the guarantee of recovering damaged data in any case can only be their regular backup ...

I think the above information is enough for an informed choice. My personal choice over the past few years has been ReiserFS. Occasionally, on systems where it is justified to move everything out of the root partition, it is advisable to use ext3fs for the root filesystem and ReiserFS for everyone else.

If a separate partition is provided for the / boot directory (and this is recommended when the GRUB boot loader is used by its developers) - for it, no other file system except ext2fs is justified, any kind of journaling does not make sense here. Finally, if you create a separate section for all kinds of multimedia materials, then you can think about XFS.

If you approach the explanation more methodically

ext - In the early days of Linux, the dominant system was ext2 (extended file system, version 2). Since 2002, it has been replaced by the ext3 system, which is largely compatible with ext2, but also supports journaling functions, and when working with kernel versions 2.6 and higher, it also supports ACL. The maximum file size is 2 TB and the maximum file system size is 8 TB. At the end of 2008, the release of a version of ext4 was officially announced, which is backward compatible with ext3, but many features are implemented more efficiently than before. In addition, the maximum file system size is 1 EB (1,048,576 TB), which can be expected to last for a while. About reiser - The system was named after its founder, Hans Reiser, and was the first logging system to access the Linux kernel for data. The Zn version in SUSE was even considered standard for some time. The main advantages of the reiser over ext3 are its faster operation and placement efficiency when working with small files (and in the file system, as a rule, most files are small). Over time, however, the development of reisefers has stopped. It has long been announced about the release of version 4, which is still not ready, and support for version 3 has ended. About xfs - The xfs file system was originally developed for SGI workstations running on the IRIX operating system. Xfs is especially good for working with large files, in particular ideal for streaming video. The system supports quotas and extended attributes (ACL).
jfs

jfs - a66peBHaTypaJFS stands for Journaled File System. It was originally developed for IBM and then adapted for Linux. Jfs has never enjoyed much recognition in Linux and is currently dragging out a miserable existence, inferior to other file systems.
brtfs

brtfs - With the will of the leading kernel developers, the brtfs filesystem in Linux has a bright future. This system was developed from scratch at Oracle. It includes support for the device-mapper and RAID. Brtfs is most similar to Sun's ZFS. Its most interesting features include checking the file system on the go, and support for SSDs (solid-state drives are hard drives based on flash memory). Unfortunately, work on brtfs will not be completed in the foreseeable future. Fedora 11 comes with the option to install brtfs, but I only recommend it to file system developers!
There is no "fastest" or "best" file system - the estimate depends on what you intend to use the system for. Linux novice local users are advised to work with ext3, and server administrators with ext4. Of course, with ext4, the speed of work is higher than with ext3, but at the same time, in the ext4 system, the situation with data reliability is much worse - you may well lose information if the system is suddenly turned off.

If you have installed a second UNIX-like operating system on your computer, then the following file systems will come in handy when exchanging data (from one OS to another).

sysv - Used by SCO, Xenix and Coherent operating systems.

ufs - Used by FreeBSD, NetBSD, NextStep, and SunOS. Linux can only read information from such file systems, but cannot make changes to the data. To access segments from BSD, you will additionally need the BSD disklabel extension. A similar extension exists for SunOS Partition Tables.

ZFS is a relatively new system developed by Sun for Solaris. Since the ZFS code is not GPL-licensed, it cannot be integrated with the Linux kernel. For this reason, Linux only supports this filesystem indirectly through FUSE.
Windows, Mac OS X

The following file systems will be useful when communicating with MS DOS, Windows, OS / 2, and Macintosh.

vfat - used in Windows 9x / ME. Linux can read information from such partitions and make changes to it. The vfat system drivers allow to work with old MS DOS file systems (8 + 3 characters).

ntfs - the system is used in all modern versions of Windows: otNT and higher. Linux can read and modify its files.

hfs and hfsplus - These file systems are used by Apple computers. Linux can read and modify its files.

Data CDs and DVDs usually use their own file systems.

iso9660 - The file system for CD-ROMs is described in the ISO-9660 standard, which allows only short file names. Long names are supported differently on different operating systems, with a variety of incompatible extensions. Linux is capable of working with both the Rockridge extension, common in UNIX, and the Joliet extension, developed by Microsoft.

udf - this format (universal disk format) appeared and developed as the successor to ISO 9660.

Network file systems

The file systems do not have to be on the local disk - they
can connect to a computer and over a network. The Linux kernel supports a variety of network file systems, of which the following are most commonly used.

smbfs / cifs - help to map Windows or Samba network shares to a directory tree.

nfs is the most important network file system in UNIX.

coda - This system is very similar to NFS. It has many advanced features, but it is not very common.

ncpfs - runs on NetWare kernel protocol; oH is used by Novell Netware.

Virtual file systems

In Linux, there are several file systems designed not for storing data on a hard disk (or other medium), but only for exchanging information between the kernel and user programs.
devpts - This file system provides access to pseudo-terminals (PTY for short) via / dev / pts / * in accordance with the UNIX-98 specification. (Pseudo-terminals emulate a serial interface. On UNIX / Linux systems, such interfaces are used by terminal emulators such as xterm. Typically, devices such as / dev / ttypn are used. In contrast, the UNIX-98 specification defines new devices. information is reported in the text terminal H0WT0.)
proc and sysfs - The proc file system is used to display service information related to kernel and process management. In addition, the sysfs filesystem builds relationships between the kernel and hardware. Both file systems are mounted at / proc and / sys.
tmpfs - This system is built on System V shared memory. It is usually mounted at / dev / shm and provides efficient information exchange between two programs. On some distributions (eg Ubuntu) the / var / run and / var / lock directories are also created using the tmpfs filesystem. The files in these directories are used by some network daemons to store process identification numbers as well as file access information. Thanks to tmpfs, this data is now reflected in RAM. The method guarantees high speed, and also that after turning off the computer, no files will remain in the / var / run or / var / lock directories.

usbfs - The usbfs file system, starting with kernel 2.6 and higher, gives information about connected USB devices. It is usually integrated into the proc filesystem. About USB device support in Linux.

Other file systems

auto - in fact, there is no file system with that name. However, auto can be used in / etc / fstab or with the mount command to specify a filesystem. In this case, Linux will try to recognize the file system on its own. This method works with most critical file systems.
autofs, autofs4

autofs, autofs4 are also not file systems, but kernel extensions that automatically execute the mount command for the selected file systems. If the file system has not been used for some time, the umount command is automatically executed against it. This method is convenient primarily in cases where only a few of many NFS directories are actively used at the same time.

To do this, the /etc/init.d/ autofs script automatically runs the automount program at system startup. It is configured using the /etc/auto.master file. The corresponding software is automatically installed on, for example, Red Hat and Fedora. In any case, autofs is only activated after configuring /etc/auto.master or /etc/auto.misc.
cramfs and squashfs

cramfs and squashfs - Cram and Squash file systems are read-only. They are used to "pack" as many zipped files as possible into flash memory or ROM (read only memory).

fuse - FUSE stands for Filesystem in Userspace and allows you to develop and use file system drivers outside of the kernel. Therefore, FUSE is always used with an external file system driver. FUSE works in particular with the NTFS ntfs-3g driver.

gfs and ocfs - The Global File System and Oracle Cluster File System allow you to build giant networked file systems that can be accessed by multiple computers in parallel at the same time.

jffs and yaffs - Journaling Flash File System and Yet Another Flash File System are specially optimized to work with solid state drives and flash media. Using special algorithms, they try to use all memory cells evenly (wear leveling technology) to avoid premature system failure.
loop

loop - used to work with pseudo devices. A loopback device is an adapter that can access a regular file as a block device. Thanks to it, any file system can be located in any file, and then mount it to the directory tree using mount. The kernel function responsible for this - pseudo device support - is implemented in the loop module.

There are a variety of ways to use pseudo devices. In particular, they can be used when creating Initial RAM disks for GRUB or LILO, when implementing encrypted file systems, or testing ISO images for CDs.

File systems of storage media

File systems
ISO 9660
Joliet extension of the ISO 9660 file system.
Rock Ridge (RRIP, IEEE P1282) is an ISO 9660 file system extension designed to store file attributes used in POSIX operating systems
Amiga Rock Ridge Extensions
El torito
Apple ISO9660 Extensions
HFS, HFS +
Universal Disk Format Specification of an operating system independent file system format for storing files on optical media. UDF is an implementation of the ISO / IEC 13346 standard
Mount rainier

If you have two operating systems installed, Windows and Linux, then for sure you would like to be contained on partitions of a free operating system directly from Windows without restarting your computer.

Unfortunately, there is no support for Linux partitions on Windows. But in vain. It seems to me that this could be a nice gesture from Microsoft.

The crux of the problem is that Windows uses the NTFS file system, while Linux has its own way of organizing files, the extended file system, the latest version of which is serial number 4.

Linux is more user-friendly than its commercial sister: Linux supports the Windows NTFS file system by default. Of course, you won't be able to install Linux on an NTFS partition, but you can read and write data from such.

Ext2 IFS

Ext2 IFS supports Windows NT4.0 / 2000 / XP / 2003 / Vista / 2008 x86 and x64 versions and allows you to view the contents of Linux ext2 partitions and can also write to them. The utility installs the system driver ext2fs.sys, which extends the capabilities of Windows and includes full support for ext2 in it: drive letters are assigned to ext2 partitions, and files and folders on them are displayed in dialogs of all applications, for example, in Explorer.

Ext2 FSD

Ext2 FSD is a free driver for Windows systems (2K / XP / VISTA / 7 versions x86 and x64). Like the previous utility, which in its essence is also a driver, it includes full support for the ext2 file system in Windows.

LTOOLS is a set of command line utilities that allows you to read and write data to / from Linux ext2, ext3 and ReiserFS partitions (standard Linux file systems) from a DOS or Windows machine.

There is a version of the program with a graphical shell (written in Java) - LTOOLSgui, as well as a version with a graphical shell written in.

Ext2Read

For dessert, as always, the most delicious.

Ext2Read is a file manager utility that allows both viewing and writing to ext2 / ext3 / ext4 partitions. Supports LVM2 and, unlike other programs in this review, the ext4 filesystem. Support for recursive directory copying is built in.

And here is the second dessert. At the beginning it was said that it would be a good gesture from Microsoft to enable support for Linux partitions in Windows by default.

The gesture was nevertheless made for the 20th anniversary of Linux. See for yourself.

That's all. Thanks for attention. I'm going to fight off the May beetles. There are sooo many of them this spring. 🙂

14 June

File systems ext2, ext3, XFS, ReiserFS, NTFS

File system- This is the order that determines the way of organizing, storing and naming data on any electronic storage media in computers.

The variety of file systems is explained by the fact that each was invented for its own specific package of tasks. Some write small files very quickly (say, up to 1GB), but at the same time they do not interact well with large files or do not work with them at all. Some are good in terms of security, others in terms of write / read speed. Each file system has its own pros, cons, vulnerabilities and distinctive features.

IN Linux the most commonly used types of file systems are:

  1. ext2 - stands for Second Extended File System (second extended file system). Developed by Remy Card in 1993 as the Linux kernel filesystem, was the main filesystem from 1993-2001 Linux.
    The advantage is high read / write speed.
    The main disadvantage of the system ext2 is that it is not journaling, but it is because of this that it has great performance ( logging Is the process of logging, storing a list of changes that helps preserve the integrity of the file system during various system failures);
  2. ext3 - stands for Third Extended File System (the third version of the extended file system). Developed by Stephen Tweedy in 2001, still used in distributions today Linux... Was born as an improved ext2.
    The advantage of this system is that it is journaling, that is, its reliability increases significantly in comparison with ext2.
    The disadvantage is slightly lower performance and read / write speed.
  3. XFS - Developed by the company Silicon Graphics in 1993, was added to the core Linux as a filesystem in 2002 to the entire family of distributions Linux, currently used as "native" in the distribution Red Hat.
    The advantage is the presence of metadata journaling, high stability of operation, the distribution of I / O streams into groups is supported, a high read / write speed, there is the possibility of defragmentation even with a mounted partition, and you can increase the size of the file system. Works most effectively with large files.
    The disadvantage is that the size of the partition cannot be reduced, the processing of metadata is not that fast, it works noticeably slower with small files than other types of file systems.
  4. ReiserFS - developed by the company Namesys under the leadership of Hans Reiser in 2001. Used only on operating systems Linux... Was the first journaling file system to be adopted into the kernel.
    The advantage of this file system is that it works very quickly with small files (read / write speed is higher than that of the family ext4), supports journaling.
    The disadvantage is that its development has slowed down noticeably due to the arrest of the head Hans Reiser and there is no background encryption.
  5. NTFS - stands for new technology file system (new technology file system). Developed in July 1993 by the corporation Microsoft... It is widely used in various operating systems, as well as in various storage media.
    The advantage is the built-in ability to differentiate access to data for different users, as well as to assign restrictions on the maximum amount of disk space, the use of the journaling system, and high speed of reading / writing small files.
    The disadvantage is that for stable operation, not a small PC RAM is required, it works slowly with large files, the length of the path to files is limited (32,767 Unicode characters).

In such a simple way, we figured out the "file systems ext2, ext3, XFS, ReiserFS, NTFS«!

ext2 (also called as ext2fs) - Second Extended File System(Second Extended File System) is a file system built on top of the Linux kernel. Ext2 was created and developed by Remy Card. The ext2 file system was built by him to replace the old, previous version - ext.

In terms of speed and performance, this file system can serve as a benchmark. This is evidenced by the results of performance tests of file systems. For example, in Dell Tech Center's sequential read and write speed tests, ext2 outperforms ext3, and is only second in read speed to more modern ext4.

The main drawback of ext2 is that it is not a journaling filesystem. However, this flaw was eliminated in the next filesystem - ext3.

ext2 is used on flash cards and solid state drives (SSDs), as the lack of journaling is an advantage when dealing with drives with write cycle limits.

Ext2 history

During the rapid development of the Linux system, it used the Minix OS file system. It was quite stable, but it was 16-bit. As a consequence, it had a hard limit of 64 Mb per partition. In addition, there was a limitation on the maximum length of a file name, which was 14 characters.

Together, these limitations led to the development of the "extended file system" (hence the term " Extended File System "). She was tasked with solving two key problems of Minix. The new file system was made public in April 1992. It was Ext, it extended the file size limit to 2 gigabytes and set the file name length limit to 255 characters.

However, despite the success of the new file system, there were still quite a few unresolved problems. For example, there was no support for split access, there were no data modification timestamps. The need to solve these problems served as a motive for the creation of the next version of the extended ext2 file system (“ Second Extended File System "). ext2 was developed in January 1993 and also implemented POSIX-compliant ACLs and extended file attributes.

Ext2 logical organization

The ext2 directory hierarchy graph is represented as a network. This is due to the fact that one file can be included in several directories at once.

All file types have symbolic names. Hierarchically organized file systems typically use three types of names: simple, compound, and relative. So it is in ext2. In the case of a simple name, the restriction is that its length should not exceed 255 characters, in addition, the name should not contain the NULL character and slash.

As for the NULL character, the restrictions are related to the representation of strings in the C language, in the case of the slash character, everything lies in the fact that it is used as a separating character between directories.

The fully qualified name is a chain of simple symbolic names of all directories through which the path from the root to the given file passes. In ext2, a file can be in multiple directories, which means that it can have multiple full names (one file - multiple full names). But anyway, the full name defines the file.

Ext2 attributes:

  • file type and permissions,
  • owner, access group,
  • information on permitted operations,
  • creation time, date of last access, date of last modification and time of last deletion,
  • current file size,
  • file specification:
    • regular file,
    • catalog,
    • byte-oriented device file,
    • block device file,
    • named pipe,
    • symbolic link,
  • number of occupied blocks,
  • others

File attributes are contained in special tables, not in directories, as is usually the case with simple file systems. As a result, the directory has a very simple structure with two parts: an inode number and a name.

Ext2 physical organization

Disk partition structure

As part of ext2, the following can be distinguished:

  • blocks and block groups;
  • inode;
  • superblock.

The entire disk space is divided into fixed-size blocks, which are multiples of the sector size (1024, 2048, 4096, or 8192 bytes). The block size is specified when creating a file system on a disk partition. Sequential numbers are assigned to all blocks. To reduce fragmentation and the number of movements of the hard disk heads when reading large data arrays, blocks are combined into groups.

The basic concept of a filesystem is the inode (also called inode - information node). This is a special structure that contains information about the attributes and physical location of a file. Index decryptors are merged into a table at the beginning of each block group. The superblock is the main element of the ext2 filesystem. It contains general information about the file system. The superblock is located 1024 bytes from the beginning of the section. The integrity of the superblock determines the health of the file system. The OS creates several backups of the superblock in case the partition is damaged. In the next block, after the superblock, there is a global descriptor table - a description of block groups in the form of an array with general information about all block groups.

Block group

All blocks on an ext2 partition are split into groups. A separate entry is created for each group in the global descriptor table. This record stores basic parameters such as: block number in bitmaps and tables, number of free blocks in a group, number of inodes containing directories.

Block bitmap Is a system in which each bit informs whether the block corresponding to it is assigned to any file. If the bit is 1, then the block is busy. The inode bitmap performs a similar function: it shows which inodes are busy and which are not. The Linux kernel tries to evenly distribute the inodes of directories into groups, and to move the inodes of files to a group with the parent directory. All the remaining space that appears in the table as data is allocated for storing files.

Data addressing system

The data addressing system is one of the most serious and key components of the file system. Thanks to it, the desired file is found among the many empty or occupied blocks on the disk.

ext2 uses the following file block addressing scheme. To store the file address, 15 fields are allocated, each of which consists of 4 bytes. If the file fits into 12 blocks, then the numbers of the corresponding clusters are listed in the first twelve fields of the address. If the file size exceeds 12 blocks, then the next field contains the address of the cluster, in which the numbers of the following file blocks can be located. So, the thirteenth field is used for indirect addressing.

With a maximum block size of 4096 bytes, the cluster corresponding to the 13th field can contain up to 1024 numbers of the next file blocks. If the file size exceeds 12 + 1024 blocks, then the 14th field is used, which contains the address of a cluster containing 1024 cluster numbers, each of which refers to 1024 file blocks. Double indirect addressing is already used here. And if the file contains more than 12 + 1024 + 1048576 blocks, then the last 15th field for triple indirect addressing is applied.

This addressing system allows for a maximum block size of 4096 bytes to have files larger than 2 TB.

The Linux filesystem is most often ext4. It is journaling and allows you to conveniently work with data when solving the vast majority of problems. However, there are others. The main types of file systems and the principles of working with them will be discussed within the framework of this material.

Linux file system types and their features

Distinctive features are the speed of working with files, security and parameters (such as block size) that exist by default and are set when creating an FS. Perhaps the most important characteristic is the presence of a journal. Data is written to the system log or metadata (headers only) by which information can be restored in case of failure.

The file system can be created on any device: disk or system partition.

EXT2 file system

EXT2 is currently an obsolete file system that is hardly used in modern installations. the main drawback is the lack of logging, which, accordingly, makes it impossible to recover data in case of a failure. Still used on portable storage media such as USB. They do not need a magazine because they take up some space.

Also guarantees the maximum speed of work.

  • for EXT2 the maximum file size is -2 TB

EXT3 file system

Supplanted EXT2, the main feature is the appearance of the magazine, is fully backward compatible with EXT2 (EXT2 can be freely converted to EXT3). Now it is also rare, EXT4 is almost always used.

The log is a special area in memory where information about all changes is recorded

  • for EXT3 the maximum file size is -2 TB
  • maximum size of all files - 32 TB
  • each directory can have up to 32,000 subdirectories

There are three options for journaling (specified when creating the file system):

  • journal - journal metadata, as well as the information itself
  • ordered - the default option, only metadata is saved after writing to disk
  • writeback - also only metadata is saved, you can choose to save it before writing to disk or after

EXT4 file system

The modern version of the extended file system, it is most often used

  • max file size -2 TB 16 TB
  • the maximum size of all files is 1 EB (exabyte). 1 EB \u003d 1024 PB (petabyte). 1 PB \u003d 1024 TB (terabyte).
  • each directory can have up to 64,000 subdirectories

In EXT4, logging can be turned off by setting the option data when mounted in off

EXT as the main Linux file system and practice

The file system is created by the mk2fs command

The required logging option is specified during mount, for example:

mount / dev / vdc / mnt / 1 -t ext3 -o data \u003d journal

Conversion from EXT2 E to XT3

ReiserFS

ReiserFS (and the modern SELinux-enabled implementation of Reiser4) has good performance and is very productive - especially when dealing with a lot of small files. ReiserFS does not allocate inodes for each small file by processing them together, nor does ReiserFS use a journal with several options available. The file system is currently supported by developers from Russia.

You can create FS for the device with the command

XFS

XFS is a Journaled File System. Uses RAM to store information, so data loss is possible - for example, when the power is turned off.

To use XFS on Ubuntu, you need to install packages xfsprogsand xfsdump

vfat

The Linux file system also exists in the Windows environment. It is used when you need to organize joint access to certain disks and partitions of clients with different operating systems. In other cases, it is not recommended to use it because it can be difficult when working in Linux.