Advanced Tutorial: Recommended hard disk partitioning for Linux

Source: Internet
Author: User

If you have no time to read this article, beginners can use root partitions and swap partitions. Or you can divide the hard disk by my partition. I often set up file systems in the order of M/boot, 1g swap, M/var/tmp, 3g/usr, and leave the rest of the space to/home.

Typically, you should set the swap area size to 2 times the memory size. If you do not have a lot of memory, you will need more swap space. We do not recommend that you set the swap partition to less than 256 M. When you determine the swap partition size, consider the possibility of memory expansion in the future.The kernel's VM (Virtual Memory) page feed algorithm is quasi-optimized for swap areas that are at least twice the memory size.A too small swap zone will lead to low efficiency of VM page scanning. When the memory is expanded, it will also cause problems. Finally, on a large system with multiple SCSI hard disks (or multiple IDE disks work on multiple IDE controllers ),We strongly recommend that you configure swap partitions on each driveThe size of each swap partition should be almost the same. The inner nuclear energy processes swap areas of any size, but the internal data structure is enlarged to 4 times the maximum partition size. Keeping swap partitions of the same size allows the kernel to optimize the distribution of swap space across N disks. Don't worry that this is a little too much. The swap zone is a UNIX savior, even though you usually don't need so many swap zones, before being forced to restart, it can also give you time to recover the system from an derailed program.

How to set the size of your/var partition depends on how you use this machine. This partition stores the mailbox, and prints the buffer zone and log files. Some people even regard/var/log as an independent partition (however, unless otherwise, this is not worthwhile, it will only waste a partition ID ). If your machine is mainly used as an email or print server, or a WEB server that runs a large volume of traffic, you should consider creating a larger partition, maybe 1 GB or more. It is easy to underestimate the storage needs of log files.

Determine the size of/var/tmp depends on how you will use your temporary file. M is the recommended minimum size. Note that sysinstall will create a/tmp directory, but it is important to use/tmp as a connection to/var/tmp. There are two important reasons for creating a partition for a temporary file: First, it reduces the possibility of file system corruption after a system crash, the other is to reduce the chances of affecting other important subsystems (mail, logging, and so on) When an derailed program is filled with/var/tmp. Filling/var/tmp is a common problem.

In the past,/tmp and/var/tmp were different, but the introduction of/var (and/var/tmp) was a big confusion caused by programmers, today's programs sometimes use one or another, and there is no difference between them. So it makes sense to turn them into a temporary directory. however, when you process/tmp, one thing you don't want to do is to place/tmp on the Root partition, this results in file system corruption when the root partition is filled or crashed and restarted.

The/usr partition stores a large number of files used to support the system. The subdirectory/usr/local stores a large number of files installed from ports (7. If you do not use ports so much and do not store the system source code (/usr/src) on the machine, you can save 1 GB of disk space for/usr. On the contrary, if you install a large number of ports (especially window management and Linux Simulation), we recommend that you at least 2 GB/usr. If you want to place the system source code on the machine, we recommend that you do not underestimate the required space for 3G/usr. It will slow up and surprise you.

The/home partition stores user data and leaves the remaining space to this partition.

Why partition? Why not create a large partition? In this case, I do not need to consider the partition size. There are several reasons why this is not a good note. First, each partition has different operational features. separating them helps the file system adjust itself to these features. For example,Root and/usr partitions are mainly read operations with only a small amount of write operations, while a large number of read and write operations can occur in/var/tmp.Separating small partitions with more busy write operations will not affect the partitions with most read operations. Then, close the partitions with most write operations to the outside of the disk.(Outside the disk, not before a large partition, but after the partition table)This helps you increase the performance of frequently needed partitions. You may also need the I/O performance in a large partition, but they are so large that moving them out of the disk does not significantly increase performance, however, moving/var to the outside of the disk is significantly different.

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.