disk-level conceptsThis is mainly about the online so-called old-fashioned disk, it is composed of a platter, we start from a disc structure. 1, the graph of a circle of gray concentric circle for a track, from the center to draw a straight line, you can divide the track into a number of arcs, each track an arc segment is called a sector (the green part of the picture). A sector is the smallest constituent unit of a disk, usually 512 bytes. Figure 2 shows a disk composed of a three-dimensional structure, a platter on both sides are read and write, the blue part of the picture is called cylinder (cylinder).
After a brief introduction of the disk structure, we will explain the parameters of the disk below. Common parameters for disks are as follows:
- head (head)
- track
- cylinder (cylinder)
- sector (sector)
- disc (platter)
The disk in Figure 2 is a disk with 3 discs, 6 heads, 7 cylinders (7 tracks per platter), and 2 sectors per track in Figure 12, so the capacity of this disk is 6*7*12*512 bytes.
That
Storage capacity = number of Heads x track (cylinder) x number of sectors per sector X number of bytes per sector
Let's talk about modern disks, in older disks, although the perimeter of the tracks is different, the number of sectors on each track is equal, and the more the segment segments are shorter, the higher the storage density. However, this is obviously a waste of space, so the modern disk is replaced by a density structure, which means that the number of sectors on the perimeter track is larger than the inner ring track, and the addressing method is also changed to a sector-based linear addressing. To be compatible with old-fashioned 3D addressing, there is an address translator in the modern disk controller that translates the dimensional addressing parameters into linear parameters.
Source: <http://www.cnblogs.com/joydinghappy/articles/2511948.html>
sector (sector): Smallest physical storage unit, 512bytes per sector
Cylinder (cylinder): a circle of sectors consisting of a cylinder that is the smallest unit of a partition (partition)
First sector: Includes boot record (Mbr,master boot recording) and partition table (partition table), where MBR is 446bytes,partition table 64byte
because the partition table size is only 64byte, only 4 partition information can be stored, which is why a hard disk can only be divided into four primary partitions, or one of them as an extended partition in which the logical partition is partitioned.
Multi-Boot
The Blue is MBR in the picture, yellow for each partition's boot sector (boot sector)
- each partition has its own boot sector (boot sector)
-
- The actual bootable core file is placed in each partition!
- loader will only know the bootable core files within the system partition, as well as other loader;
- loader can direct or indirectly transfer administrative authority to another hypervisor.
Zoning Conceptsthe smallest unit of the partition is the cylinder, the cylinder = number of sectors per track * Sector size * Number of heads, so the partition cannot be accurate in size and there will be a deviation of the cylinder size.
partitions are as follows A hard disk is initially the MBR and partition table, and each partition has its own boot sector.
File System ConceptsThe file system defines what structure the data is stored in. each partition can be a different file system, and the partitioning of the file system is for the partition. Linux File system ext2 is mainly divided into three types of structure, Superblock,inode,block.
Superblock (Super block)
Superblock records the entire filesystem-related information where, without superblock, there is no filesystem
- Block vs. Inode Total
- Unused and used Inode/block quantity
- Size of block and inode
- FileSystem mount Time, last write data time, last check disk time, etc.
- A valid bit value, if mounted as 0, otherwise 1
inode
- The number of bytes in the file
- User ID of the owner of the file
- The group ID of the file
- Read, write, and execute permissions for files
- The timestamp of the file, total three: CTime refers to the time when the inode was last changed, mtime refers to the time when the file content was last changed, atime refers to the time when the file was last opened.
- Number of links, that is, how many file names point to this inode
- Location of file data block
block
The size is generally 1k,2k,4k, which is the area where the content of the data is actually stored.
the relationship of the three of them
there 's another part.
Filesystem Description (File system description)This section can describe the start and end block numbers for each block group, as well as the description of each section (Superblock,Bitmap, Inodemap, data block) are located between each block number. This part can also be observed with DUMPE2FS..
block Bitmap (block table)If you want to add files, always use block! So you're going to use that block to record it? Of course, the choice is "empty."block "to record the data for the new file. So how do you know that block is empty? This has to go through block bitmap.up. From the block bitmap, you can see which blocks are empty, so our system can quickly find a way to usespace to dispose of files.
inode bitmap (inode table)this actually does not block bitmap is a similar function, just is the block bitmap record is the use of the block number is not used, as forInode Bitmap is a record of using an unused inode number!
how directories and files are stored
How directories are storedWhen we build a login on Linux's ext2 file system, ext2 allocates an inode not at least one block to thedirectory. Where the Inode records the permissions and attributes of the directory and can record the block number assigned to it, and blockis the inode number data that is recorded in this directory and the file name that is occupied by the filename.
how files are storedfile storage is also allocated an inode, and this inode has 12 direct, one indirect, one double indirect, one three indirect record area
File retrieval Process
such as opening the/var/test file processfirst Find/directory, and then find its corresponding block below the directory name Varthe corresponding inodefind the corresponding block in the Var inode and find the file TEs in the blockthe inode corresponding to Tlocate the corresponding block in the inode of test, which is the contents of the test file.
as shown
Reference article:http://www.cnblogs.com/vamei/p/3506566.html
From for notes (Wiz)
Linux disk and file system concept understanding