in this chapter, we begin the introduction of Linux system, we first understand the structure of the disk and the concept of file system, in the foundation of the previous article, the main introduction of the use of Linux commands and other concepts, knowledge is trivial, I hope that these basic knowledge can be consolidated, alas ... Life is difficult, it is hard to learn. So in this chapter we'll talk about Linux disks and the concept of file systems.
I. Components of the operating system
our operating system components are roughly divided into hardware and software, hardware equipment is the lowest level, which is a computer running foundation, von Neumann defined hardware components, is the CPU (composed of the operator and the controller) and then the memory (main memory, that is, Ram device), is a addressable storage unit, its unit is a size is a byte, is a string of eight-bit binary composition, each byte has a hexadecimal identifier, but the memory is only temporary storage , as long as a power outage, all the data will not, so we need a secondary storage, used to permanently store the data, after the power outage, the data still exist, now, if the host can not connect the network is an island, then the network card device is another important IO device, for the server, The NIC is extremely important because it is an interface for service access.
early hard disk devices for the PC interface there are many kinds of, early IDE, and now SATA, and so on, the type of cable is not the same, the data type of access is implemented by the CPU, the transmission between them is also through some kind of protocol to achieve.
Let's summarize the hardware components and the types of hard disk interfaces.
cpu, memory (RAM), i/o i/o:disk, ehtercard interface type: ide (ATA): The same port, 133mb/s         SCSI and:ultrascsi320, 320mb/s, ultrascsi640, 640mb/s sata: Serial,6gbps; sas: Serial port, 6GBPS;        USB: Serial port, 480mb/s
so about the type of interface is divided into roughly two parts, one is the same port, the other is the serial port, supposedly, and the port than the serial port to be faster, like a number of runways run together, But they have a weak defense mechanism that interferes with each other,
: The same cable can be connected to multiple pieces of equipment ide: Two, Master, from;      SCSI: Broadband:16-1 narrowband: 8-1 Serial: The same cable can only be connected to one device iops:io per Second
Then now the hard disk is divided into two kinds, one is a mechanical hard disk, the other is a solid-state hard disk, the two ways to achieve storage is not the same, the mechanical hard disk is a mechanical device, is a hard disk rotation to carry out data access, and solid-state drives are electrical equipment, through the operation of electronics to achieve, So the latter is faster for data access.
Second, the working principle of hard disk
we mainly understand how the mechanical hard disk is working, simply speaking, is a vacuum package, driven by the motor of a plurality of steel-like platters, coated with magnetic materials, Access to data is achieved through the fixed orbit above, and the storage capacity of the data depends on the density of the magnetic material applied, which requires a high level of technology, and the platters are divided into many orbits from the outside, which we call the track.
A lot of tracks on the disk, the data stored for each track is not the same, on the coaxial motor, the length of the slide is not the same, is a fixed angular speed device, for data access, on the disk suspended a magnetic head, It can also be used to read data from magnetic materials on the disk and to send high-energy signals for storage in magnetic materials; This device we call the head.
for disk, both sides have heads, these heads are fixed on a robotic arm, so reading data consists of two parts, the first step is to move the head, positioning in the track, the second step is to wait for the data to turn over the head, Therefore, reading the data on the track will have an average seek time. But because the perimeter is not the same from the inside out, so it is not possible to store with a track, otherwise it is difficult to achieve effective management of data, so the track is divided into fixed-size sectors, each sector storage capacity of 512bytes.
just said, these heads are fixed on the robotic arm, that is, can be synchronized, in a moment, the same number of different disk tracks, called a cylindrical surface.
then why partition, if not partition, will be as a file system for storage, but generally only support four partitions, but in order to become an independently managed file system, each other does not interfere with each other, so the partition is partitioned. The division of partitions is carried out according to the cylinder surface. The closer the partition, the better partition, because the unit time, the head across a long time, the amount of data stored is also large, so the general Windows default will be installed on the C drive.
Hard disk: Mechanical hard disk, solid-state drive, mechanical hard disk: Track: Tracks bytes sector: sector, cylinder: cylinder partitioning is based on cylindrical surface; Average seek time: 5400rpm, 7200rpm, 10000rpm, 15000rpm
iii. type of equipment
For the philosophy of Linux, is all documents, this philosophical thinking can be treated on the hard disk device, so that the device has two categories, one is a block file, and the other is a character file.
Device type: Block: Random access, data exchange unit is "block"; character (charactor): Linear access, data exchange unit is "character";
and one of the philosophy of Linux: All documents, they also have files to control the device, which we call device files, according to FHS ( File hierarchy Standard), the system will store the device files in the/dev directory, and the main function of the device file is to correlate the device's startup program, which is the access entry of the device, each device will have a device number, no size of the points.
Device File:fhs /dev Device file: The driver associated to the device; the access entry for the device; device number: major: Main device number, differentiating device type To indicate the required driver for the device; minor: Secondary device number, Differentiate different devices under the same device type; a specific access entry;
If you need to manually create device files in the future, you can use the Mknod command. It is a command that can create a block device and a character device file with the following command format:
Mknod [OPTION] ... NAME TYPE [MAJOR MINOR]
The command options are as follows:
-M MODE: access to device files after creation
then all the device filenames on the system are defined by ICANN, otherwise, different distributions will have a distinct difference in the file name of the device, for the system , different disk devices will have different device files. Examples are as follows:
Disk: Ide:/dev/hd[a-z] For example:/dev/hda,/dev/hdb SCSI, SATA, USB, sas:/dev/sd[a-z] Partition:/dev/sda# Note: CentOS 6 and 7 all identify the hard disk device file as/dev/sd[a-z]# Reference device: Device file name, volume label, UUID;
third, disk partitioning
We just said that the disk can only be divided into four zones, which belongs to the MBR type, now not only the MBR type, there is GPT type, 0 tracks 0 sectors, Used as an MBR sector, the MBR we call the master boot record, a total of 512 bytes, divided into three parts, but it seems to be more than four partitions, this is because we take one of the partitions to point to another storage space, the new space as a new storage table for storage, The partition used to guide the other partition is called the extended partition, so the whole space can be extended partition, but the extension can not be used directly, need to create logical partition in this point, the last primary partition is divided into extended partition, then we summarize:
disk partition:mbr, gpt mbr:0 sector Master Boot Record is divided into three parts: 446bytes:bootloader, program, boot operating system; 64bytes: Partition table, Each 16bytes identifies a partition, with a total of only 4 partitions;       4 Primary Partition 3 Master 1 Extension: n a logical partition; Extended partition: Point one primary partition to another partition table, We call it an extended partition, and here we call it the logical partition of the partitioned space; The validity of the    2BYTES:MBR area is identified; 55AA is a valid; identification of primary and extended partitions:1-4; logical partition: 5+;
even if one of your extended partitions is useless, the logical partition should start with 5+.
the command to manage disk partitions is FDISK, which is used to manage disk partition tables, and the format and usage of the command is:
fdisk command: 1, view partition information of disk; fdisk -l [-u] [device]: Lists the partitions on the specified disk device;          2, Managing Partitions: fdisk device fdisk provides an interactive interface to manage partitions, which has a number of subcommands for different management functions, all of which are done in memory, are not synced directly to the disk, and are saved directly to disk using the W command; Common Command: n: Create new Partition; d: Delete existing partition; t: Modifying an existing partition; l: View all known id; w: Save and exit;Nbsp; q: Do not save and exit; m: View Help information; p: Displays existing partition information;
Then if you want to use it next, you can add a hard disk or on an existing disk to find the existing space to operate.
2018-1-17linux System Management (1) Linux disk and file system concepts