Brother Bird's Linux learning Note III

Source: Internet
Author: User

8th Linux disk and file system Management

1 disk composition and partitioning: The disk consists of a round disc, a head, a spindle motor and so on.          The main platters are: sector (Sector) is the smallest physical storage unit, each sector 512bytes a sector of a circle, that is, cylinder (Cylinder), is the smallest unit of the partition. The first sector is the most important, there are MBR (Master boot record), partition table, MBR accounted for 446 bytes, partition table accounted for 64bytes.
Partitioned tables support up to 4 partitions, either as primary primary partitions or as extended extended partitions.                    There is a maximum of one extended partition, and a logical partition is distinguished by an extension. Only the primary and logical partitions can be formatted.
The various interfaces of the disk in Linux file name:/dev/sd[a-p][1-15]: For SCSI, SATA, Usb,flash and other interface devices/DEV/HD[A-P][1-63]: For the IDE interface of the magnetic Plate.
2. File system features are formatted after partitioning because each operating system has different permissions for the file attributes, in order to store the data required for these files, the partition needs to be formatted to become a file format that the operating system can take advantage of. The Linux formal file system is Ext2 (Linux second Extended file system,ext2fs), and by default, Windows does not recognize the Linux Ext2 file system.
Traditionally, a partition can only be formatted as a file system, i.e. a filesystem is a partition. However, with the development of new technology, our regular channel LVM and floppy disk array (software RAID) can format a partition into multiple file systems, and also be able to synthesize multiple partitions into a file system.          At the moment, we're not talking about formatting a partition, it's a file system instead of a partition that can be hung. Linux newer file systems, in addition to file data, there are many properties, such as rwx and file attributes (owner, group, time parameter, etc.). The file system will usually have different blocks of these two pieces of data, permissions and attributes in the Inode, the data in the database block, and a super-fast (Super block) will record the entire file system overall information, including the total Inode and block, the amount of usage,          Amount of surplus.          Super BLOCK: Records the overall file system information, including the total number of inode and block, usage, Remaining amount, file system format and related information.          Inode: Record file attributes, one file occupies an inode, and the block where the file data resides is recorded.          Block: Log the file data, if the file is too large, will occupy multiple blocks. This access method is called an indexed file system (indexed allocation).
3 Linux Ext2 File System (inode)       file system the Inode and block are planned from the beginning, unless reformatting or changing the file system size with commands such as RESIZE2FS, Otherwise, the inode and block will no longer change after they are fixed.       When EXT2 format is divided into multiple block groups (block group), each block group has a separate Inode/block/super block, the file system has a boot sector at the front (boot sector), This boot sector is used to install the boot loader.       Each block group has 6 main components: Data block:      The block size supported in EXT2 is 1KB, 2KB, 4kb Three, the block size is fixed when formatting, Each block is numbered to facilitate the inode record. The block size determines the maximum single file size that the file system can support as follows:     inodetable:     inode recorded file data has the following:          Access mode for this file (rwx);          file owners and groups (owner, group);        &NB Sp File size;          file creation or status change Time (CTime)           Last read time (atime);  &NB Sp       Last modified (mtime);          defining file features flag flags, such as setuid         &N Bsp The actual data content of the file;          inode is formatted with the number and size of,          each inode largeSmall 128bytes;          Each file occupies a inode;          file system can be created with the number of files and the number of inode related ;          When the system reads the file, it finds the corresponding Inode, analyzes the permissions recorded by the Inode and whether the user is compliant, and if so, begins reading the block blocks that point to.
Inode/block relationship to file size: The inode structure is as follows: The Inode has 12 direct points, an indirect, a double indirection, and a three-indirect record area. If 1k blocks, each block record needs 4bytes, so 1k block can record 256 block records.
Super BLOCK: The recorded information mainly includes: block and inode total, unused and used Inode, block number of block and inode size (1k, 2k, 4k; 128by TES), file system mount time, last write data time, last check disk (fsck) time and other file system related information; a Validbit value that indicates whether the file system is mounted.
In general, the Superblock size is 1024bytes. Related information can be viewed using the DUMPE2FS command.
FileSystem Description (File system description): Used to describe the start and end block numbers for each block group, and which block the Superblock Inode block is located in each section;
Block bitmap: Used to record those blocks used, those blocks are unused.
Inode bitmap: Records the use and unused status of the inode.
DUMPE2FS [-BH] Device filename-B: Lists the portions reserved as bad lanes-H: Lists the data for Superblock, and does not list other sections.
DF: This command brings up the current Mount device
4. ext2/ext3 file access and log file system: In general, the Inode table and data block become data regions, and other regions become metadata (intermediate regions).               Log file system: 1: prestaged, when the system writes to a file, the log records are now always logged to the qualified file to prepare the information for writing. 2: Actual write: Begin to inhale file permissions and data, start updating meta data data 3: End: Complete the data with Meta Data Update, complete the record of the file in the log record block.
So when the power outage, and so on, the system just check the log record block to know that the file problems, for the issue of consistency check.
5 Linux file Operation: When the system loads a file into memory, if the file is not changed, the file data in the memory section is set to clean, and if it is changed, the data in memory will be set to dirty, and the system will set the memory to dirty data-rest disk at irregular time. Maintains disk-to-memory data consistency.
You can use the Sync command to force dirty files in memory to be written back to disk.



Brother Bird's Linux learning Note III

Related Article

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.