Summary of important Linux knowledge points-disk and file system management

Source: Internet
Author: User
Summary of important Linux Knowledge & mdash; disk and file system management EXT2 file system: file system features: format ): the file attributes/permissions set for each operating system are different. to store the data required for these files, you need to format the partitions to become the operating system... summary of important Linux knowledge points-disk and file system management EXT2 file system: file system features: format: the file attributes/permissions set for each operating system are different, to store the data required for these files, you need to format the partitions, to become the file system format that can be used by the operating system, we usually call a data that can be mounted as a file system rather than a partition (multiple file systems in one partition, A file system with multiple partitions). super block: records the overall information of the file system, including the total number of inode/blocks, usage, and remaining amount, as well as the file system format and related information. inode: record the attributes of a file. a file occupies one inode and records the data of the file. Block number block: the content of the file is actually recorded. if the file is too large, it will occupy multiple blocks. Each inode and block is numbered, and each file occupies one inode, inode contains the block number for storing file data. This data access method is called an Indexed file system. Fragment: writing a file to a block is too fragmented, so the file reading performance will become very poor. The block to which the same file belongs is merged by means of fragment, which makes data reading easier. The file system has planned inode and block at the beginning. The inode and block will not change unless it is re-formatted (or the file system size is changed by using commands such as resize2fs. During formatting, the Ext2 file system basically distinguishes multiple block groups. each block group has an independent inode/block/superblock system. In the overall plan, there is a boot sector at the top of the file system, which can install the boot loader. Call out the currently mounted device: df to view the file system information: dumpe2fs [-bh] the relationship between the device file name and the directory tree directory: When you create a directory, ext2 allocates an inode and at least one block to the directory. Inode records the related permissions and attributes of the Directory and records the allocated block number; the block records the file name in this directory and the inode number occupied by the file name. view the inode number occupied by the file in the directory: ls-I File: When we create a new file, ext2 allocates an inode and the number of blocks relative to the file size to the file. Directory tree reading: the system finds the inode number of the Mount point through the mounting information (usually the top-level inode number of a file system starts from 2 ), in this case, you can get the inode content of the root directory and read the file name data in the block of the root directory based on the inode, to create a file or directory by reading the correct file name one by one: Determine whether the user has the permissions of w and x for the directory to add the file, if yes, you can find the unused inode number based on inode bitmap, and write the permissions/attributes of the new file to the block bitmap to find the unused block number, write the actual data into the block, and update the inode block to point to the data. synchronize the newly written inode and block data to update inode bitmap and block bitmap, and update the content of superblock (unused and used) inode table and data block are called data storage areas, and other super block and blo The ck bitmap and inode bitmap fields are meta data (intermediate data) and the data changes frequently. each addition, deletion, and editing may affect the data in these three fields. Inconsistent data (Inconsistent) status meta data content is Inconsistent with the actual data storage area. In the Ext2 file system, you can determine whether to force a data consistency check by checking the valid bit (whether mounted) recorded in the Super block and the state (clean or not) of the file system. If you need to check the log file system (Journaling file system) with e2fsck program: when the system wants to write a file, logs the information to be written into a file in the log record block. the actual write operation starts to write the permission and data to the file. the update of meta data ends: after the data and meta data are updated, the file is recorded in the log record block in such a program. in case of a problem in the data record process, then, our system only needs to check the log record block to know which file has a problem and check the consistency of the problem. Asynchronously: if the system knows that a file has been transferred to the memory, the file data in the memory segment is set to (clean. However, if the file data in the memory has been changed, the data in the memory will be set to Dirty. At this time, all the operations are still executed in the memory and are not written to the disk. The system writes the data set as Dirty in the memory back to the disk from time to maintain the consistency between the disk and the memory data. File system and memory: the system places common file data in the buffer zone of the primary storage to accelerate the reading and writing of Linux physical memory. This is normal and can accelerate system performance. You can manually use sync to force the files set to Dirty in the memory to be written back to the disk. if the data is not properly shut down, it is not written back to the disk, therefore, after a Linux kernel is restarted, it may take a lot of time to perform disk verification, or even cause file system damage (non-disk damage). Linux VFS (Virtual Filesystem Switch): The Linux kernel manages the file system through VFS, you do not need to know what the file system is in the header of a partition. Simple File system operation: Disk and directory capacity: df, du df: list the overall disk usage of the file system du: Evaluate the disk usage of the file system (often used to evaluate the directory capacity) df-hi: Display in easily readable formats such as GB, MB, and KB without the need for hard disk capacity, the number of inode entries indicates that the read range is within the super block. Therefore, the command displays the result very quickly. Du-s: only list the total amount, instead of listing the occupied capacity of each individual Directory, directly go to the file system to find all the file data, by default, the output size is in KB. Connection File: ln hard link (hard connection or actual connection): creates a new file name under a directory to connect to a record associated with an inode number. Security: if you delete any "file name", inode and block still exist. In this case, you can use another "file name" to read the correct file data. In addition, no matter which "file name" is used for editing, the final result will be written to the same inode and block, so data can be modified. Restriction: you cannot connect to directories across file systems. Symbolic link (symbolic link, or shortcut) creates an independent file, which allows data reading to point to the file name connected to it. After the source file is deleted, the symbolic link file cannot be opened: the symbolic link of the target file can be named with an equal sign with the Windows shortcut, files created with symbolic link are an independent new file. Therefore, inode and block ln-s are occupied. If no parameters are added, the connection is hard link, -s is the symbolic link disk partition: fdisk-l: output all the device partitions followed by df: find the available disk file name, and then use fdisk to check and delete the partition: fdisk: go to the fdisk page. p: check the partition information first. confirm the partition to be deleted. d: Select a partition. w: store it in the disk data table, and leave fdisk to add the disk partition: fdisk: enter the fdisk interface n: Select the partition type (primary partition, extended partition) start cylindrical (default) end cylindrical: + 512MBp: View partition results force update kernel partition table information: partprobe disk format mkfs 【 -T file system format: Device file name disk check: fsck, badblocksfsck [-t file system] [-ACay] device name-A: According to/etc/fastab content, scan the required device once-a (y): automatically fixes the problematic sector-C: A histogram is used to display the current progress during the inspection. This command is usually used only when it is root and the file system is faulty. Otherwise, this command is used normally, it may cause harm to the system. When fsck is executed, the checked partitions must not be mounted to the system! Disk attaching and detaching a single file system should not be repeatedly mounted to different mount points. a single directory should not be repeatedly mounted to multiple file systems as the mount Point Directory. Theoretically, it should be an empty directory mount- a: mount all unmounted disks to mount-l based on the data in the configuration file/etc/fstab: displays the currently mounted information (with the label column) to re-mount the root directory: modify the disk parameters of mount-o remount, rw, auto/umount (detach device files): mknod device name [bcp] [major] [minor] B: external storage device file c: external input device file p: FIFO file set file system volume label: e2label device name new label name tune2fs hdparm-Tt device name: test the reading performance of this hard disk. mount the disk at startup. mount the/etc/fstab and/etc/mtab root directory, and be sure to be mounted before other mount points. other mount points must be A new directory can be specified at will, but it must comply with the required system directory architecture principles. all mount points can be mounted only once within the same time, you must first move the working directory to a special device loop mounted outside the Mount point (and its sub-directories) if it can only be mounted once. (if the image file is not burned, it will be mounted) mount-o loop file address mount address create a large file to create a loop file to help solve the problem of poor partition. Create a large file dd if =/dev/zero of =/home/loopdev bs = 1 M count = 512 format mkfs-t ext4/home/loopdev mount-o loop... The construction of a memory swap space (swap) sets a swap partition to create a virtual memory file using a physical partition to build a swap partition: First use fdisk to separate a partition to the system as a swap, you must also set the system ID. Fdisk/dev/sda-> p-> t (modify the system ID). change the number of partitions to 82, p, w, and partprobe (update the kernel partition table) build swap format: mkswap start to view and load: free (view), swapon (enable partition), free use file build swap use dd add a file use mkswap format the file to swap format use swapon to start use swapoff switch swap file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.