Linux directory structure, the size of the Linux partition, mount point and how partitions

First, on a hard disk type, geometry and physical hard disk capacity, partition size calculation;

1, a hard disk type, the physical geometry

The main types of hard disk is SCSI, IDE, and now the popular SATA and so on; any kind of hard drive production have a certain standard; with the corresponding standard upgrade, hard drive upgrade production technology are; such as SCSI SCSI standard has gone through -1, SCSI-2, SCSI-3; which we regularly present at the server sites to see Ultral-160 is based on the SCSI-3 standard; IDE follows the ATA standard, and popular SATA, ATA standard is an upgrade version; the IDE device is parallel, and a serial SATA, SATA development purposes is to replace the IDE; physical geometry of the disc is hard, the surface of the disk, cylinder, sector composition, an internal hard disk is several sheets superimposed discs together, thus forming a column decent; each has upper and lower surfaces of the disc; head and the disk surface contact so that data can be read;

2, the hard disk capacity and the size of the partition algorithm;

We can find the following information fdsik -l:

Disk /dev/hda: 80.0 GB, 80026361856 bytes  
255 heads, 63 sectors/track, 9729 cylinders  
Units = cylinders of 16065 * 512 = 8225280 bytes  
   Device Boot      Start         End      Blocks   Id  System  
/dev/hda1   *           1         765     6144831    7  HPFS/NTFS  
/dev/hda2             766        2805    16386300    c  W95 FAT32 (LBA)  
/dev/hda3            2806        9729    55617030    5  Extended  
/dev/hda5            2806        3825     8193118+  83  Linux  
/dev/hda6            3826        5100    10241406   83  Linux  
/dev/hda7            5101        5198      787153+  82  Linux swap / Solaris  
/dev/hda8            5199        6657    11719386   83  Linux  
/dev/hda9            6658        7751     8787523+  83  Linux  
/dev/hda10           7752        9729    15888253+  83  Linux  

Wherein the surface is a disk heads; sectors is a sector; Cylinders are cylindrical; 512Byte size of each sector, i.e. 0.5K; by way of example above, we found that the hard disk has a disk surface 255, there are 63 sectors, there are 9729 cylinders; hard disk so that the entire volume of the conversion formula would be:

The size of each magnetic sector number of the sector plane x x 512 x number of cylinders = number of hard disk volume (in bytes)

Therefore, the size of the present embodiment, the disk should be calculated as follows: 255 x 63 x 512 x 9729 = 80023749120 bytes Note: Due to the hard disk manufacturers and the operating system in terms of not the same, a hard disk manufacturers to approach 10 carry be converted, while the operating system is 2 to be converted binary system, so in terms of M or G, the results are not as different algorithms; we sometimes hard 80G is marked, but the operating system to see at least a few M; the above example, a hard disk manufacturers arithmetic comparison algorithms and operating systems: hard manufacturers: 80023749120 bytes = 80023749.120 K = 80023.749120 M (in terms of the large units, each divided by 1000)

Operating System: 80023749120 bytes = 78148192.5 K = 76316.594238281 M (converted to large units, each divided by 1024) we view the partition size when the manufacturer can use algorithms to provide a simple projection of the size of the partition; move the decimal point forward represented by G is the size of six; for example a size of about hda1 6.144831G;

Second, the standard hard disk partitioning and partition structure on reasonable;

1, standard hard disk partitioning

Hard disk partition from the primary partitions, extended partitions and logical partitions; when we partition the hard drive to follow this standard; the maximum primary partition (including extended partition) the number is four, the primary partition (including the extended partition) th master boot record number of the hard disk MBR (master boot Recorder) decision, MBR boot manager store (GRUB, LILO, NTLOARDER etc.) and partition table records. Wherein the extended partition can be considered a primary partition; the extended partition may contain more logical partitions; so the primary partition (including extended partition) ranges from 1-4, logical partitions start from 5; as in the following example:

