Linux file system: type, description, structure, system check, recovery of damaged files

Immediately, we note that this material will be mostly theoretical, aimed at beginners, at the formation of a general idea. Therefore, we will consider the general, most important points about the Linux file system. The intricacies of working with any kind of it, direct commands - this is another topic of conversation. Our task is to understand what it is, how this system functions.

What it is?

The phrase "file system" is often used in completely different contexts. Therefore, at the beginning of this article, we need to prevent confusion.

Speaking about the Linux Mint file system, we will mean the following:

  • The whole range of Linux file structures, starting from the root.
  • Any specific format for storing information. Common examples: Ext3, Ext4, Btrfs, XFS, etc. Note the distinguishing feature of the Linux kernel. It can support up to hundreds of file systems of various types, from modern to very outdated. Each of these types will use its own metadata structures to organize work with information on disk.
  • A logical volume or a specific partition formatted into a specific kind of file system. It can be "mounted" to a specific mount point.
    linux file system type




Fundamental System Features

Parsing the Linux file system for beginners, we will dwell on its tasks in detail. The main function: providing organized spaces for storing information, files on a non-volatile storage device. A number of additional problems follow from this statement.





All file systems necessarily provide a namespace. It determines how the files will be named, set restrictions on the length of the name, the use of certain characters. Responsible for the logical structure of information on the disk. Example: using directories specifically for organizing files, and not for simple storage.

When the namespace is already defined, you need to create a database for it using the file system metadata. In most cases, this framework includes the following:

  • Data structure for creating a directory hierarchy.
  • A structure for storing both occupied and free blocks on disk.
  • Structures with the names of directories and files.
  • Important information about documents: size, file location on disk, time of its creation, and so on.

I must say that only the contents of the file will be contained in the blocks themselves. Everything else is in the metadata. The latter are also used to describe subsections and logical volumes; they contain data characterizing the file system itself.

To access documents, you need a set of functions called API. With it, programs acquire the ability to manage various objects of the file system. There are methods for creating, deleting, and moving documents.

It is important that modern file systems can provide a security model - access rights to documents for users. It follows that users in this structure have access only to their files.

Organization of file structure in Linux

This file system is a complex of two parts:





  • Virtual FS (file system). A single set of kernel commands with which developers can gain access to any of the file systems. This part definitely needs a driver for compatibility with various types of FS.
  • File system drivers. The second part of the implementation. They contain a standard command set that ensures the execution of file-system-specific actions.
    how to recover file system linux mint serena




About directory structure

You must admit that it is much easier to find the necessary document if the files are stored in well-organized groups, rather than being collected in one heap. The FS structure in Linux is just a simple hierarchy. All directories here are in the root directory (/). Accordingly, the address of each document will begin with it.

The root Linux FS is a top-level file system that contains all the files and documents needed to boot the system before the rest of the FSs are mounted. Here are the necessary libraries and documents for connecting other file systems. At boot time, other FSs are mounted in the directories defined for them.

We will talk about them a little further. Note that the directories / bin, / dev, / etc, / lib, / root, / sbin cannot be mounted. Therefore, they are available already before downloading, as they contain the entire set of necessary files. But the directories / media and / mnt are always empty. Why? These are mount points for other systems. Other FSs can be mounted later, since they do not affect the launch.

In Linux, all physical partitions and disks are connected to a common file system. It begins, as we said, with the root (/), in which other directories are located. This is due to the fact that / var, / home, / boot, / tmp can also be located on other physical disks, even removable ones.

All of the above is good in that when updating the distributive version it is realistic to save all documents and settings in the home directory. Often, you need to reformat the root partition to rid it of information junk. The structure will help you not to lose important data. This is how the root partition is protected from overflow, which could cause the entire system to become inoperative.

Next, we move on to listing the types of the most common file systems for this OS.

Linux file system




Xfs

The development of this Linux file system began in 1993. Creator - Silicon Graphics. For most users it became available in 2000-2002.

Let's introduce the important features of this system in Linux:

  • Support for voluminous files and their volumes.
  • For 64-bit systems: 8 exbibytes - 1 byte (represented as follows: 8 * 2 60 -1 bytes).
  • The presence of continuous zones of space.
  • Online defragmentation.
  • Space allocation delay.

Another important feature of this Linux file system is one of the very first journaling systems for * nix. Accordingly, it contains the most debugged source code in this area.

Reiserfs

Here is another oldest Linux journaling file system. Its developer is Namesys. Available to users since 2001. They note the presence of annoying flaws, but generally speak of it as a good file system.

The meaning of such a journaling system is in disk transactions sequentially written to a special area of ​​the hard drive (log, log) before documents get to the end points of the Linux OS file system.

