Article Title: a deep understanding of efficient Linux File System Management. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
I. Overview
Linux supports a large number of local file system types and several file systems that access remote disks through the network, analyze the content of the/proc/filesystems file to find out which file systems are supported by the Linux kernel.
Adding support for any such File System in the kernel is quite simple. You only need to select the corresponding configuration option when constructing a new kernel. For example, for makexconfig, you only need to select the desired file system type under its Filesystems. If you want to migrate a disk from another environment to a Linux system, you need to add the file system type, and the original system environment of the disk uses a different partition table format than that of Linux, remember that you must also enable the corresponding Partition type support (set through Partition Types ).
Currently, the ext2 File System (second extended filesystem) is a file system directly supported by Linux by default. The ext2 file system is very similar to other modern Unix File Systems, but closer to the Berkeley Fast Filesystem used by the BSD system. The maximum size of the ext2 file system is 4 TB, but currently its maximum file size is limited to 2 GB by the Linux kernel.
The core of ext2 is two internal data structures, namely superblock and inode. Superblock is a table that contains important information about a file system, such as labels, sizes, and inode quantity. It is a basic and global description of the file system structure. Therefore, file systems without superblock will no longer be available. For this reason, multiple copies of superblock are stored in different locations in the file system.
Inode is a basic file-level data structure. every file in the file system can be found in one of the inode. The file information described by inode includes the file creation and modification time, file size, and the list of actually stored file data blocks. For large files, the block list may contain the disk location (called indirect block) of the attached data block list, or even a list of double or triple indirect blocks. The file name is associated with inode through the Directory Entry, which consists of the "file name-inode" pair.
Linux provides a large number of tools for creating and managing file systems. Next we will introduce various tools to be used based on the new disk (or partition. Although the process of completing this task is not complex, these operations must be performed on the Linux Command Line, because most graphical tools have limited support in this regard.
Add disks/partitions to Linux
Adding a new disk or partition in a Linux File System is quite simple. The steps are as follows:
Connect a disk to a computer
Partition the disk (fdisk or cfdisk) if necessary)
Determine the device file associated with the new disk/partition (MAKEDEV)
Create a file system (mkfs) on a partition)
Check whether the file system has a consistency error (fsck)
Mount)
Set the startup behavior and other options in the file system configuration file (/etc/fstab ).
In daily use, modify the features and options of the file system (tune2fs) if necessary)
2. Determine the device file and create a partition
1. Confirm the Device File
Before creating a file system for a new physical disk (or disk partition), you must first know the specific device name of the disk. We can use several methods to find the device name. For example, you can use the dmesg command to analyze the startup log (send it to grep in a pipeline and search for [hs] d [a-z, you can view the log file. In addition, most Linux distributions enable the/proc file system by default. If you also use it, you can analyze the/proc/partitions file and view the list of all disk partitions recognized by the system.
Sometimes we need to manually create device files for the disk, but this is extremely rare. You can use the MAKEDEV script in the/dev directory to create a device file. For example, the following command creates a device file for the sixth SCSI disk:
# Cd/dev; MAKEDEV sdf
[1] [2] [3] Next page