Linux Learning (CENTOS-7)---disk partitioning (concept, partitioning method, partitioning scheme)

Source: Internet
Author: User
Tags create directory cpu usage

1 Concepts related to disk partitioning

1.1 What is a disk
The disk is the computer's external memory device, the round magnetic disc is installed in a square sealed box, the purpose is to prevent the disk surface scratches, resulting in data loss. Simply speaking, is a kind of computer information carrier, can also be rewritten repeatedly. Disks have floppy disk and hard disk points:
1.1.1 Floppy disk (floppy disk)
Floppy disks are the earliest removable media used in a personal computer (PC). Floppy disk reads and writes are done through a floppy disk drive. The floppy disk drive is designed to receive removable floppy disks, and is now commonly used as a 3.5-inch floppy disk with a capacity of 1.44MB. Floppy disk access speed is slow, the capacity is also small, but can be installed removable, easy to carry. As a removable Storage method, it is ideal for small files that need to be physically moved.
1.1.2 HDD
A hard disk is one of the main storage media of a computer, consisting of one or more discs made of aluminum or glass. The discs are covered with ferromagnetic materials. Hard drives are solid-state drives (SSD disks, new hard drives), mechanical hard drives (HDD legacy HDD), Hybrid drives (HHD a new hard drive based on traditional mechanical hard drives). SSDs are stored using flash particles, HDDs are stored with magnetic discs, and hybrid drives (Hhd:hybrid hard disk) are a hard disk that integrates magnetic hard disks and flash memory. Most hard drives are fixed hard disks that are permanently sealed and pinned to the hard drive. The disks in the partition we mentioned here refer to the hard disk.

1.2 The interface type of the hard disk
The hard disk interface is the connecting part between the hard disk and the host system, which transmits data between the hard disk cache and the host memory. Different hard disk interface determines the speed of connection between the hard disk and the computer, in the whole system, the quality of the hard disk interface directly affects the program running speed and system performance. From the overall point of view, the hard disk interface is divided into IDE, SATA, SCSI, Fibre Channel and SAS five kinds, IDE interface hard disk is used in household products, and some of the server, SCSI interface hard disk is mainly used in the server market, and Fibre Channel only on high-end servers, expensive. SATA is a new type of hard disk interface, also is in the market penetration stage, in the home market has a wide range of prospects.
The IDE's English is all called "Integrated drive Electronics", or "Electronic integrated Driver", which is intended to refer to the hard drive that integrates the "hard disk controller" with the "Disk body". The combination of the disk body and the controller reduces the number and length of the cable on the hard drive interface, the reliability of the data transfer is enhanced, and the hard drive is made easier because the hard drive manufacturer does not need to worry about whether its hard drive is compatible with the controllers produced by other manufacturers. For users, hard drives are also more convenient to install. IDE this interface technology from the birth has been in continuous development, performance has been improving, its low price, compatible with strong characteristics, for which other types of hard disk can not be replaced by the status. The IDE represents a type of hard disk, but in practical applications, people are also accustomed to using the IDE to address the earliest IDE type hard disk ATA-1, this type of interface with the development of interface technology has been eliminated, and then the development of branching out more types of hard disk interface, such as ATA, Ultra ATA, The DMA, Ultra DMA and other interfaces are all part of the IDE's hard drive.
The use of SATA (Serial ATA) port hard disk is called Serial drive, is the future and now the main trend of PC hard disk. In 2001, the Serial ATA Board, which consisted of Intel, APT, Dell, IBM, Seagate and Maxtor, formally established the Serial ATA 1.0 specification, while the related equipment for serial ATA was not officially listed in 2002, but serial The ATA Commission has been the first to establish the Serial ATA 2.0 specification. The Serial ATA uses a serial connection, the Serial ATA bus uses an embedded clock signal, has a stronger error correction capability, the biggest difference compared with the past is that the transmission instruction (not just the data) can be checked, if the error is automatically corrected, which greatly improves the reliability of data transmission.
SCSI's English is all called "Small computer system Interface" (Small computer system interface), is a completely different interface with the IDE (ATA), the IDE interface is the standard interface of the ordinary PC, and SCSI is not specifically designed for the hard disk interface, is a kind of high-speed data transmission technology widely used in small-sized machines. The SCSI interface has a wide range of applications, multitasking, high bandwidth, low CPU usage, and hot plug, and so on, but the high price makes it difficult to use as IDE hard disk, so the SCSI hard disk is mainly used in medium and high-end servers and high-end workstations.
1.2.4 Fibre Channel
The English spelling of the Fibre Channel is Fibre Channel, and the same as the SCSI interface Fibre Channel is not originally designed for hard disk design interface technology, is specifically designed for network systems, but with the demand for speed of the storage system, it is gradually applied to the hard disk system. Fibre Channel drives are developed to improve the speed and flexibility of a multi-drive storage system, which greatly improves the communication speed of multi-drive systems. The main features of Fibre Channel are hot-pluggable, high-speed bandwidth, remote connection, large number of connected devices and so on. Fibre Channel is designed for multi-drive system environment such as server, which can meet the requirements of high-end workstations, servers, mass storage sub-networks, peripheral devices through hubs, switches and point-to-point connections, and so on.
SAS (Serial attached SCSI) is a serial-attached SCSI, a next-generation SCSI technology that is the same as the current popular Serial ATA (SATA) hard drives, with serial technology for higher transmission speeds and improved internal space by shortening the wiring. SAS is a new interface developed after the parallel SCSI interface. This interface is designed to improve the performance, availability, and scalability of storage systems and to provide compatibility with SATA drives.

