- Linux file system features:
- Ext2 file system: An Ext2 file system is formatted into block groups, each of which has its own inode/block/superblock system. The block group consists of six parts:
- Data blocks: Data blocks are places where file content data is stored. The Ext2 file system supports block sizes of 1K, 2K, and 4K. Block sizes are fixed at formatting time, and each block is numbered to facilitate inodes.
- Table (inode):
- Inode record information:
- The access mode of the file
- Owner and group of the file
- The capacity of the file
- The time when the file was created or its state changed
- Last read time
- Time of last modification
- Flags that define file properties
- The actual content of the file points to
- The inode features:
- Each inode has a fixed size of 128 Bytes
- Each file occupies only one inode
- The number of files a file system can create is related to the number of inodes
- When reading a file, the system needs to find the inode and analyze whether the permission recorded in the inode matches the user. If the permission matches the user, the system can start reading the block.
- Superblock: The size of the Superblock is 1K. The Superblock records information about the entire file system and can be used
dumpe2fs
Command to view its information:- Total number of blocks and inodes
- Number of unused and used inodes/blocks
- Block and inode size (block 1, 2, 4K, inode 128Bytes or 256Bytes)
- Time when the file system was mounted, when data was last written, and when disks were last checked
- A valid bit value. The value is 0 if the file system has been mounted, and 1 if the file system has not been mounted.
- Filesytem Description(File system Description): Describes the start and end block numbers of each block group and the block numbers between each segment.
- Block bitmap: Records the block usage status.
- Inode bitmap: records the inode usage status.
- XFS file system:
- Data section:
Data is allocated to multiple storage area groups to place the data required by the file system. Each storage group contains:- Superblock of the entire file system
- Residual space management mechanism
- Inodes and blocks are dynamically configured when the system needs them.
- The active log section of the file system: Records changes to the file system, which are not terminated until the changes are fully written to the data section.
- Realtime Section:
When a file is created, XFS will find one or more of the extend blocks in the segment, place the file in the block, and write the file to the inodes and blocks in the data section when the allocation is complete.
The XFS file system is availablexfs_info
Command to view superblock information.
- Data section:
- Ext2 file system: An Ext2 file system is formatted into block groups, each of which has its own inode/block/superblock system. The block group consists of six parts:
- Df du command:
- Df command: lists the total disk usage of the file system
- -a: Lists all file systems
- -k: Displays each file system in KBytes
- -m: Displays file systems in the capacity of MBytes
- -h: displays itself in easy-to-read formats such as GBytes, MBytes, and KBytes
- -t: displays the file system type of the partition
- -i: indicates the number of inodes, not disk capacity, that the df command reads mainly information within the superblock.
- Du command: evaluates the directory capacity
- -a: Lists all file and directory capacities
- -h: displays in an easy-to-read format
- -s: Lists the total quantity
- -s: lists the total number of directories, excluding subdirectories
- Df command: lists the total disk usage of the file system
- LSBLK command:
- Parameter Meanings:
- -d: Only the disk itself is listed, and partition data of the disk is not listed.
- -f: lists the names of file systems on the disk.
- -m: displays the permission data of the device under /dev.
- -p: lists the complete file name of the device.
- -t: lists the detailed data of the disk.
- Meaning of the output information:
- NAME: indicates the file NAME of the device.
- MAJ:MIN: primary: indicates the secondary device code.
- RM: Indicates whether the device can be uninstalled.
- SIZE: capacity.
- RO: Indicates whether the device is read-only.
- TYPE: disk, partition, or ROM.
- MOUNTPOINT: indicates the MOUNTPOINT.
- Parameter Meanings:
- Blkid command:
- List parameters such as device UUID: Linux assigns a unique identifier to all devices on the system that can be used to mount or use the device/file system.
- Parted command:
- List the partition table types and partition information of disks:
- Example:
parted /dev/sda print
- Example:
- List the partition table types and partition information of disks:
- Gdisk and fdisk commands:
Use fdisk for the MBR partition table and gdisk for the GPT partition.
Because Linux is still using the disk at this time, the partition table has not been updated. You can usepartprobe -s
Update the partition table. - XFS mkfs.ext4 command:
- Parameter Meanings:
- -b: Subsequent block capacity.
- -f: forcible formatting. To find out which file system formats are supported, press Tab.
- Parameter Meanings:
- Xfs_repair fsck.ext4 Command:
- xfs_repair:
- -f: The device in the back is actually a file, not a device.
- -n: Only check does not modify any data of the file system.
- fsck.ext4:
- -f: forcible check. If no unclean flag is detected on FSCK, it will not enter the detailed check for /
- -d: optimizes the configuration of directories in the file system.
- -b: indicates the position followed by the superblock. If the superblock is damaged, you can specify the superblock backed up by the file system to rescue it.
- Mount umount command:
- Mount: The mount command can be used to mount the device name or UUID
- Mount using device name:
mount /dev/sda1 /home/study
- Mount using UUID:
mount UUID="06d699ec-4bd3-4849-a050-32b666506076" /home/study
- Mount using device name:
- umount:
- -f: Forcible uninstallation
- -l: Uninstalls the file system immediately
- – n: don’t update
/etc/mtab
Unload under condition
- Special device loop mount:
- Create a large file:
dd if=/dev/zero of=/srv/loopdev bs=1M count=512
- Format large files:
mkfs.xfs -f /srv/loopdev
- Mount large files:
mount -o lopp /srv/loopdev /mnt
Partitions can be extended by mounting large files
- Create a large file:
- Mount: The mount command can be used to mount the device name or UUID
- Mkswap swapon swapoff
- Mkswap: Creates a swap partition
- Swapon: Starts the swap partition
- Swapoff: Disables the swap partition
- Reference: [1] : Bird’s Linux private dishes