Disk Partitioning in Windows 7 and Ubuntu 12.04

Source: Internet
Author: User

I haven't fully figured out the problem of disk partitioning since I studied Linux intermittently. Although I still don't know it, I should have a bit of thought and noted it down.

I installed a dual-system. First, we can see the disk partitions in win 7:


Originally, only the partition is restored, the partition is retained, and the cdfg disk. The primary partitions in the middle are all about dividing the unconfigured space during Ubuntu installation, the strange thing is that it should not be displayed as the primary partition. Anyone who has some knowledge about this should know it. Copy a section below:
The first sector of the hard disk is 512 bytes, which is mainly divided into two parts (in fact, four parts, the other two can be ignored first). One is to store the boot loader (Master Boot recorder, MBR) space, which is about 446 bytes. The other is the storage space of the hard disk partition table (DPT), which is about 64 bytes. This sector must be read after the computer is started. This is required to start the computer.
 
MBR is a headache. The key is that it has different meanings when used. I have summarized the following meanings:
1. It refers to the main boot program, such as grub and Lilo commonly used in Linux, as well as Win's main boot program.
2. Hard Disk Space of 446 bytes in the first sector of the hard disk.
3. It refers to the first sector of the hard disk, that is, all 512 bytes of hard disk space mentioned above, including 446 bytes of space for storing the Main Boot Program and 64 bytes space for storing the partition table.
 
Disk Partitions follow the principles of P + P or P + E.
 