1.3 What is a disk partition
Disk partitioning uses the partition editor (partition editor) to divide several logical parts on disk, and once the platters are divided into several partitions (partition), different directories and files can be stored in separate partitions. The more partitions there are, the more different places, the more granular the nature of the files can be, and the more segmented nature of the files stored in different places to manage the file, but too many partitions become troublesome. Space management, access licensing, and directory search are based on the file system installed on the partition. When the ability to change size is dependent on the file system installed on the partition, the size of the partition needs to be carefully considered.
There can be up to 4 primary partitions in a hard disk of an MBR partition table type. If you need more than 4 disk blocks on a hard disk, you need to use an extended partition. If you use an extended partition, you can have up to 3 primary partitions and one extended partition on a physical hard disk. An extended partition cannot be used directly, it must be partitioned into a logical partition for the second time before it can be used. A logical partition in an extended partition can be any number. (The concept of MBR will be described in a later article)

1.4 Partition Type
After the hard disk partition, there are 3 forms of partition State, i.e. primary partition, extended partition and non-DOS partition.
1.4.1 Non-DOS partition
The non-DOS partition on the hard disk (Non-dos Partition) is a special partitioning form that divides a piece of the hard drive into a separate partition for use by another operating system, which is a partitioned storage space for the primary partition's operating system. Only operating systems that are not DOS partitioned can manage and use this storage area.
1.4.2 Primary partition
The primary partition is a relatively simple partition, usually located in the first area of the hard disk, constituting a logical C disk. The main bootstrapper is part of it, this program is mainly used to detect the hard disk partition correctness, and determine the active partition, is responsible for the transfer of the boot to the active partition DOS or other operating system. This program is corrupted and will not boot from the hard drive, but can read and write to the hard drive after booting from the floppy drive or optical drive.
1.4.3 Extended Partition
Extended partition strictly speaking it is not a meaningful partition, it is just a pointer to the next partition, this pointer structure will form a one-way list. So in the main boot sector in addition to the primary partition, only need to store a partition called extended partition data, through this extended partition of the data can find the next partition (in fact, the next logical disk) starting position, so that the starting position and so on to find all the partitions. Regardless of the number of logical disks established in the system, each logical disk can be found individually in the main boot sector through an extended partition parameter. The extended partition is not used directly, and is used in logical partitioning, so the extended partition can be divided into logical partitions. Their relationship is a contained relationship, and all logical partitions are part of the extended partition.