The maximum volume size for this structure is 16 terabytes.

JFS (Journaled File System)

We move on to the next file system, which is the development of the notorious IBM Corporation. It was created relatively long ago: in the 1990th for AIX.

The first stable release of Linux specific for users appeared in more than a decade - in 2001.

The biggest plus of this Linux OS file system is its excellent scalability. But it is also highlighted by a significant drawback: not particularly active support on the continuation of the entire life cycle.

The largest volume size for this system is 32 pibytes.

check linux file system




Ext systems

In this subheading, we’ll analyze four types of Linux file systems of the same name:

  • Ext (extended filesystem). Born in April 1992. What is important to note, was the first file system that was developed specifically for the needs of Linux. The creator was Remy Card. Development Goal: Overcome the limitations of the previous Minix file system.
  • Ext2. The authorship system of the same developer. It was introduced in 1993. Its significant minus: the system was not journaled. This shortcoming was designed to correct the very next development.
  • Ext3. Another type of Linux file system. In fact, it was not an independent development, but was just an extension to the previous one. Developer - Stephen Tweedy. The system was introduced in 1999 in order to already be included in the main Linux kernel in 2001. Against the background of past developments stands out for the modest size of space. Here is an example for 32-bit systems: up to 4 terabytes. But at the same time it highlights an important advantage: it is one of the most stable and widely supported in the Linux family.
  • Ext4. What kind of development is this? In short, this is a version of the previous one, but only adapted for 64-bit systems. She was distinguished by the ability to support large spaces - up to 1 exbibyte. The structure of the Linux file system of this variety is also distinguished by the following: the presence of contiguous areas of disk spaces, online defragmentation, the possibility of delaying the allocation of space, and so on. Direct compatibility with previous development is also provided here. Backward compatibility will be limited (in the absence of the ability to contiguous areas of disk space).

Reiser4

What Linux file system is hidden under this name? This is the first attempt to create a new generation system for this OS. It was introduced to the world in 2004. The following features distinguish it:

  • Transactions
  • The possibility of delaying the allocation of space.
  • Built-in ability to compress information and data encoding.

The developer of the new product is Hans Reiser (in fact, the file system was named after its creator). He suggested that the user "Linux" use his brainchild as a database with improved metadata.

Unfortunately, the fate of the advanced Reiser4 turned out to be connected with the fate of its creator. In 2008, Hans Reiser was convicted of murder. After this, they preferred to forget about the file system.

windows linux file system




UPD: Btrfs

We continue to parse the file systems "Linux", "Windows". It should be noted that this project was originally launched by Oracle. It was further supported for Linux systems. There are many users who distinguish this file system as a response to ZFS.

Next, we will introduce the key features of Btrfs:

  • Support for copy-on-write technology. Its main advantage is that it allows you to take pictures of disk areas - the so-called snapshots. Their value is that they help a lot if necessary to restore the system.
  • Monitoring data integrity as well as metadata.
  • Compression of information.
  • Optimized mode, specially designed for users of SSD drives, which can be set during installation.
  • Ability to upgrade to Btrfs with ext3.

Later (from August 2008) the system began to be released under the GNU GPL.

Tux 2 and Tux 3

Tux 2 is another file system for Linux. The peculiarity of the development is that it is widely known, but is not publicly announced. The creator of the system is Daniel Philips. The peculiarity of his creation is that the structure is based on a “file tree”, which reliably protects the system from failures. By the way, journaling carries a similar mission. Organized as an ext 2 add-in.

We move on to the next development, Tux 3. Many say that it was released as a worthy alternative to Btrfs. Important feature: created on the basis of Filesystem in Userspace (this is the name of a special module for developing FS on * nix platforms).

The goal of this project is to get rid of the logging that has become accustomed, in return offering a versioned recovery (as of a certain period of time).

The advantage of the Linux recovery used in this file system (Windows is not mentioned here) is that a new way of describing the changes has appeared. What is its essence? A modified copy is created for each of the system files. Instead of overwriting its current version. The advantage of this change is that it allows you to very flexibly manage current versions.

linux mint file system




UPD: Xiafs

What is the difference between this Linux Mint file system? Let's analyze the key features.

Both the idea and the development of this discovery is Frank Xia's idea. The base for the system was MINIX.

Today, the development is considered obsolete, practically not applied. At one time, it was created as an alternative to the common ext. At the end of 1993, Xiafs was added to the standard Linux kernel. It was distinguished by decent stability, a smaller zone of disk spaces for control structures.