Device Boot      Start         End      Blocks   Id  System  
/dev/hda1   *           1         765     6144831    7  HPFS/NTFS  
/dev/hda2             766        2805    16386300    c  W95 FAT32 (LBA)  
/dev/hda3            2806        9729    55617030    5  Extended  
/dev/hda5            2806        3825     8193118+  83  Linux  
/dev/hda6            3826        5100    10241406   83  Linux  
/dev/hda7            5101        5198      787153+  82  Linux swap / Solaris  
/dev/hda8            5199        6657    11719386   83  Linux  
/dev/hda9            6658        7751     8787523+  83  Linux  
/dev/hda10           7752        9729    15888253+  83  Linux  

By this example, we can see that there are three primary partitions, from hda1-hda3, extended partition from the hda5-hda10; 4 no primary partition the hard disk, so it does not display the main partition hda4; but logical partition can not start from 4, because that is the location of the primary partition, get the point;

2, the hard disk device (including removable storage devices) shows Linux or other Unix-like systems

IDE hard drives generally expressed Linux or other Unix systems as hd *, such as hda, hdb ... ..., we can fdisk -l to see; sometimes you may have only one hard drive, see the operating system is hdb, this is related to jumpers hard drive; another hdc most CD-ROM device is represented; if you have two hard drives, most of hda and hdb. In this respect also say too much useless, or to prevail for the good fdisk -l; SCSI and SATA drives in Linux usually expressed as sd *, such as sda, sdb ... ... to fdisk -l subject to removable storage devices in linux expressed as sd *, such as sda, sdb ... ... subject to fdisk -l

3, reasonable zoning

Partition on a disk, a disk should have four primary partitions, wherein the extension can be considered a primary partition; the following conditions:
1) one partition structure: four primary partitions, no extended partition;

[Primary | partition 1] [primary partitions | zone 2] [primary | partition 3] [primary | partition 4]

This situation, if you want to division of five or more partitions on a disk, this does not work;

Three primary partitions an extended partition;

[Primary | partition 1] [primary | partition 2] [primary | partition 3] [extended partition]

|

[Logic | partition 5] [Logic | partition 6] [Logic | partition 7] [Logic | partition 8] ... ...

This situation works, but relatively large degree of freedom of partition; also unconstrained partition, the partition can be over 5 minutes; this is just one example;
2) the most reasonable way of partition;

The most reasonable partition structure: first primary partition, the extended partition, and then dividing the logical partitions in the extended partition; primary partition number of partition number + extension to be controlled within the four; following such partition is better of;

[Primary | partition 1] [primary | partition 2] [primary | partition 3] [extended partition]

|

[Logic | partition 5] [Logic | partition 6] [Logic | partition 7] [Logic | partition 8] ... ...

[Primary | partition 1] [primary | partition 2] [extended partition]

|

[Logic | partition 5] [Logic | partition 6] [Logic | partition 7] [Logic | partition 8] ... ...

[Primary | partition 1] [extended partition]

|

[Logic | partition 5] [Logic | partition 6] [Logic | partition 7] [Logic | partition 8] ... ...

The most reasonable partition structure: primary partition surrounding the extended partition; as in the following;

[Primary | partition 1] [primary | partition 2] [extended partition] [primary | partition 4] [blank unpartitioned space]

|

[Logic | partition 5] [Logic | partition 6] [Logic | partition 7] [Logic | partition 8] ... ...

This [primary | partition 2] and [primary | partition 4] [extended partition] is between freedom, but the [primary | partition 4] after the [blank unpartitioned space] how do unless the primary partition 4 completely? use of space after an extended partition, or you want to draw in the primary partition 4 and then a partition is impossible, let alone division of logical partitions; although such an approach is also similar to a standard disk four primary partitions, but this main extended partition partition partition method surrounded it undesirable; we have the basis of this title, look at our example, is not in line with this standard?