1.5 partition Format
After partitioning the disk, it must be formatted before it can be formally used, the format of the common disk format is: FAT (FAT16), FAT32, NTFS, ext2, ext3 and so on.
This is the most common format for disk partitioning in MS-DOS and the earliest Win95 operating system. It uses a 16-bit file allocation table, can support a maximum of 2GB hard disk, is currently the most widely used and the most supported by the operating system disk partition format, almost all operating systems support this format, from DOS, Win95, Win97 to Win98, Windows NT, Win2000, even the hottest l inux support this partitioning format. However, in the FAT16 partition format, it has one of the biggest drawbacks: inefficient disk utilization. Because in DOS and WI ndows systems, the allocation of disk files is in clusters, and a cluster is allocated to only one file, regardless of how much the file occupies the entire cluster capacity. In this way, even if a file is small, it will occupy a cluster, the remaining space is all idle there, creating a waste of disk space. Due to the capacity limitations of partitioned tables, the larger the partitions supported by FAT16, the greater the capacity of each cluster on the disk and the greater the waste. So in order to solve this problem, Microsoft introduced a new disk partition format FAT32 in WIN97.
This format uses a 32-bit file allocation table, which greatly enhances the ability to manage the disk, breaking the limit of only 2 GB for each partition's capacity in FAT16. Because the production cost of hard disk is decreasing, its capacity is getting bigger, after using FAT32 partition format, we can define a large hard disk as a partition without dividing into several partitions, which greatly facilitates the management of the disk. Moreover, FAT32 has one of the biggest advantages: in a partition not exceeding 8GB, each cluster capacity in the FAT32 partition format is fixed to 4KB, which can greatly reduce the waste of disk and improve disk utilization compared with FAT16. The operating systems that support this disk partition format are WIN97, Win98, and Win2000. However, this partitioning format also has its drawbacks, first of all the disks are partitioned in FAT32 format, and because of the expansion of the file allocation table, the speed is slower than the disk with the FAT16 format partition. In addition, because DOS does not support this partition format, the DOS system is no longer available after this partition format is used.
It has the advantage of excellent security and stability, and it is not easy to produce file fragments in use. It can record the operation of the user, through a very strict restrictions on user rights, so that each user can only follow the system-assigned permissions to operate, and fully protect the system and data security. There are many operating systems that support this partitioning format, from Windows NT and Windows 2000 to Windows Vista and Windows 7,windows 8.
1.5.4ext2, Ext3
EXT2,EXT3 is a disk format that is suitable for Linux operating systems, and the Linux EXT2/EXT3 file system uses index nodes to log file information that acts like a Windows file allocation table. An index node is a structure that contains information such as the length of a file, creation and modification times, permissions, affiliation, location on disk, and so on. A file system maintains an array of index nodes, each of which corresponds to the only element in an array of index nodes. The system assigns a number to each index node, which is the index number of the node in the array, called the index node number. The Linux file system saves both the file index node number and the filename in the directory. So, the directory is just a table that combines the name of the file with its index node number, and each pair of file names and index nodes in the directory is called a connection. For a file, there is a unique index node number corresponding to it, for an index node number, but can have more than one file name corresponding. Therefore, the same file on the disk can be accessed through a different path.
The file system used by Linux by default is really efficient and stable for the Ext2,ext2 file system. However, with the application of Linux system in the key business, the weakness of Linux file system is gradually revealed: the Ext2 file system which the system uses by default is a non-log file system. This application in key industries is a deadly weakness.
The Ext3 file system is developed directly from the Ext2 file system, and the Ext3 file system is very stable and reliable. It is fully compatible with the Ext2 file system. The user can smoothly transition to a log-capable file system. This is actually the original design of the ext3 log file system.

2 Disk Partitioning methods

2.1 Partitioning under Linux with the FDISK command
Reference URL:

2.2 Using graphical interface to partition the CentOS installation
Http:// Jkco2ccsb2aqelpmugomolo33khbqfnhhvhesdm1jvtjvzg4zmuo314xoxfrmyontrfsgnk7nexae4qalzhxzauquuscqeb28kj1hgj3fm

3 Disk partitioning scheme