However, practice showed an indisputable fact: the development turned out to be weaker than ext 2. Due to the following restrictions: the maximum size of the partition and file, as well as the possibilities of subsequent expansion.

UPD: ZFS

Which Linux file system will be final in our story? We will talk about the Zettabyte File System. The developer was Sun Microsystems Corporation. I must say that this file system was originally developed for the Solaris operating structure, which was notorious in 2005.

Let's dwell on the distinctive features of the development:

  • Lack of information fragmentation per se.
  • Availability of control over snapshots and storage pools.
  • Variable block sizes.
  • The presence of a 64-bit checksum mechanism.
  • The most important distinguishing feature: the ability to address 128 bits of data.

As for Linux itself, development can be applied through FUSE.

linux os file system




Fsck utility basics

How to check Linux file system? To do this, we advise you to refer to the useful fsck utility. For the root partition, it takes effect automatically. But this statement does not apply to other sections. Autostart is not possible even if you disabled it in the settings. In addition, fsck is a shell for other utilities that are oriented to work with a specific file system.

If the root partition is damaged, then the utility is launched from an external medium (for example, from a disk). Otherwise, the system turns on in recovery mode. Then the utility starts from the root partition.

How to check Linux file system? First of all, you need to get acquainted with the useful functions of the utility:

  • Do not run the next version of fsck for the hard drive until this one has completed its work.
  • User-defined types of file systems that need verification. It is not necessary to specify the device, since the verification can be set with one command, indicating the necessary type of FS.
  • Check all file systems. It is also possible to set priority here. First, of course, the root is checked. Usually used at startup.
  • Demonstration of the progress of checking file structures.
  • Ignore the check if the file system is already mounted.
  • Do not perform any actions, show that the verification was successful.
  • Ignore checking the root section of the file system.
  • Provide the most detailed output of information.
  • Do not show data about the utility itself.

There is also a set of additional options that are not so often used by users, but are interesting enough for familiarization:

  • During the default check, fix all detected errors without system issues. The option is considered obsolete, so experts do not recommend marking it.
  • Performing only a file system check without error correction.
  • Ask the user about the correction of each detected utility error.
  • Automatically respond to all requests for fixing system errors positively. In fact, this is a modern version of the first item from this list.
  • Find and blacklist all bad blocks found on the hard drive. Not available for all types of file systems.
  • Force verification of a specific file system. Even if it goes through the magazine as clean.
  • Set a new superblock address if the previous one was damaged.
  • Check and correct errors automatically.

Checking the Linux File System

Let us now proceed directly to practical actions. We present to the reader several possible verification methods:

  • Checking a clean FS: $ sudo fsck -fy / dev / sda1.
  • Check all FS that are connected to this computer. Joining the -A- command helps. Here's what it looks like: $ sudo fsck -A -y.
  • If the previous method turned out to be powerless (it is suitable only for starting in recovery mode), we recommend that you refer to the following "test" combination: $ sudo fsck -AR -y.
  • Check with the exception of mounted file systems: $ sudo fsck -M -y.
  • If you do not need to check all available file systems, and only ext4 diagnostics are required, what to do in this case? We suggest using this combination: $ sudo fsck -A -t ext4 -y.

But many experts do not recommend checking mounted file systems. However, if it is vital, then there is one way out.To do this, you need to remount the FS in a special version of "Read Only". The check is then implemented like this: $ sudo mount -o remount, ro / dev / sdb1.

In conclusion, imagine how to check the FS in the so-called forced standard: $ sudo fsck -fy / dev / sdb1.

FS recovery

Let’s tell you how to restore the Linux Mint Serena file system.

LiveCD . , .

By default, FS can be found in the / dev / sda1 section. You need to do the following: $ sudo fsck -y / dev / sda1. Experts advise not to check the option U. Otherwise, the system will ask you a lot of questions that need to be answered in the affirmative.

Some users are interested in what to do in case of damage to the superblock. Unfortunately, with such a serious malfunction, the utility does not always help. The superblock is the beginning of the Linux file system. Accordingly, without it she will not be able to work.

But experts say that hurrying to say goodbye to data even in this case is not worth it. Enter the following command: $ sudo mkfs -t ext4 -n / dev / sda1. The system will create a new file system. Substitute ext4 with the one into which you formatted this section. At the same time, the block size also coincides so that recovery takes place.

As a result, six backup additional addresses of superblocks will appear. In this case, you can try to restore the file system using each. Imagine one of the recovery options: $ sudo fsck -b 98304 / dev / sda1.

Now you know important information about the Linux file system, about its types that exist today, modern and outdated. Unlike the popular Windows, this OS is still more suitable for advanced users. The above is confirmed by file system recovery verification algorithms.




All Articles