What are filesystems? Basic knowledge of Filesystem
In the following article, we will introduce you to the basic knowledge of filesystem, find out the filesystem types, how to create filesystem and many other useful information about this file system.
1. What are filesystems?
Filesystems are methods and data structures that an operating system uses to track files on a drive or partition. It is possible to temporarily translate filesystem as a file system. That is how the files are organized on the drive. This term is also used to refer to a partition or drive used to store files or file system types. So if someone says "I have two filesystems" that means the user has two partitions, in which a partition stores files, or a partition uses "extended filesystem", which means the fileystem type.
- Learn the basics of file systems in Linux
- Learn the file system and folders on Linux operating systems
The difference between a drive or partition and the file system saved on it is very important. Some programs (including file system creation programs) work directly on raw sectors of a drive or partition. If there is a file system exists, it will be destroyed or seriously damaged. Most programs work on a file system, so they will not work on a partition that does not contain one (or contains a wrong type).
In order for a partition or a drive to be used as a file system, it needs to be initialized and the data structures of that file system type need to be written to the drive. This process is called creating the file system.
Most types of UNIX file systems have the same general structure, although the details are quite different. Key concepts are superblock , inode , data block , directory block and indirection block. Superlocks contain information about the file system as a whole, such as its size (the exact information here depends on the file system). The inode contains all the information about a file, except its name. Names are stored in folders, along with large numbers of inodes. The directory entry includes the file name and the number of inodes that represent the file. Inode contains a large number of data blocks, used to store data in files. There is space for some data blocks in inode, however, if necessary, there will be more space for pointers to automatically allocated data blocks. These allocation blocks are indirect blocks, the name indicates that to find the data block, the user must first find its number in the indirect block.
UNIX file systems often allow the creation of a file vulnerability (this is done by calling the system Iseek (), checking the manual page), which means that the file system only deceives it is in a specific place in the file that has 0 bytes, but no actual disk sector is reserved for that location in the file (that is, the file will use less disk space). This usually happens especially with small binary files, Linux shared libraries, some databases and some other special cases. (The vulnerability is done by storing a special value such as the address of the data block in the indirect block or inode. This special address means that no data block is allocated for a part. of the file, so there is a vulnerability in the file).
2. Filesystem galore
Linux supports several types of file systems. In this article, the most important systems are:
Minix
Minix is the oldest and most trusted system, but it is quite limited in features (some missing time stamps), up to 30 filename characters) and limited about capacity (maximum 64 MB for each filesystem)
Xia
Xia is a modified version of the minix file system - raising the limit of file names and file system size, but does not introduce any new features. Xia is also not very popular, but reports show that the system works very well.
Ext3
The ext3 file system has all the features of ext2. However, the difference is the presence of journaling. This improves performance and room recovery time when the system crashes. That makes ext3 more popular than ext2.
Ext2
Ext2 is the most feature-rich system of early Linux system files. It is designed to be easily compatible with the new version, so the new code versions of the file system do not require rewriting the existing file system.
Ext
As an older version of ext2, this version is not compatible with new versions. It is almost never used in new installations and most users convert to ext2.
Reiserfs
Is a more powerful file system. Using journaling will cause less data loss.
Jfs
JFS is a file system that has journaling designed by IBM to work in high-performance environments.
Xfs
XFS was first designed by Silicon Graphics to act as a file system with 64-bit journaling. XFS is also designed to maintain high performance with large files and file systems.
In addition, support for a number of external file system operations, to easily exchange files with other operating systems. External file systems work just like original programs, except that they often lack some common UNIX features or other strange limitations.
Msdos
Msdos is compatible with MS-DOS FAT file systems (including OS / 2 and Windows NT)
Umsdos
Umsdos extends the msdos file system driver in Linux to receive long file names, owners, permissions, links and device files. This allows a common msdos file system to be used as if it were a Linux, so umsdos eliminates the need for a separate Linux partition.
Vfat
This is the extension of the FAT file system called FAT32. It supports larger drive sizes than FAT. Most Windows disks are vfat.
Iso9660
The I9696 is a standard CD-ROM file system, the popular Rock Ridge extension for CD-ROM standards allows longer file names to be supported automatically.
Nfs
Nfs is a network file system that allows sharing a filesystem between multiple computers to allow easy access to files from them.
Smbfs
Is a network file system that allows sharing a filesystem with an MS Windows computer. It is compatible with Windows file sharing protocols.
Hpfs
Is the OS / 2 file system
Sysv
SystemV / 386, Coherent and Xenix file systems.
NTFS
The most advanced file system of Microsoft provides faster file access and stability than previous Microsoft file systems.
The choice of the file system to use depends on the situation. If compatibility or other reasons make one of the non-original file systems necessary, that option needs to be used. If you can choose freely, then perhaps the smartest way is to use ext3 because it contains all the features of ext2 and is a journaling file system. For more information about the file, please read section 5.10.6 below.
There is also proc, accessible as the / proc directory, which can be considered as a filesystem, although it is not really. The proc system makes it easy to access certain kernel data structures, such as the process list. It makes data structures look like a file system, and this system can be manipulated with all common file tools. For example, to get a list of all processes, you can use the following command:
$ ls -l / proc total 0 dr-xr-x 4 root root 0 Jan 31 20:37 1 dr-xr-xr-x 4 liw users 0 Jan 31 20:37 63 dr-xr-xr-x 4 liw users 0 Jan 31 20:37 94 dr-xr-xr-x 4 liw users 0 Jan 31 20:37 95 dr-xr-xr-x 4 root users 0 Jan 31 20:37 98 dr-xr-x 4 ry users 0 Jan 31 20:37 99 -r - r - r-- 1 root root 0 Jan 31 20:37 devices -r - r - r-- 1 root root 0 Jan 31 20:37 dma -r - r - r-- 1 root root 0 Jan 31 20:37 filesystems -r - r - r-- 1 root root 0 Jan 31 20:37 interrupts -r -------- 1 root root 8654848 Jan 31 20:37 kcore -r - r - r-- 1 root root 0 Jan 31 11:50 kmsg -r - r - r-- 1 root root 0 Jan 31 20:37 ksyms -r - r - r-- 1 root root 0 Jan 31 11:51 loadavg -r - r - r-- 1 root root 0 Jan 31 20:37 meminfo -r - r - r-- 1 root root 0 Jan 31 20:37 dr-xr-x modules 2 root root 0 Jan 31 20:37 net dr-xr-xr-x 4 root root 0 Jan 31 20:37 self -r - r- -r-- 1 root root 0 Jan 31 20:37 stat -r - r - r-- 1 root root 0 Jan 31 20:37 uptime -r - r - r-- 1 root root 0 Jan 31 20:37 version $
Note that although it is called the file system, there is no part of the proc file system that works directly on the drive. It exists only in the virtual system of the system kernel. If you search for parts of the proc file system, multiply the system to make that part show up somewhere, although it is not. Therefore, although there is a file of / proc / kcore many MB, it still does not occupy a bit of disk space.
3. Which filesystems should be used?
There is usually little point in using multiple file systems. Currently, ext3 is the most popular filesystem because it is a file system with journaling (journaling is the ability to record system operations when manipulating data, helping to detect corrupted files quickly without scan the entire file and make the data recovery process more reliable). It is the wisest choice. Reiserfs is also a popular choice because it also has journaling. Depending on the cost for the accounting structure, speed, reliability (perceived), compatibility and other reasons, users are advised to use other file systems. This is decided on a case-by-case basis.
A filesystem using journaling is also called a journaling file system. A file system journaling maintains records, records, about what happened on the file system. In case the system crashes, or if your child touches the power button, the journaling file system will use the filesystem record to recreate lost and unsaved data. This makes data loss less likely and can become a standard feature in Linux file systems. However, like other systems, errors can still occur. So remember to backup your data in an emergency.
Read section 5.10.6 for details on the features of different file system types.
4. Create the filesystem
The filesystem is created, ie initialized with the mkfs command. There is actually a separate program for each type of file system. Mkfs is just a user interface that runs the appropriate program depending on the desired filesystem type. This type is selected with custom -t fstype .
Programs called by mkfs have a slightly different command line interface. The most popular and important options are summarized below:
-t fstype
Select the file system type.
-c
Search for bad blocks and create bad block lists accordingly.
-l filename
Read the original bad block list from the file name.
There are also many programs written to add specific options when creating a specific file system. For example, mkfs.ext3 adds an -b option to allow administrators to specify the block size to be used. Make sure to find out if there is a specific program available for the type of system file you want to use. For more information on determining use block sizes, see also section 5.10.5 below.
To create an ext2 file system on a floppy disk, the following commands need to be issued:
$ fdformat -n / dev / fd0H1440 Double-sided, 80 tracks, 18 sec / track. Total capacity 1440 KB. Formatting . done $ badblocks / dev / fd0H1440 1440 $> $ bad-blocks $ mkfs.ext2 -l bad-blocks / dev / fd0H1440 mke2fs 0.5a, 5-Apr-94 for EXT2 FS 0.5, 94/03/10 360 inodes, 1440 blocks 72 blocks (5.00%) reserved for super user First data block = 1 Block size = 1024 (log = 0) Fragment size = 1024 (log = 0) 1 block group 8192 blocks per group, 8192 fragments per group 360 inodes per group Writing inode tables: done Writing superblocks and filesystem accounting information: done $
First, the floppy disk must be formatted (option -n suppresses validation, ie checks for bad blocks). Then the bad blocks were searched with badblocks , with the output being redirected to a file - badblocks. Finally, the file system is created with a bad block list initialized with any badblocks found.
The -c option may have been used with mkfs instead of badblocks and a separate file. See the example below.
$ mkfs.ext2 -c / dev / fd0H1440 mke2fs 0.5a, 5-Apr-94 for EXT2 FS 0.5, 94/03/10 360 inodes, 1440 blocks 72 blocks (5.00%) reserved for the super user First data block = 1 Block size = 1024 (log = 0) Fragment size = 1024 (log = 0) 1 block group 8192 blocks per group, 8192 fragments per group 360 inodes per group Checking for bad blocks (read-only test): done Writing inode tables: việc Writing Writing superblocks and filesystem accounting information: done $
The -c option is more convenient than using separate badblocks , but badblocks are needed again in the test after the file system is created.
The process of preparing the file system on the hard disk or the same partition as for floppy disks, except that formatting is not required.
5. File system block size
The block size determines the size that the file system will use to read and write data. Larger block sizes will help improve I / O performance when using large files, such as databases. This happens because the drive can read or write data for longer periods of time before searching for the next block.
On the other hand, if you have many smaller files in the filesystem, for example / etc, it is likely that more disk space will be wasted.
For example, if you set the block size to 4096 or 4K and you create a file of 256 bytes size, it will still take up 4K space on your hard disk. For files that seem normal, but when your file system contains hundreds or thousands of files, this may increase.
The block size can also affect the maximum supported file size on some file systems, because many modern filesystems are limited not by block size or file size, but by number. blocks. So you will need to use the "block size * max # of blocks = max block size" formula.
6. Compare the fileystem types
Table 1: Comparison of filesystem types
It should be noted that Exabyte, Zettabyte and Yottabyte are rare in practice. There is a current estimate that the world's printed material (printed material) is 5 Exabytes. Therefore, some file system limitations are considered primarily in theory. However, the file system software has reached these sizes.
Above is only a small part of Filesystem theory, long and slightly academic article, in the process of writing an inevitable error, I hope readers can contribute comments to improve the article!
You should read it
- How to Set Administrator Password
- How to use Dropbox in a Linux file system is not Ext4
- Chrome will have new features that prevent websites from discovering Incognito mode
- How to create system information file in Windows 10
- How to create an EXE installation file
- What is bitlocker?
- Instructions for creating and using BAT file on Windows
- How to create a new host file on Windows
- Create backup file for the entire system
- Which file system should be used for removable storage devices
- How to quickly create new blank text files on Windows, Mac and Linux
- How to create an ISO file on Linux