Linux Learning Record (c): disk and file management system

Prior to this, we must first know Ext, it was extended file system (English: Extended file system, Ext abbreviated or Ext1), system A document, published in April 1992, it is the first one done for the Linux kernel File system.

Ⅰ.Linux most traditional disk file system is using Ext2

Information in EXT2 mainly:
1.block: The actual location of the file data storage, if the file is too large to occupy multiple Block;
2.inode: record properties file, a file occupies one inode, inode which will record this block number where the data file;
3.superblock: recording information comprising the total amount of inode / block, the amount of the remaining amount, the file system format outsider.

Means that the specific content and file attributes placed separately, this way, then quickly and easily find.

Data access Ⅱ.Ext2 file system

Indexed : inode and block are numbered, if we create a file, then the file will take up a inode, block numbers will be stored in the corresponding file data inode. So if we want to read this file, first read the smaller inode can then jump to the specific content there, do like this will be convenient to quickly find files.

Ⅲ. File defragmentation reason and purpose

When the block file written too discrete (such as file a small footprint, but the store a few block number interval particularly) when the file read performance becomes poor. You can block the same file belongs to the summary by defragmentation, reducing the number of discrete extent, improve the reading speed.

Six major Ⅳ.Ext2 file system

1.boot sector: boot sector, the boot loader can be installed
2.superblock: recording information comprising inode / block of the total used amount, the remaining amount, the file system format outsider;
3.inode Bitmap: the inode control table, information is recorded whether each inode may be used;
4.block Bitmap: block table, information is recorded for each block may be used;
5.inode table: inode table, which are all inode, and a 128bytes, since one file will take up a inode, so the number of its decisions can have a number of files;
6.block the table: block table, all of the block in this, and there is 1KB, block 2KB, 4KB three types of files put the contents of the file, block directory put the file name and the corresponding inode bitmao in that directory.

Query file system information: dumpe2fs

Behavior Ⅴ. When you add a file system

1. Check whether the user has in the catalog w and x permissions, you can create anything;
2. The inode bitmap using the available inode number, write the new file permissions / attribute;
3. The block bitmap using the available block number, write the actual data, while updating the data block number within the corresponding inode;
4. the inode number with the block data of the steps to synchronize updates inode bitmap, block bitmap, and among the superblock.

View directory and disk capacity: du, df

Ⅵ. Log (TECHNOLOGY) file system

Occasionally, when a sudden power failure, when the behavior of the new file system can not be completely finished, it will cause inconsistencies in the inode and block information into various parts. To overcome this data in an inconsistent state, it creates a log (journal) file system, writing a file system, will now record a block of log records in the file to prepare to write something, until all the appropriate behavior all over, again log in to complete the record.

Ⅶ. Connection file

There are two main ways
1.hard link (physically connected): generates a new file name from an inode connection, no new file, then the file may correspond to a plurality of names to the same inode number, but can not cross the file system operation;
2 .symbolic link (symlink): similar to Windows shortcut to create a separate file, which let the read data to the file name of the file attached to it, it will be spent this way inode and block.

It seems so, if there is a very hidden file A below put some of your deposit a small movie, and then you open another in order to facilitate the building of a real connection B, if one day suddenly people found this hidden file to A you deleted, then you can open with a B or a small movie (because the corresponding inode and blocks are still). But if you were to create a symbolic link is C, then this will not delete you see these little movies, because C is a point A, and only the inode corresponds to a file name and this A small movie, so a deleted A the corresponding inode and blocks were all deleted. Such a talk, it may be a little clearer.

Production connection file: ln (-s plus a symbolic link, without an actual connection)

VIII. New operation when a hard disk

1. disk partition, to create a new partition available;
2. to create a new partition formatted to create a system available file system;
3. test what the new file system;
4. Create mount points, mount it up.

Disk partition: fdisk (you can add, delete, write)
disk format: mkfs, mke2fs (not used)
disk test: fsck, badblocks
disk mount and unloading: Mount, umount
(? Such as a change of name) disk parameter modification: mknod, e2label, tune2fs, hdparm

Released five original articles · won praise 1 · views 102

Guess you like

Origin blog.csdn.net/weixin_41425032/article/details/104159655
Recommended