Linux system partitioning and mounting

Source: Internet
Author: User

Linux system partition and Mount Linux system partition

There is a big difference between Linux partitions and Windows. In Linux, there is no graphical partitioning interface, so we cannot see the disk partitioning interface for C-drives and D-disks in Windows.

1. Hard Disk partitioning

    • purpose of hard disk partitioning : improve management efficiency. If everything is placed in one partition, the OS is less efficient to manage. At the same time, the operating system starts with the MBR to obtain the partition where the operating system files reside, so a bootable partition is not missing.
    • partitions are not related to the operating system . The partition has started before the operating system is installed. We can simply think of partitioning as dividing the hard disk into different areas.
    • Introduction to the partition structure .
      HDD Master Boot sector = hard disk Master boot record (MBR) + hard disk partition table (DPT), total 512 bytes, where MBR is 446 bytes, partition table is 64 bytes, and then there are 2 byte end flags. The boot sector is stored on the hard drive's 0-head 0-Channel 1 sector, which is the boot Sector.

      The operating system at boot time through the BIOS (BIOS is actually a basic input and output system) program to read the boot sector into memory, and then execute the MBR, this time the BIOS will boot to the MBR control. The role of the MBR is to search for the partition marked active in the 4 partition table, find the first sector of the active partition to read into memory, and then start executing it, running a system-specific boot program (Lilo,grub,nt Loader). At this point the start task is given to the operating system boot program to control. Then the operating system carries out a series of initialization, finally the system to the system core management.

2. Partition type

There are 3 types of hard disk partitions: Primary partition, extended partition, and logical partition.

    • The operating system can be installed on the primary partition . Because the primary partition information is recorded in the MBR, and the system boots to the primary partition to find the operating system boot file, the boot file of the operating system must be in the primary partition or the system will not start.
    • supports a maximum of 4 primary partitions . Since the hard disk retains only 64 bytes of storage for the partition table, and the parameters for each partition occupy 16 bytes, the total in the main boot sector can store 4 primary partition data. The operating system only allows the storage of data for 4 primary partitions.
    • The system introduces the concept of extended partitioning in order to establish more logical disks for use by the operating system . The extended partition is not a real partition, it is just a pointer in the memory management list, indicating which area is the extended partition. an extended partition is also a primary partition . Extend the system partition by dividing the logical partition in the extended partition. Virtually all logical partitions are within a partition, but logically separate. But everything is transparent to the user, and we seem to have a lot of partitions in the system.
    • Partition Properties :
      • Primary and extended partitions can have up to four (limit on hard disks). The
      • extended partition has a maximum of one (operating system limit). The
      • extended partition could not be formatted.
      • in a Linux system, the primary partition number and extension area code 1-4, the logical partition number must start from 5.

3. Linux partition
compared to the Windows partition, the biggest difference between Linux is that we don't see the so-called drive letter. , use/dev/hda,hdb under Linux. This identifies the hard disk, and the partitions on the hard disk are represented by/DEV/HDA1,/dev/hda2. The last number represents the partition number, the primary partition is 1-4, and the logical partition is the number after 5. The
Liunx uses a tree-based file management system, that is, in a Linux system, there is no concept of partitioning. Partitions are just one file in Linux, as with other devices. To use a partition, you must load it into the file system .

4. Linux Mount
so-called Mount , is to use a directory as an entry point, the partition of the disk data into the directory, access to the directory can read the partition.
The file structure of the tree in Linux, the top level is/directory. When installing the system, you must choose to mount a primary partition in the/directory, as the system needs to be installed under/mounted on the primary partition.
Linux the entire system structure, we installed the system when the partition 1 mounted to the/directory. And this time does not mount any other partitions, so/directory of all other directories under this partition, that is, I read and write in any directory is actually the operation of this partition 1th.
If we want to use other partitions, we have to mount the partition to a directory, which can be a directory that already exists, such as/home, or it can be a directory of our own, such as/oracle.

Of course, some directories such as/lib,/dev,/etc,/usr cannot mount other partitions because they all have files that the system needs, and once the other partitions are mounted, the OS cannot find the required files and the system crashes. For example, when we mount the partition 2 to the/USR/X11 directory, the system cannot find the file on partition 1 through the X11 directory, and the system GUI cannot be used. Although the file is still on the hard drive. As I said before, directories – partitions are linked by mounting them. If you change the partition, you'll break the connection and you won't be able to find the previous file. We are looking at partition 5 and partition 6, we attach it to the/home/ftp and/oracle directory, this time we are operating these 2 directories, is the operation of the corresponding partition.

    • In the Linux system, we can use the df -h command to see the current partition of the system.
    • fdisk -lthe command allows you to see information about all the partitions in the current system.
    • Common commands for mounting and unloading partitions and file systems are mount和umount , for example mount /orace /dev/hda5 , to mount the 5th partition to the/oracle directory. The specific command format is not introduced, many online, you can also use the man to view.
    • By editing /etc/fstab the file to allow the system to automatically load the boot, the details are not detailed here.

5. About swap partitions and/boot partitions
In the process of installing the system, it is recommended to create a separate partition for/,/boot, swap, respectively.

    • Swap: Can be understood as virtual memory. In general, if the real memory is less than 4GB, the space allocated to swap is twice times the real memory. If more than 4GB, allocate space of equal size.
    • /: System root directory. Generally under the primary partition, of course, it can be divided into the logical partition of the extended partition.
    • /boot: Mount it to a separate partition, typically 200MB. Mainly used for system startup. Avoid the root directory where the partition is stuffed and the system cannot start.

Linux system partitioning and mounting

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.