Disk structure
Number of sectors, tracks, cylinders and heads
The most basic part of the hard disk is made of hard metal materials coated with magnetic media, the number of different disk sizes. Each platter has two sides and can record information. Each track is divided into a number of sector-shaped areas, each of which is called a sector, and each sector stores 128x2 N-th (n=0.1.2.3) bytes of information. In DOS, each sector is 128x2 2 square = 512 bytes, the disc surface is centered on the center of the disc, concentric circles of different radii are called tracks. In a hard disk, a cylinder consisting of a track of the same radius on different platters is called a cylindrical surface. Track and cylinder are different radii of the circle, in many cases, the track and the cylinder can be used interchangeably, we know that each disk has two faces, each face has a head, used to distinguish the number of magnetic first. sector, track (or cylinder) and head number constitute the basic parameters of the hard disk structure, to help these parameters can get the capacity of the hard disk, the base calculation formula is:
Storage capacity = number of Heads x track (cylinder) x number of sectors per sector X number of bytes per sector
The first sector of the entire disk is the most important (the first sector is in the outer ring.) The circumference of the outer ring is greater than the circumference of the inner ring, i.e. the outer ring has a smaller storage density and higher reliability. ), because it records two important messages:
- The main boot record area (Master boot record,mbr) can install the boot management program where there is 446byte
- Split table : Record the entire disk partition status, 64byte
MBR is very important, because the system will be active to read the contents of this block, so that the system knows how to boot, if you installed a multi-boot system, MBR will have a record.
Split table, a disk can be used only if it is split first
Disk partition table (split table):
The start and end magnets seen earlier are the smallest units of the filesystem, the smallest unit of the divider .
You can also see that the first sector is outside the partition.
Assuming the above disk device file name is/dev/hda, then these four slots are listed in the Linux system as follows
- P1/dev/hda1
- P2/dev/hda2
- P3/dev/hda3
- P4/dev/hda4
When the operating system is window, the code name is C,d,e,f
Since the separator table has only 64 bytes, and each partition needs 16 bytes to represent, it can hold up to four splits , and four splits are called primary partitions or extended partitions
- ? In fact, the so-called "split" just is set for that bytes partition table.
- ? HDD Default obituary partition table can only write four groups of split information
- ? These four sets of split information we call the primary (Primary) or extended partition (Extended) split slot
- ? The smallest unit of a split slot is a magnetic column (cylinder)
- ? When the system is written to disk, it must refer to the disk partition table for data processing for a split slot
Why to split:
1. Security of data:
Because the data for each split slot is separate! So, when you need to reorganize the data for a split slot, for example, when you want to reinstall the Windows C slot on your computer, you can move other important data to other split slots, such as moving mail and desktop data to the D slot, and the C-slot heavy-irrigation system shipowner not affect the D-slot! Therefore, the use of split slots can be more secure data.
2. System Effectiveness Considerations:
The data is concentrated in a section of a magnetic column by a two slot, for example, the first split slot in the second magnetic column number 1~100, so that when there is data to read from the partition slot, the disk just will search the front 1~100 of the magnetic column range, by two data set, will help the data read speed performance! So, segmentation is very important!
Logical Partitioning
Since the partition table just has the space to record four sets of data, does that mean I can only split four slots in a hard drive? Of course not! A hard drive is split into more than 10 slots! How is that achieved? In the Windows/linux system, we are dealing with the extension (extension) Division (Extended) We have just talked about! The idea for an extended split is that since the partition table where the first section is located can only record four data, can I use the extra partition to record more split information ? The actual show is a bit like the bottom:
In this, we know that the hard disk's four partition record area only uses two, the P1 is the main division, and the P2 is the expansion division. Note that the extension is intended to use additional partitions to record the split information , and the extended partition itself cannot be formatted . Then we can continue to make a record of the partition by extending the block that the segment points to.
As in the lower right section of the block has continued to split out five splitter slots, these five by the expansion of the division continues to cut out the split slot, is called the logical partition slot (logical partition). Also note that since the logical split slot is further segmented by the extended split, the range of magnetic columns He can use is the range set by the extended split. That's the 101~400 in the picture!
Similarly, the above partition slots in the Linux system device filenames are as follows:
- ? P1:/dev/hda1
- ? P2:/dev/hda2
- ? L1:/dev/hda5
- ? L2:/dev/hda6
- ? L3:/dev/hda7
- ? L4:/dev/hda8
- ? L5:/dev/hda9
How do you have a device file name/dev/hda3 not/dev/hda4 it? Because the first four numbers are reserved for the primary partition and extended partition! So the device name number of the logical partition slot starts with number 5th! This is a very important feature!
Window c is the primary partition, DEFGH and so on is a logical partition under the extended partition ( can be formatted, can be used directly to use either the primary partition, or the logical partition )
We make a simple definition of the main segmentation, extended segmentation, and logical segmentation:
- ? The main partition does not extend the division can have up to four strokes (hard disk limit)
- ? extended splits can have up to one (Limitations of the operating system)
- ? The logical segmentation is a continuous cut-out slot by the extended segmentation;
- ? After being able to be formatted, the partition slot as the data access is the main partition and the logical division. Extended segmentation cannot be formatted;
- ? the number of logical partitions varies according to the operating system, in Linux systems, the IDE hard disk has a maximum of 59 logical partitions (number 5th to 63rd), the SATA hard disk has 11 logical partitions (5th to 15th number)
Segmentation is a very troublesome thing, because he is in the Magnetic column as a unit of "continuous" disk space, the expansion of the partition is a similar to a separate disk space , so in the split should pay special attention.
if the extended partition is destroyed, all of its logical partitions will be deleted because the logical partition is recorded in the extended partition.
So in general, if the first sector physical entity of a disk is broken, the disk is also useful for wood . Because the system can't find the partition table, how to know how to read the magnetic column range?
Give me a chestnut:
If my PC has two SATA drives, I want to split 6 available slots on the second hard drive (which can access the data), what are the file names for each slot in the Linux system? And what are the split types? Write at least two different ways to split.
For:
Since P (primary) +e (extended) can only have up to four, where E can have at most one . Now the topic requires 6 available slots, so it is impossible to separate four P. Below we assume two environments, one is to use all the first fourth, one is to spend only one P and one E (Window classic segmentation):
? P+p+p+e Environment:
P+e:
Boot program
The operating system is also software, that when the computer is turned on how to recognize the operating system software and execute his? When the computer does not have any software system, how does he read the operating system files in the hard drive?
- CMOS is a storage device that records various hardware parameters and is embedded in the motherboard
- The BIOS is a firmware written to the motherboard (firmware is a software program written to the hardware)
This BIOS is in the boot, the computer system will take the initiative to execute the first program !
Next the BIOS will analyze what storage devices are in the computer, we take the hard drive as an example, the BIOS will be based on the user's settings to obtain a bootable hard disk (or USB flash drive, disk. The BIOS can set the boot order) and go to the hard drive to read the first sector , when the BIOS becomes full, And the next is the MBR in the boot management program work.
This boot manager is intended to be in load core archives , The boot manager is provided by the operating system at the time of installation, so he will know the file system format in the hard drive, so he can read the core files, then the core files, then the work of the kernel file, the boot management program also become full, and then you know the The task of operating system !
1. BIOS: Boot active firmware, will know the first device to boot
2. MBR: The first bootable device in the first sector of the main boot record block, including the boot management program
3. Boot manager (boot loader): a software that can read core files to execute
4. Core Archives : Start the function of the operating system
The main tasks of this boot loader are the following items:
- ? Menu: Users can choose different boot items, which is also an important function of multi-boot!
- ? Load the Core archives: direct point to the bootable program section to start the operating system;
- ? Transfer other loader: The power-on management function is transferred to other loader.
3rd bad Understanding, in fact, at the same time there is a bit hard important
- Boot needs management Program
- The boot manager can be installed in the MBR and the boot sector (boot sector) for each split slot
In fact, it can be understood that a disk does not know an MBR functional area, but the MBR is the first sector of the main boot record block , including the start-up program, but the other slots also have a different boot sector! This feature can create multi-boot function Ah!
Suppose the PC has only one hard disk, which is cut into four slots, where the first to second slot is installed Windows and Linux, how do you choose to boot with Windows or Linux? Assuming that the MBR is installed in the Windows/linux operating system can also know the boot management program, then the entire process can be the icon as follows:
The small blue squares in the diagram are the boot sectors of each partition (which may contain boot-up programs), and the orange cubes are the core files of each partition.
The MBR contains a boot-up program that can point directly to a partition's core file or to a partition's boot sector
As we can see, the MBR Boot management program provides two menu, select Single (M1) can directly load Windows core file to boot, menu two (M2) is to turn on the management of the boot to the second split slot boot sector (boot sector). When the user selects the menu two o'clock at boot time, that the whole boot management work will be given to the second slot of the boot management program. When the second boot Manager starts, the Boot manager (middle) has only one boot menu, so it can use the Linux core file to boot. This is the work of multi-boot! We will make a summary:
- ? Each split slot has its own boot sector (boot sector)
- ? The system slots in the figure are the first and second split slots,
- ? The actual boot of the core files are placed in each partition slot!
- ? Loader will only know their own system slots in the boot core files, as well as other loader only;
- ? Loader can direct or indirectly transfer management to another management process.
If you want to install multi-boot, it's a good idea to install Windows and install Linux first. This is because:
Linux in the installation, you can choose to install the Boot manager in the MBR or other partition slot boot sector, and Linux loader can manually set the menu (that is, M1, M2 ...), so you can be in the Linux boot loader (boot program) The option to add Windows to the boot
? When Windows installs, his installer will actively cover the MBR and the boot sector of his partition, you have no choice, and he does not ridiculed we choose the menu function.
Therefore, if you install Linux and then install Windows, then the MBR boot Manager will only have Windows projects, and will not have a Linux project (because the original Linux boot management program within the MBR will be overwritten). Does it need to reinstall Linux once? Of course not, you just to use all kinds of methods to deal with the contents of the MBR. For example, using the All-Chinese Spfdisk (http://spfdisk.sourceforge.net/) software to install obituary know Windows/linux management program, but also can use the Linux rescue to save the MBR.