In short, the above rules must be observed for hard disk partitioning. This is common and must be observed for both Windows and Linux. Summary:
There are three types of Hard Disk Partitions: Primary partition, extended partition, and logical partition.
The partition records of the primary and extended partitions are stored in the first sector of the hard disk. The space in this area is limited and a maximum of four partition records can be kept. Therefore, the sum of the number of primary and extended partitions on our hard disk cannot exceed 4.
Extended partitions cannot be used directly. They can only be used after they are divided into logical partitions.
Logical partitions are part of the extended partitions. The partition records of all logical partitions are stored in the header of the extended partition, rather than in the first sector of the hard disk.
It should be clarified that each partition has a super block, and each MBr has only one disk. MBR is used to load the boot program, not the operating system. When you start the system, the built-in BIOS Detection Program (fixed) will perform self-check upon startup and load the boot guide program in the MBR (Master MBR. (This is not difficult to understand why MBR is always on the No. 0 track. If MBR is always changing its position, wouldn't I want to modify the BIOS program ), the boot program in MBR will load some core files of the operating system into the memory and create corresponding processes after you select the operating system, perform a series of initialization .....
 
As mentioned above, during partitioning, each partition is a file system, and the block at the beginning of each file system becomes a superblock ). super blocks are used to store the file system size, empty and filled blocks, their respective totals, and other such information. (The block size is the N power of the slice size * 2. A slice is generally B)
For example, the hard disk MBR code is (hd0), and the super block code (also the partition Code) of the first partition of the hard disk is (hd0, 0 ), the super block of the first logical partition of the hard disk is (hd0, 4), which can be viewed based on the following information.
IDE, SATA, and even USB flash drives may all be recognized by GRUB as HD devices (HD and SD devices are differentiated in Linux). Note that the Partition Number of grub 2 starts from 1, however, the disk number still starts from 0 .. In grub2, (hd0, 0) indicates (hd0, 1) or (hd0, msdos1.
 
We know that a hard disk can have many partitions, but there are only four MBR partition tables. How can we break this limit? The answer is the extended Boot Record (EBR-extended Boot Record). By setting an item in the MBR partition table as an extended partition (the System ID is 0x05 or 0x0f ), the partition table item specifies the start position and length of the extended partition. Another Partition Table is placed in the first sector of the extended partition, which is generally called an extended partition table. The first item of the extended partition table specifies the current information of the extended partition. If there are more logical partitions, the second item of the extended partition table specifies the location of the next EBR; otherwise, it is 0. In this way, there is no limit on the number of partitions on a hard disk.
 
Now let's take a look at Ubuntu:


The system does not identify the restoration partition and mounts the Windows 7 disk as follows:


We can see that the reserved partition is/dev/sda2 in Linux, and the 30 GB is the c disk, and the ID is/dev/sda3. dfg is a logical partition, disk D is/dev/sda5. what about/dev/sda1? See:


That's right./dev/sda1 is about restoring the partition./dev/sda5 ~ /Dev/sda7 is a dfg disk, and the undisplayed/dev/sda8 is also available, that is, the virtual memory area swap. From/dev/sda8 ~ /Dev/sda13 is all my partitions for Ubuntu. The point is, what is/dev/sda4? It is actually an extended partition !! From/dev/sda5 ~ /Dev/sda13 are all logical partitions divided from/dev/sda4 !!, There is evidence that the end of/dev/sda4 can be viewed.
The value is the same as the value of/dev/sda13 end! Both are 976771071, and start and/dev/sda5 are almost the same. Check the meaning of the system column in/dev/sda4, as follows:
It simply states that your 4th partition is an extended partition instead of a primary partition. the partition info in stored in MBR. however, the MBR can only store four partition entries. if you want more than four partitions, you will have to create
Extended parition and with in which you can create more. In your case partition 5, 6, 7, 8 ....

Next let's look at the grub 2 boot guide:
Because I installed Windows 7 first and then Ubuntu, it is certain that grub 2 is installed in MBR, while the configuration file of grub 2 is in/boot/GRUB/grub. cfg.


Cat to view the file and find the important ones:


The first thing to note is that grub 2 (which can be installed in MBR or super block) boot loader can do the following:
1. directly specify and access the core file and load it to the primary storage.
2. hand over control to the next Loader
 
We can see that this is the second function. The first menu is the Boot Load restored by win 7. This boot program is installed in the super block of the first partition (Restore partition)/dev/sda1 (hd0, 0), that is, (hd0, msdos1). chainloader + 1 indicates the first sector. If you click this item in the menu when the system starts, the system will be directed to recovery.
The second menu is Boot Loading started by win 7 (you can see that the figure above has a * number indicating bootloader). This pilot program is installed in the second partition (Reserved partition) /dev/sda2 super block (hd0, 1), that is (hd0, msdos2). If you click this item in the System Startup menu, the system starts up, go to/dev/sda3 (drive C) to find the system kernel file and load it To the memory for startup.
Note: Windows will write the boot into MBR and super block by default (here is the super block of sda2), while Linux can choose to install it somewhere, windows will be overwritten because the MBR is installed, but the Windows boot program of sda2 super block can also be seen. If you install Linux and then install Windows, it will be completely overwritten.

The first function is as follows:


We know that the boot kernel is under/boot, Because I separate/boot from the partition, so the complete path is
(Hd0, msdos10)/vmlinuz -...
Or (/dev/sda10)/vmlinuz -...
If not, set root = '(hd0, msdos9)' # As above, the root directory/is/dev/sda9
The complete path is
(Hd0, msdos9)/boot/vmlinuz -...
Or (/dev/sda9)/boot/vmlinuz -...


Note:

Bytes -----------------------------------------------------------------------------------------
Possible System ID values:
0x01 fat12 primary partition or logical partition.
0x04 fat16 primary partition or logical partition.
0x05 extended partitions.
0x06 bigdos fat16 primary partition or logical partition.
0x07 NTFS primary partition or logical partition.
0x0b FAT32 primary partition or logical partition.
0x0c uses the FAT32 primary partition or logical partition of extended interrupt 13.
0x0e uses the bigdos fat16 primary partition or logical partition with extended interrupt 13.
0x0f uses extended partitions with extended interrupt 13.
0x12 EISA partition.
0x42 dynamic disk volumes.
0x86 legacy ft (fault tolerant) fat16.
0x87 legacy ft NTFS.
The FT FAT32 legacy from 0x8b.
The legacy ft of 0x8c uses the FAT32 of extended interrupt 13.

27 windows re hidden partition
On MBR disks, Type 0x27. on GPT disks, guid: DE94BBA4-06D1-4D40-A16A-BFD50179D6AC. A hidden version of a Windows re Type 0x7 partition with NTFS. when this is installed, reboot and press F8 In order to boot into this recovery environment.

07 HPFs/NTFS/exfat
07 OS/2 ifs (e.g. HPFs)
Ifs = installable file system. the best known example is HPFs. OS/2 will only look at partitions with ID 7 for any installed ifs (that's why the ext2.ifs packet includes des a special "LINUX partition filter" device driver to fool OS/2 into thinking linux partitions
Have ID 07). (Kai henningsen (kai@khms.westfalen.de ))


07 Windows NT NTFS
Filesystem introduced in Windows NT 3.1. It is rumored that the Windows NT boot partition must be primary, and within the first 2 GB of the disk.


07 exfat
Extended fat, a.k. A. fat64. available in Microsoft Windows since 6.0 and Vista SP1. allows 32 MB clusters and very large disks and files.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.