3.1 The meaning of each partition of a hard disk partition
Although Linux can be installed in a single large partition based on the partitioning principle we have already mentioned, the better idea is to separate it. Combining the simplicity of a single partition with the flexibility of multiple partitions, we recommend the following configurations. Please note: If you want to install all Linux packages, you must use the larger partition size indicated here. In fact, you might increase the size we recommend so that you don't have to repartition the upgrade in the future.
1) An interchange (swap) partition. Swap partitions are used to support virtual memory. If your computer has less than 16MB of memory, you must create a swap partition. Even if you have more memory, it is still recommended to use the swap partition. The minimum size of the swap partition is the size of your memory, 16MB (whichever is larger). The swap partition can be up to 127 MB, so creating a larger swap partition is a waste of space. Note that more than one swap partition can be created and used (although this is usually installed on a large server).
2) a root (root) partition. The root partition is the "/" (root directory) location (note that it is not/root). It only needs to start the file and system configuration files required by the system. For most systems, the root partition of 50MB to 100M B can work well.
3) A/USR partition. /usr is where many of the software for a Linux system resides. Depending on the number of packages you swap, the partition should be between 300MB and 700MB. If possible, use the maximum space for the/USR partition. Any RPM-based package that you will install later will use more than/USR space than the other partitions.
4) A/home partition. This is where the user's home directory is located; Its size depends on how many users your Linux system has, and how much data these users will hold. If the system will be used as an e-mail service, for each user to set aside about 5MB of space, if you will provide personal home page storage space, should be at least for each user to reserve 20MB space. For Web site creators, there is also a point to note that your Web services and anonymous Ftp/home/ftp server content is also here!

In addition, your environment may require you to create one and more of the following partitions:
1) a/usr/local partition. The general/user/local is used to store software that differs from the rest of the Linux system, such as software that is not RPM packages. Its size depends on how many of these software you are going to store.
2) a/USR/SRC partition. In a Linux system,/USR/SRC usually stores two things: one is the Linux kernel source program. All of the kernel's source programs are placed here, and the new kernel is created here as well. Currently, the kernel source program is about 30MB. Remember, you may need more space to create the kernel, or to save several different versions of the kernel. The second is the RPM package source program. If the package source program is installed, the file will be stored here. Note that unless specifically specified, the Create package will also use a ' Create directory ' here. Again, the size of this partition depends on the number of software you will be installing here.
3) A/TMP partition. Just like its name, the/TMP partition is used to store temporary files. For a large, multi-user system or network server, it is a good idea to create a/TMP partition specifically. For a single-user workstation, you do not have to create a/TMP partition specifically.
4) A/var partition. Your Linux system will write the logs in/var/log. The print queue file is usually written in/var/spool. This is just a two example written in/var. Unless specifically configured,/var will be part of the root filesystem and usually does not occupy much space. If your system has a lot of print, mail, or log, you might consider creating a/var partition specifically. In general, only a multi-user or server requires a dedicated/var partition.
5) One/boot partition. Most of the partitions mentioned here are for large systems, which are useful for small systems with little space. All the files required for Lilo startup are in the/boot directory. So the best way is to separate the root file for a zone, the size of up to 64MB, preferably first divided into this area, and then sub-usr and so on.

3.2 Scene: The Linux system has a hard disk space of 500G
Requires the implementation of the following Linux partition:/var partition must be large (regardless of postfix mail, lamp Web server, etc.). Preferably above 400G. The specific/boot as long as 100M is enough.
Scenarios for 3.2.1Linux Server partitioning:

Partition type The actual size of the partition
/ 1G-2G (minimum 150–250MB)
/boot 32M-100M (boot partition, up to about 100M)
/opt 100M-1G (additional application)
/tmp 40M-1000M (Maximum can be set to about 1G, if you load ISO image file, it will be set to 4G or so, generally not so much)
/home 2G-10G (about 100M per user, specific customization. User directory.)
/usr 3G-10G At least 500M, the general loose server should be divided into 4-6G)
/usr/local 3G-15G (The self-installer is installed here)
/var >2G-All the remaining space of the hard disk (minimum 300M-500M, generally 2-3G, if you do the server, give it the rest of the space)

3.2.2Linux Desktop Partitioning scheme

Partition type The actual size of the partition
/ 1G
/boot 32M
/opt 100M
/tmp 50M
/home 1G-10G
/usr 3G-6G
/usr/local 3G-5G
/var 500M or more

3.2.3 The most economical partitioning scheme (server not recommended)

File directory Minimum General Post-installation size (CentOS5.2)
/ 150M-250M 500M-2G (378M)
/boot 32M-100M 64M (13M)
/opt 30M-100M 50M (19M)
/tmp 40-100M 50M (37M)
/home 100M-5G 1G (483M)
/usr >500M 4-6G 2.5G (2.0G)
/usr/local500M 2-5G 2G (1.2G)
/var 300-500M 2-3G 500M (296M) 

3.3 Other partitioning schemes
Reference URL:

Linux Learning (CENTOS-7)---disk partitioning (concept, partitioning method, partitioning scheme)

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: 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.