Device Boot      Start         End      Blocks   Id  System  
/dev/hda1   *           1         765     6144831    7  HPFS/NTFS  
/dev/hda2             766        2805    16386300    c  W95 FAT32 (LBA)  
/dev/hda3            2806        9729    55617030    5  Extended  
/dev/hda5            2806        3825     8193118+  83  Linux  
/dev/hda6            3826        5100    10241406   83  Linux  
/dev/hda7            5101        5198      787153+  82  Linux swap / Solaris  
/dev/hda8            5199        6657    11719386   83  Linux  
/dev/hda9            6658        7751     8787523+  83  Linux  
/dev/hda10           7752        9729    15888253+  83  Linux  

Next comes Linux partition mount point of common sense and common desktop, server recommended configuration partition mount point, of course, this configuration is Tianyuan own writing, the partition size of this topic eyes of the beholder wise see wisdom, we welcome the exchange of this topic together, such as WEB service, mail services, download services, we exchange together under the type of service which should increase a mount point on it, as to whether to see an independent individual.

Three, Linux Partitions Mount Point presentation

Linux partition mount point presentation, recommended capacity is for reference is not absolute, with the use of each system and hard disk space quotas and other factors, the actual adjustment:

Partition type Introduction Remark
/boot Boot partition General Settings 100M-200M, boot directory contains the operating system kernel and boot the system in the course of the use to the file.
/ With partition All mount points are not specified directory will be placed under this mount point
/home User directory Each user typically about 100M, for special purposes, such documents can also be amplified plus G. The partition size depends on the number of users. For multi-user computer use, it is recommended to / home independent, but also good control of normal user permissions, such as the implementation of disk quotas for users or groups of users, user access, etc.
/tmp Temporary Files 1-5g generally set, used to facilitate loading ISO file, multi-user system or a network server is also necessary to mount separate. Temporary files directory, one directory is the most common problem
/usr File system General Settings To 3-15G, most of the software programs installed by the user are all here. Like the Windows directory and Program Files directory. Many Linux systems family and sometimes the / usr / local use alone as a mount point
/where Variable data directory It contains data to change the system is running. Typically the size of the directory where the data is to be constantly changing, system logging are / var / log lower. General multi-user system or network server to create the partition, the partition set up, maintain very helpful to the system log. 2-3G generally set size, the remaining hard disk space can be divided into full var
/srv System Services directory Directory service used to store documents required to start the service, do not often change
/opt Additional applications Store the optional installation files, the individual generally exist inside their own software to download data, such as Office, QQ, etc.
swap Swap partition Memory is generally 2 times the maximum specified to 2G
Other commonly used to partition the mount point
/bin Binary executable directory Put binary executable program, which the program can be called directly from the command line without the need to enter the program files folder where the
/sbin The system administrator command store directory Standard file system storage administrator
/dev File storage device Driver files

Of course, so much above the mount point, in fact, there is no comparing each directory is a separate mount, we need to need to be mounted on individual directories according to their actual use, so that the system will streamline the structure looks a lot.

Generally Linux system least two mount point is a root mount point /, and the other is swap, swap may be used, although other similar alternative manner, but using the angle, day margin that will not be necessary, the set a separate swap mount point seems to be better support for the standard of the Linux system.

Four, Linux desktop, server partitioning recommendations

Below independent 80G hard disk to install Ubuntu, for example, listed some simple partition scheme.

1, normal desktop user recommendations partitioning scheme (Example: 80G desktop users):
Here Insert Picture Description
2, the server user recommendation partitioning scheme a (Example: 80GWEB server users, user program and the system program combined usr):
Here Insert Picture Description
. 3, the server user recommendation partitioning Scheme II (Example : 80GWEB server users, user program and the system programs and demultiplexing opt usr):
Here Insert Picture Description
partitioning scheme key:

- Large database generally increase the / usr mount point

- Multi-user, download categories, multiple storage files, etc. to increase the / home mount point

- small files, multi-user should pay attention to / tmp and / var mount point size

Published 12 original articles · won praise 30 · views 1036

Guess you like

Origin blog.csdn.net/da13122318861/article/details/103873060