Summary of knowledge about FreeBSD partition

Time:2019-4-27

Terminology of partition

FreeBSD divides the hard disk into up to four slices, and the boot zone of FreeBSD must be one of these slices. Each slice can b e divided into up to eight partitions, which are called a, b, c, d, e, f, g, H. Traditionally, a, b, c, D partitions have a special meaning. A means root partition, B means swap partition, C means whole slice, D means whole hard disk.

Sequence of partitions

Since FreeBSD-2.0.5, FreeBSD has developed a new concept of slice. Only the whole slice is located in c, and the others can be used freely. However, the traditional concepts of a: root, b: swap, efgh: other uses are generally followed.

Root and / usr partitions are usually read more frequently and written less. They need to be placed close to the outer track. Large partitions such as / usr can be placed on the inner track. Both / VAR and / var / tmp read and write frequently.

Create partitions in the corresponding order: root, swap, / var, / usr.

Use of partitions

/ It saves the files needed to start the system.

/ var is mainly used for storage: mailbox, printing spool and log files. Mailboxes and log files may reach an unpredictable number, depending on how many users are on your system and how long your log files can be saved. 如果你想要运行一个邮件服务器,一个超过G数量级的/var分区是必要的。 In addition, / var / tmp should be large enough to contain enough packages that you might add.

/ The usr partition holds the files needed by the support system and a subdirectory called / usr / local to save the files installed from ports. If you don’t use ports and don’t want to save system source code on the machine, you can save more than 1G / usr partitions. If you install many ports, we recommend that at least 2G space be reserved for / usr. If you also want to save the system source code on your machine, we recommend that you reserve 3G space for / usr. Don’t underestimate the size of the space required for this partition, it may increase continuously and surprise you very much! __________ When you adjust the size of partitions, remember that your system may increase the demand for space.

Swap swap can avoid fragmentation, but also prevent the impact on the file system, better performance. Usually swap partitions are 2-2.5 times as large as memory, which is enough to deal with daily emergencies. In larger systems with many SCSI (or IDE) disks, we strongly recommend that you create a SWAP for each hard disk. Swap partitions should have the same size. The kernel may be processed to any size, but the internal data structure is four times as large as the maximum swap partition. Keeping swap partitions the same size allows the kernel to best schedule swap space to access disks.

/ TMP is used to save temporary files.

Notes for Zoning

The size of the partition varies according to the actual situation of the application. In particular, it is pointed out that website files, database files, log files and temporary files should be stored in separate partitions to prevent the system from crashing due to the abuse of disk space by attackers.

Special Zoning Reference

An example of partitioning a 18G SCSI hard disk
Partition size
/     128M 
SWAP 1008M is at least twice the amount of memory (512M memory is used in this system)
/tmp  256M 
/ Applications such as usr, 3G system and Apache, and source code are stored in this partition
/ The usr/home 7G website file is stored here
/ The var 3G database will use this partition
/ var/log 2811M log files partitioned separately

General partitioning scheme of FreeBSD

When establishing internal partitions, attention should be paid to the rational allocation of disk space. In general, the following suggestions are recommended:
/ 256M
Swap 512M, in principle, is memory size, but there is no need to exceed 1G
/ tmp 100M, suitable for most server environments, can be increased appropriately
/ var 4000M, if the hard disk is less than 9G, 2000M, at least 1000M
/usr 500M
/ usr / local 500M, enough as a server, or up to 1000M

/ Home*, all the remaining space on the first hard disk
/ disk1*, all the space of the second hard disk
/ disk2*, all the space of the third hard disk, and so on

Similar to the previous step, FreeBSD Disklabel Editor also lists command keys in the middle of the screen, and we create partitions in C. For existing partitions, you can use M to set the loading point, or T to reformat.

Finally, don’t forget to check that all FreeBSD partitions except / and swap are set to “UFS + S”.
If not, use S to activate the “SoftUpdates” option for the current partition to improve file system performance.
Note that for security reasons, do not set / to SoftUpdates.
Save and exit by pressing the Q key

=========================================================================

A FreeBSD partitioning scheme for WEB servers

/ (128MB)
swap (2048MB (2048MB RAM))
/tmp (512MB)
/var (1024MB)
/usr (10240MB)
/home (rest of the hdd)

The following is a supplement to other netizens:

FREEBSD 5.0 partition and LINUX partition concepts are different. Brothers who have not installed FREEBSD can see! Personal installation experience!

We know that a hard disk can be divided into four main partitions at most, and an extended partition is a main partition. When playing WIN, our hard disk usually has only two main partitions, one is C disk, the other is extended partition. Now, if we want to install FREEBSD while retaining WIN, we need to divide the hard disk and divide one partition as the main partition, because FREEBSD must. Installed on the main partition, rest assured that a hard disk can have four main partitions, so it is no problem to add another main partition, how to add a main partition? I suggest brothers use this software: partition expert2003, and then online search should be able to find, this software partition speed!

Okay, now we have three main partitions on our hard disk. One is C disk, the other is extended partition, and the other is the main partition we just filled in. Next, we introduce the partition naming rules of FREEBSD, which is different from LINUX:

FREEBSD calls the primary partition SLICE, that is to say, a hard disk can have up to four SLICEs. The four primary partitions are wd0 s1, wd0s 2, wd0s3, wd0s4, wd0 as the first IDE hard disk. The first partition is identified by s1. If the second primary partition is an extended partition, it is called wd0s 2, by analogy. When FREEBSD is installed, it will occupy a main partition. Suppose we use the third main partition to install FREEBSD, that is wd0s3, then we need to specify this partition as the installation partition of FREEBSD. Under the partition interface, we can move the cursor to wd0s3, and then change the partition type according to “T”. Input 165 and 165 are the partition type of FREEBSD. There will be above partitions. Explanation, brothers can see, after changing the type of partition, we press “W” to write, at this time will be prompted to use what tools to guide, I usually choose “BOOTMANAGER”, and finally press “Q” to exit!

Now that the FREEBSD partitions are ready, we need to divide them into’/’,’/ var’,’/ usr’swap partitions on this partition. We even press’A’, so that FREEBSD can divide these partitions automatically. In fact, this part is just like dividing logical partitions on the extended partition. Then we write in’W’, exit by’Q’, so the partition is ready, and then we can get it done. Come down and install the others, haha!

Having said so much nonsense, I want my brothers to have a better understanding of it. I can’t help but want to sum it up again.

1. FREEBSD must be installed on the main partition. If your computer only has two main partitions now, you must remember to draw one more partition. Otherwise, you will accidentally destroy the extended partition. 5555555, blood lesson!
2. First, specify a primary partition for FREEBSD.
3. Then the specified primary partition is divided into’/’,’/ var’,’/ usr’swap and so on.