First, the file system
When the operating system manages files and data through a file system, the disk or partition needs to create a file system before it can be used by the operating system, and the process of creating a file system is called formatting . Devices that do not have a file system are also known as bare devices (raw), and some environments require bare devices, such as when you install Oracle.
Common File System types
Common file systems include FAT32, NTFS, Ext2, Ext3, Ext4, XFS, HFS, and so on. where FAT32 and NTFS are file systems in Windows, Ext2, Ext3, Ext4, XFS, and HFS are file systems in Linux. NTFS is the mainstream file system of Windows today, Ext3, EXT4 is the mainstream file system in Linux.
The difference between different file systems
- With log
- Supported partition sizes
- Supported individual file sizes
- Performance
- ......
Second, the Linux supported file system
Common are ext2, ext3, Ext4, Fat (msdos), VFAT, NFS, iso9660 (file system for CD-ROM), proc (virtual file system in Linux memory), GFS (global file systems in Linux, Global file system), JFS (file system with log), and so on, different Linux distributions, file systems are slightly different.
Iii. MKE2FS Order
The command mke2fs is used to create the file system:
Mke2fs-t Ext4/dev/sda3 Create a EXT4 file system for partition 3rd of the first SATA drive
Common parameters:
-B blocksize Specifies the file system block size (the smallest unit of the file system per read and write data)-C Check for block bad damage (check, check)-l label tag (similar to Windows Disk volume label) when establishing file system-j Set up file System log (journal, log), ext3 and ext4 default with log
Iv. MKFS Command
Command MKFS can also be used to create file systems, which are simpler than MKE2FS , but support fewer parameters and do not allow finer control.
It also has a few subcommands:
Mkfs.ext3/dev/sda3mkfs.ext4/dev/sda3mkfs.vfat/dev/sda3
V. DUMPE2FS command
The command dumpe2fs can be used to view the file system information for a partition:
Dumpe2fs/dev/sda1
Vi. Journal Log
The file system with the log (ext3, EXT4) has strong stability, mainly reflected in the error can be restored.
Using a file system with a log, the file system uses a method called " two-phase commit " to perform disk operations, and when the disk operation occurs, the file system does the following:
- The file system writes the specific contents of the prepared transaction to the log
- File System operation
- After the operation succeeds, delete the specific contents of the transaction from the log
The advantage of this is that when a transaction executes, it can be recovered by querying the log if there is an unexpected (such as a power outage or disk failure). The disadvantage is that some performance is lost (additional log read and write operations).
Vii. Order of E2label
The command E2label can be used to label the file system:
E2label/dev/sda2 display sda2 label e2label/dev/sda2 MYLABEL set sda2 label to MYLABEL
Eight, fsck command
Command fsck to check and repair bad-damaged file systems:
Fsck/dev/sda2
- Fix directly with the-y parameter without prompting
- The default fsck automatically determines the file system type, and if the file system corruption is more severe, specify the file system type with the-t parameter
- For corrupted data that is recognized as a file (the file system has no records),fsck places the file into the Lost+found directory
- The disk is fsck when the system starts
Linux entry record: Viii. Linux file system