The reason why the thought of writing this, because I am in the process of tossing Linux system, there are multiple hard drive partitions fall into the trap of experience. In recent days, once again fall into the pit, toss a couple of days to climb out of the pit. After many inquiries information, and finally figured out some of the concepts of hard disk partitions. It will be recorded as a warning to newcomers.
Speaking of my own experiences out of the pit, all with a fierce collision WinXP and Linux related. Years ago, I started on a computer to install Linux and WinXP the same time, as long as the first installation to comply with the order WinXP install Linux, you will not go wrong, Linux installation program will automatically recognize multi-system installation is complete smooth start multi-system. One day, I think that alone is enough to use Linux, so he grid of the entire hard disk installed Linux. Another day, I think it is to use WinXP, then re-install WinXP (not to mention the virtual machine to me, years ago, my computer has only 256M of memory, the virtual machine simply can not run), and found that, WinXP installer did not a way to partition the hard drive. The pit is caused by the Linux LVM, WinXP not identify LVM partition, WinPE that era, DOS all the tools in the toolbox no way to identify LVM, but then again my understanding of Linux will only stay in the installing the system partitions, you do not know Linux systems as well as fdisk, parted such tools, so toss a long time to climb out of the pit inside. Now years later, I once again fell into the pit. I use a computer at work is WinXP system (heavenly situation, you know), in order to do some private live, I installed a Ubuntu up, two systems has been peaceful. Until one day, I put the Ubuntu system and toss hung up, then reinstall because the district are not careful when you choose the default "Clear the entire disk and install Ubuntu", then the hard drive was lost throughout the grid, WinXP, there is no . I was like, this big little thing, and then I put on a WinXP is not finished yet. But the question is, no matter how I installed, WinXP system is not activated. Only later did understand the whole, this is a hard drive with pit caused GPT partition. Why I let Ubuntu automatically partition it into a GPT partition it? It is also strange that Hewlett-Packard is working with the machine relatively wonderful it is to support legacy BIOS, also supports EFI, when the original WinXP present it with, of course, MBR partition (msdos partition), so when you install Ubuntu is to use the MBR partition , and later when Ubuntu automatically partition it sees motherboard supports EFI, automatically put the entire hard disk to GPT partition. I also toss a few days to understand this, and finally with the help of the Ubuntu LiveCD parted program, use a mklabel msdos command to change the hard disk partition from GPT to MBR partition, and then press the order of installation WinXP and Ubuntu, is considered from inside the pit to climb out.
For long-term friends who manage a large room and large storage capacity of the server, the hard disk partition, they certainly would have done the homework. I do not like this, the problem will not go until he came to learn the relevant knowledge. For this knowledge the hard disk partition, I summarized as follows (only a brief summary, details please on their own search elements):
1, the conventional BIOS to boot from the hard disk only support MBR partition. MBR partition partition table stored in the first sector of the hard drive, and only 64 bytes, so a maximum of only four entries. That is, we can only put the hard disk is divided into four primary partitions, or less divided into three primary partitions plus an extended partition. Extended partition can be divided into multiple logical partitions. Advantages MBR partition is simple, we all use, so we know everything Well, many operating systems can boot from the hard disk MBR partition. The disadvantage is the MBR partition can not recognize more than 2T hard disk space, can not have partitions larger than 2T;
2, GPT partitioned hard drive can solve all the above shortcomings MBR partition, it does not limit the four primary partitions, wanted in several primary partitions can be divided into several primary partitions, it can identify more than 2T hard disk space for each partition the size can also be more than 2T. But its disadvantage is the need for operating system support. For example, only WinXP 64 Wei, Win Vista, Win 7 and Win 8 and the relatively new Linux release supports GPT partition the hard disk. Moreover, without the support of EFI's words, the above system can only be GPT partition the drive as a data disk, can not boot from hard disk GPT partition;
3, the hard disk boot from a GPT partition, the motherboard uses EFI, GPT hard disk partition, the operating system supports GPT and EFI three conditions are indispensable. The relatively new 64-bit Linux systems and Win8 systems are supported by EFI, so all you need to start from a GPT partition the hard disk. Now the computer motherboard has been gradually abandoned the legacy BIOS, and the only support EFI. (Like my work machine such transitional product will be less and less.) At present, many pre-installed Win8 notebook motherboard is almost the only support EFI. Therefore, the study of knowledge and EFI GPT imperative;
4, the above partitioning strategy is fixed partitions. Once the hard disk partition, the partition size can not be changed, if you want to change the size of the partition, then only re-zoning. And because there is no way to multiple hard disks assigned to a zone, so no matter how minute, the size of each partition are limited. So what we need is a dynamic partition. LVM is such a stuff, it is called the Logical Volume Manager. Mechanism uses LVM is this: First, the hard disk partition or the entire hard drive is marked as a physical volume (PV), and then create a volume group (VG), the one or more physical volumes added to the volume group, the final volume group partition, each partition is called a logical volume (LV). Advantage of LVM is that you can always add the size of the physical volume expansion volume group to the volume group to be dynamically resized logical volume. This is particularly useful in a server, for example, has had a 100-user server, there will be 100 user's home directory under its / home directory, if each of them assigned to 20G of space, it would fill a 2T hard drive, if then again 100 users how to do? If you are using LVM can successfully solve this problem, we can add a 3T hard drive, then the hard disk volume group can be added to expand the size of the volume group, and then adjust the logical volume / home where the size of the can. LVM can be used with both MBR, or you can use with GPT.
The following Ubuntu 14.04 installation process by automatically partitioning strategies to verify the above knowledge. First, only supports legacy BIOS of the computer, when you install Ubuntu partition options are as follows
In this case, do not select the option to start the LVM. After installing the operating system, use parted program to view the hard disk partition, by looking at the / etc / fstab file to find out which partition corresponds to which file system
parted program output print command can be seen, the hard disk partition table type msdos, is the MBR partition. Hard disk is divided into a primary partition and an extended partition sda1 sda2, primary partitions sda1 accounted 20.4G, extended partitions sda2 only 1072M, an extended partition is only a logical partition sda5. Via / etc / fstab can be seen that the primary partition sda1 mounted as the root directory for the logical partition sda5 swap space.
The above partitioning scheme is the simplest and most commonly used. Let's look at what the effect is to enable LVM. The choice of interface options open partition scheme LVM options
After installing the operating system, or through the parted program and / etc / fstab to view the hard disk partition and use
Partition table type or msdos. Hard disk or just scored a primary partition and an extended partition sda1 sda2, but only the main partition sda1 255M, extended partition sda2 does have 21.2G, also only extended partition into a logical partition sda5, sda5 logical partition occupies the entire extended partition 21.2G space, and sda5 logo is lvm, indicating that the partition is marked as a physical volume (PV), it must have been added to a volume group (VG) in. Via / etc / fstab file can be seen, the primary partition sda1 mount / boot, swap and root and mount the two logical volumes (LV).
By LVM command to view the system volume groups, physical and logical volumes of information
And pvdisplay by pvs command, you can see that the system has only one physical volume, that is, / dev / sda5, the physical volume is added to the volume group ubuntu-vg being. By vgs and vgdisplay commands. You can see only one volume group that ubuntu-vg, the volume group is divided into two logical volumes.
And lvdisplay by lvs command to see the volume group is divided into two logical volumes, which are mounted to the root and swap space.
By LVM commands can also be more operations, such as creating a new volume group, will join the new physical volumes to the volume group, logical volume to increase or decrease the size, and so on. What specific command, you can get a help.
Finally, take a look at the motherboard only supports EFI case, Ubuntu how to partition. Start interface installed as follows
The installation interface installation interface and legacy BIOS system under different traditional installation interface as follows
In EFI mode or select automatic partitioning. After installing the operating system, use parted and / etc / fstab to view the hard disk partition and use
Through the above picture we can see the hard disk partition table type gpt, the hard disk is divided into three zones, are the primary partition. Wherein the size of the first partition sda1 is 537M, the file system is fat32, whose mount path is / boot / efi, while the other two partitions to mount a root directory, one for the swap space. From the above information we can infer: motherboard only supports the EFI GPT partition boot only from the hard disk, and the hard disk first partition must be fat32 file system, the file system is stored in various files EFI needed.
If the installation of Ubuntu system to automatically partition is not an option, but the final choice "other options" to customize the partition, will find that the custom partitioning Ubuntu provides very limited. It is no way people choose to use MBR partition or use a GPT partition, there is no way to choose whether to enable LVM. If you need a more flexible management of the case, or only click on the "Try Ubuntu" button, enter the LiveCD Ubuntu system, use the parted command and lvm command to manually manage disk partitions.
In addition to the hard disk partition, there may be usually used in hard disk management functions are the following:
1. Create RAID, you can use mdadm program;
2, view the partition or space each folder takes up, use the df and du procedures;
3 Specify the disk quota using the quota package;
4. Check each partition file system, UUID, label, use blkid program.