Storage Management 1

A physical storage device

In the Linux system, everything is a file, the hardware device is no exception.

1, common hardware and file name:

hardware equipment

file name

IDE devices

/dev/hd[a-d]

SCSI / SATA / U Infrastructure

/dev/sd[a-p]

Floppy

/dev/fd[0-1]

printer

/dev/lp[0-15]

CD-ROM

/dev/cdrom

mouse

/dev/mouse

Tape Drives

/ Dev / st0 or / dev / ht0

Now that the IDE device has rarely met, it is generally hard disk device will begins with the "/ dev / sd". And a host may have multiple hard disks, so the system uses a ~ p to represent 16 different hard disk (the default is allocated from A), and the hard disk partition number is also very particular:

Primary or extended partition is numbered from 1 to 4 ends; logical partitions numbered starting from 5.

Note :

1, / dev directory device sda ​​reason is a, not determined by the slot, but by the recognition sequences of the system kernel;

2, digital code is mandatory extended partition is not necessarily down, there may be manually assigned.

2, for example interpret the meaning of the disk partition

To / dev / sda5 interpret its meaning, for example:

First, save the / dev / directory should be a hardware device files;

Secondly, sd denotes a storage device;

Then, a represents the system interface similar to the first device is identified;

Finally, 5 indicates the device is a logical partition.

In short, "/ dev / sda5" is represented by "This is the first system to a hardware device identified in the logical partition of the partition number 5 device file."

3, disk partition

Hard disk apparatus is a large number of sectors, each sector has a capacity of 512 bytes. Wherein the first sector of the most important, which it holds the master boot record and partition table information. To the first sector is concerned, need to occupy the master boot record 446 bytes, the partition table is 64 bytes, 2 bytes terminator; wherein each of the partition table recording partition information requires 16 bytes, so that only a maximum of four partition information can be written to the first sector, four partitions is four primary partitions.

The first sector:

In order to solve the problem of insufficient number of partitions, the first partition table may be a sector of 16 bytes (the original information to be written into the main partition) space (called the extended partition) to point out another partition. In other words, an extended partition is actually not a real partition, but more like a 16-byte pointer to the partition table occupied space - a pointer pointing to another partition. Thus, the user will generally choose to use 3 primary partitions plus an extended partition method, and then create a number of logical partitions in the extended partition, so as to meet the multi-partition (greater than 4) needs.

Second, the file system and data storage

1, the file system

Files performed by the user in the hardware storage device establishing, writing, reading, modifying, and dump control other operations rely on the file system to complete. The role of the file system is reasonable plan hard to ensure the user's normal needs. As shown in the Linux system to support dozens of file system, and the most common file system as follows.

Ext3 : is a journaling file system, the file system can avoid data loss when the system is abnormal downtime, and can automatically fix inconsistencies and erroneous data. However, when a large hard drive capacity, required repair time will be very long, and can not guarantee 100% data is not lost. It will every detail of the entire disk write operation is pre-recorded, in order to be able to trace back to the interrupted portion of downtime after an exception occurs, and then try to repair it.

Ext4 : improved version of Ext3, as the default RHEL 6 system document management system, which supports a storage capacity of up to 1EB (1EB = 1,073,741,824GB), and can have an unlimited number of subdirectories. Further, Ext4 file system can allocate block block quantities, thereby greatly enhancing the efficiency of reading and writing.

XFS : it is a high performance journaling file system, and is the default RHEL 7 document management system, its advantages particularly evident after the occurrence of unplanned downtime, which can quickly recover files may be corrupted, and the powerful logging computing and storage functions with only a very low cost performance. And it can support a maximum storage capacity is 18EB, which meets almost all needs.

2, the data storage

Linux is the authority attribute of each file is recorded in the inode, and each occupies a separate file inode tables, default size of this table is 128 bytes, which records the following information:

Access the file (read, write, execute);

The owner of the file with the belonging group (owner, group);

The file size (size);

Create or contents of the file modification time (ctime);

Last access time (atime) for the file;

The file modification time (the mtime);

Special file permissions (SUID, SGID, SBIT);

The real address of the data file (point).

The actual contents of the file is stored in the block blocks (size may be 1KB, 2KB or 4KB), only the default size of an inode 128B (Ext3), a block record is consumed 4B. When the inode file is filled, Linux system automatically assigns a block block, dedicated to recording as other information like block inode blocks, each block so that the block content to string together, it is possible to allow the user to read the complete the contents of the file. For block contents block storage file, there are two common cases below (in 4KB block size as an example).

Case 1: The file is very small (1KB), but still occupies one block, thus potentially wasting 3KB.

Case 2: very large file (5KB), it will take two block (after 5KB-4KB remaining 1KB have occupied a block).

In order to make the user when reading or writing files do not care about the underlying structure of the hard drive, Linux kernel software layer for the user program provides a VFS (Virtual File System, a virtual file system) interface, so that the user is actually in operation file this is the unity of a virtual file system to operate.

The VFS architecture diagram

Guess you like

Origin www.cnblogs.com/yxf-/p/11408693.html