Date: August 30, 2015
Linux Disk Management
Basic knowledge of hard disk
Track
The track is divided by the manufacturer, and how much data a track can store is related to the density of the disc. If the head is held in one position, each head will draw a circular trajectory on the disk surface, which is called the track.
Sector
Each track on the disk is divided into segments, which are sectors of the disk, each of which can hold 512 bytes of information, which is to be sector-based when the disk drive reads and writes data to the disk.
Average seek time:
The disk is a fixed angular speed device, so the average time to read is called the average seek time when the heretics is swept over an arbitrary sector on any track with a long head on the inner lane.
Cylinder cylinder:
Each disc is divided into equal numbers of tracks and numbered from the "0" of the outer rim, with the same numbered tracks forming a cylinder called the disk's cylinder. The number of cylinders on a disk is equal to the number of tracks on a disk.
partition: The No. 0 sector stores the partition information of the disk
MBR: the 0 cylinders, 0 heads, and 1 sectors of the hard disk are referred to as the primary boot sector (also called the Master Boot Record MBR).
It consists of three parts: the master boot program, the hard disk partition table DPT (disk Partition table), and the partition valid flag.
The Master boot program (boot loader) occupies 446 bytes in a total of 512 bytes of the main boot sector, and the second part is the partition table area (partition table), which is the DPT, which accounts for 64 bytes, how many partitions are in the hard disk, and the size of each partition. The third part is the magic number, which accounts for 2 bytes, fixed to 0xaa55 or 0X55AA
512bytes:
Bootloader:446bytes boot loading zone, which is used to boot the boot operating system.
Fat:64bytes (File system allocation label), 16bytes (16 bytes per partition), 4 (up to 4 primary partitions)
MBR validity tag: 5A
Partition of basic hard disk:
1, up to 4 primary partitions
2, can be divided into 3 main points, an extended partition, to create multiple logical partitions on the extended partition
GPT: Partitioning technology that is larger than 2TB
Disk interface type:
IDE: (ATA): 133mb/s
SCSI: 0mb/s
SATA (Serial): Serial, 300Mbps, 600Mbps, 6Gbps
sas:sas:6gbps
Usb:
★ : Multiple partitions can be partitioned on each disk, and each partition appears to be a separate device on the system.
are independently controlled and accessed, so each partition has a device access entry (device file).
hard disk device file: /dev/sd
Mark a different hard drive device:/dev/sd[a-z]
Mark different partitions on the same device:/dev/sd[a-z][1-n]
1-4: Primary or extended partition identification
5 +: Logical partition identification
These partition information is recognized by the kernel after a hard disk device is connected to the current system and stored in the kernel file.
/proc/partitions
Device Files: Special files
Device number:
Major, minor
Major: Device type
Minor: Different devices under the same type
Partition: The delimiter storage space is for multiple small spaces, and each space can use the file system independently.
Partitioning Tools: fdisk , Sfdisk , Cfdisk
fdisk Command
Function
Create partitions, delete partitions, modify partitions on a hard disk ID , see how hard drives are used, etc.
Format:
fdisk [options] <disk> change partition table
fdisk [Options]-l <disk> list partition table (s)
D: Delete partition
N: New Partition
P: List existing partitions
T: Modify the partition tag (ID)
L: List kernel-supported partition IDs
W: Save exit
Q: Do not save exit
Instance:
Create an extended partition and create a 15G logical partition on the extended partition
Use FDISK-L to list existing partitions on a hard disk on the current system
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/84/wKioL1XlggqhQmlfAAF-0YZ5o4o541.jpg "title=" 1.png " alt= "Wkiol1xlggqhqmlfaaf-0yz5o4o541.jpg"/>
Type the FDISK device name to operate on the hard disk, type M to display the menu Help information
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/88/wKiom1Xlf_bjNYMuAAJHdDDIWbI484.jpg "title=" 2.png " alt= "Wkiom1xlf_bjnymuaajhdddiwbi484.jpg"/>
Type N to create the partition, after which you will be prompted to create the primary or extended partition, type E to create the extended partition.
The start input sector is then prompted. All the remaining space on the hard disk is allocated to the extended partition directly here.
and then type in the P , you can list all the partition information, and finally type W , save and exit
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/84/wKioL1XlgiiBnohKAAL8wyXzLB4837.jpg "title=" 3.png " alt= "Wkiol1xlgiibnohkaal8wyxzlb4837.jpg"/>
Create a new logical partition on the extended partition with a size of 15G after the extended partition has been created
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/88/wKiom1XlgCKjmAi0AALvzFvs6Es203.jpg "title=" 4.png " alt= "Wkiom1xlgckjmai0aalvzfvs6es203.jpg"/>
After the creation is complete, check to see if the kernel has identified the new partition:
# cat/proc/partitions, visible although the partition has been created, but the kernel is still not recognized
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/84/wKioL1Xlgm3A5FEQAACDQifhADE545.jpg "style=" float: none; "title=" 5.png "alt=" Wkiol1xlgm3a5feqaacdqifhade545.jpg "/>
Reread the partition table so that the kernel can recognize that partx-a is reading all the partitions on the hard disk,
and pass the partition table information to kernel
Common commands on CentOS 5: Partprobe
Commonly used on CentOS 6: Partx, Kpartx
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/88/wKiom1XlgEyilRt2AAD27uBB5qs209.jpg "style=" float: none; "title=" 6.png "alt=" Wkiom1xlgeyilrt2aad27ubb5qs209.jpg "/>
Linux disk partition Management