In the previous article, “Disk Begins: Peeling away the hard coat of mechanical hard disks!” In, we learned about the physical structure of a mechanical hard disk, which is composed of disk faces, tracks, sectors and other smaller units, as shown below:
Partitioning is the first step in an operating system’s management of disks, a concept that any of us computer users are familiar with. For example, drive C, D, E, and F in Windows. So think about it. If you were an operating system designer and you were asked to divide the entire disk into C, D, etc., how would you do it?
For the sake of argument, the hard drive you’re dividing here has 50 plates and 3,000 cylinders. We give you two scenarios
- Plan 1:50 plates, 0-10 plates in C, 10-20 plates in D…
- Scheme 2:3263 cylinders, 0-1000 cylinders in Disk C, 1001-20001 cylinders in disk D…
Let’s talk about which solution is better in terms of disk read/write latency. The principle of reading and writing is also simple, it is the process of the magnetic head to find the specified track, the specified sector, and then read or write data into the process. The process is divided into three steps:
- The first step is to move the head radially to find the track where the data is. This part of the time is called seek time. The seek time of modern disks is about 3-15ms, which is mainly affected by the relative distance between the current location of the magnetic head and the location of the target track
- The second step is to move the target sector directly below the head by rotating the disk after finding the target track. This part of time is called rotation delay. Now mainstream servers often use 1W RPM disks, and the time required for each rotation is 60*1000/10000=6ms, so the rotation delay is (0-6ms).
- The third step is to read or write data to the target sector. This part of the time is called access time. This is an electromagnetic operation, so it usually takes a few tenths of ms.
Up to this point, single disk IO time = seek time + rotation delay + access time
Which scheme to use on partition, the most important thing is that the performance of that way is faster. In the use of disk partitions, there is a basic fact that data in the same partition will often be read together. The performance of the two schemes for rotation delay and access time is the same, but the main difference is the performance of seek time:
In the first case, the head would have to constantly hop between 3,000 tracks, so that the disk’s seek time would not fall. In scheme 2, for disk C, it is only necessary to move the head between 1 and 1000 tracks, greatly reducing the seek time.
So all the operating systems are using Plan 2, not Plan 1. Note the following information if you have used fdisk for partitioning under Linux.
The partitioning process is where you enter the starting and ending cylinder numbers. In practice, however, partitions do not start on cylinder 0, because the first track of the disk corresponds to the cylinder that is used to install the boot loader and disk partition table.
Therefore, the operating system partitions disks according to their corresponding cylinders to reduce the seek time of disk I/OS and improve disk read/write performance
The development of internal training of hard disk album:
- 1. Disk opening: remove the hard coat of mechanical hard disk!
- 2. Disk partitioning is also a technical trick
- 3. How can we solve the problem that mechanical hard disks are slow and easy to break?
- 4. Disassemble the SSD structure
- 5. How much disk space does a new empty file occupy?
- 6. How much disk space does a 1-byte file occupy
- 7. Why is the ls command stuck when there are too many files?
- 8. Understand formatting principles
- 9. Read file How much disk IO actually occurs per byte?
- 10. When to initiate disk I/O write after one byte of the write file?
- 11. Mechanical hard drive random IO is slower than you might think
- 12. How much faster is an SSD server than a mechanical one?
My public account is “developing internal Skills and Practicing”. Here I am not simply introducing technical theories, nor only introducing practical experience. But to combine theory with practice, with practice to deepen the understanding of theory, with theory to improve your technical practice ability. Welcome you to follow my public number, also please share with your friends ~~~