Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to partition the linux system in the production scene

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to partition the linux system in the production scene. The article is very detailed and has certain reference value. Interested friends must read it!

Foreword:

When we buy a house, we will consider 1 bedroom 1 living room, 2 bedrooms 1 living room, or 3 bedrooms 2 living rooms... Well, how to choose specifically depends on

Money in hand and number of households.

Similarly, the server operating system is divided into 3 zones and 4 zones. Whether to divide it into/home/ /var depends on our business requirements, operation and maintenance specifications or preferences of operation and maintenance leaders.

Too many, too few, can cause problems in different business scenarios (LVM can solve this problem, but it has its drawbacks, or some scenarios are superfluous).

Before we get into this, let's briefly talk about the role of the base/boot partition, swap partition, and/(root) partition.

Linux/boot partition, swap partition and/(root) partition role

The/boot boot partition stores boot files and the Linux kernel.

Boot file: Used to determine which operating system or kernel you need to boot.

Kernel: Simply put, the bridge between programs and hardware. You use applications to control the entire computer through the kernel.

Partition time general setting: 100-200M, formal environment, linux boot file and kernel size is less than 100M.

/Root partition, which acts as the root directory of the entire file system, regardless of how many partitions the hard disk is divided into. all the files

It's all in the root directory. In Windows, we divide the hard disk into c: d:e: , etc., and then

Store systems, programs, games, songs, etc. separately.

But under linux it's different: no matter how many zones you divide into, you have to give them a separate name,

Then mount the partition with directories named/data,/music,/study

Provide access to their respective directories, exactly the same treatment as directories.

Under linux, a hard disk looks like a partition. The root directory of this partition is/.

Partition general settings: points over the two areas, the rest are to the root partition can be.

In the large-scale website operation and maintenance of production scenarios (more than 200 servers), the partitions of ordinary servers are divided into the above three zones.

Wrong choice.

Advantages and disadvantages of using/boot partition, swap partition and/(root) partition scheme:

Advantages:

Simple, easy to use, can be installed and deployed in batches, and will not be divided into multiple partitions, some partitions are full,

Some partitions have a lot of space left and cannot be used (LVM is not described here).

(In fact, it can also be used. You can delete the rebuilt partition with fdisk and then expand it, but the process is complicated.

Interested friends can communicate separately).

Disadvantages:

If the system is broken, reinstall the system, because the data are in/(root partition), and lead to data backup trouble when reinstalling the system,

If you add partitions such as/usr,/home ,/var, etc., then the system is broken.

You can install systems directly in/(root partition) without destroying data in other partitions. Of course, I also said just now, if it is a cluster node, there is no need to backup data, the advantages of the partition scheme in this article are very obvious, there is no need to worry about a partition full and other partitions can not be used.

How do I partition linux when installing it in a production environment?

Here is my answer to the topic of this article for your reference. Just old boy's opinion.

Many students and friends will struggle here, how to partition linux system when installing in the production environment?

For example, the above/boot partition, swap partition and/(root) partition are basic, in addition, do not divide/home /var, etc., or even do not partition the data separately.

Actually, there is no fixed answer to this question. Well, you still won't be satisfied if you don't give us an answer, so I'll explain it in detail.

Tip: The above partition method can be established on the basis of raid. We'll talk about how to select raid for servers in different roles in production scenarios next time.

Attached: Introduction to other commonly used partition directories

/home The default storage directory of the home directory of the ordinary user;

/usr This is the directory where the system stores programs, such as commands, help files, etc. There are many files and directories in this directory. When we install a package officially provided by a Linux distribution, it is mostly installed here. If there is one involving server configuration files, the configuration files are installed in the/etc directory./ Under the usr directory there is the directory/usr/share/fonts, the help directory/usr/share/man or/usr/share/doc, the directory/usr/bin or/usr/local/bin or/usr/X11R6/bin of executable files for ordinary users, such as/usr/sbin or/usr/X11R6/sbin or/usr/local/sbin, etc.; there is also the directory/usr/include where the program header files are stored.

/var The contents of this directory are often changed, look at the name to know, we can understand the abbreviation for var,/var has/var/log This is the directory used to store system logs. var/www is the directory that defines the Apache server site;/var/lib is used to store library files, such as MySQL, and MySQL databases;

--------------------------------------------------------------------------------

Old Boy Survey Solicitation:

What do you think is the best way to partition linux in a production environment? Please TXT (Time-Subject-Name.txt) your answer to me.

I'm doing some research. Interested rookie and junior operation and maintenance friends can cooperate, and those who cooperate will be rewarded.

Reward an article: old bird talks about production scenarios how to partition linux systems? haha.

Dividing methods of collected netizens and students

(a) 20110802-linux partition method-kanga.txt

Partition uses ext3 format

/boot 200m Force primary partition

/swap 1.5- 2 times memory forced to dominate

/The remaining space is assigned to the root to force the main

Old boy comments:

In general, this partitioning scheme is a generic partitioning scheme suitable for general enterprise server choices. especially

RS under Load Balancer.

(b)

GENERAL(511429563) 2011-8-2 9:43:04

Whether to separate/home,/usr, according to the purpose of the server. As the old boy says,

Your house needs 2 bedrooms and 3 living rooms, maybe his house needs 3 bedrooms and 1 living room! individual opinion

Old boy comments:

Agreed.

(c)

AIX(xxx)10:35:28

/dos3G

/boot 64M

/Contents 10G

/HOME 100G

Our 3G/DOS is used to back up/directory servers on which of course this partition is not used!

AIX(519372002)10:36:34

Swap memory is too big! Not much local production data!

Old boy comments:

Generally speaking, dividing dos is meaningless, and/home single points have no purpose. No problem with swap, but once

Memory exhaustion, facing the risk of direct hang-up, it is recommended to divide a little less.

(d)

Invest in Hope 10:45:44

In my feeling, division, according to reality,

There are usually several partitions as follows

1、boot

2、/

3、/swap

4、/usr

5、/root

6、 /var

7、/home

The two most important points are as follows

First, does this host compile and install software frequently?

If you compile and install, I will put the/usr directory out separately to make a partition, and define the size myself (slightly larger according to the actual budget).

Second/var partition, log

General logs, temporary directories are in this partition, so it is recommended that a separate space to get a large point, logs can be very valuable things

Third custom backup partition

Generally/dos as a backup partition, the size is about 5G or the old saying is actually

Fourth/home partition,

This partition is also very important. About half of the space should be allocated to this partition. All the user data is here.

The fifth/swap partition, this according to the configuration, if the large memory can be completely avoided, the small memory is of course necessary,

Old boy comments:

The reason for this division is not strong.

(e)

Student saink

Company production environment

General server (original production environment, unchanged)

/boot 100M

swap 0~0.5 times memory

/The remaining space is given/

Oracle server 16 GB memory (installed directly managed by itself)

/boot 100M

swap 17G

/Remaining space

tmpfs manually gave 14000M, the original default 8G

I think the average server

/boot 200M

swap 1~2 times, now the server memory is relatively large, larger than 8G server swap partition slightly larger than the memory on the line

The memory is relatively small, then you can use 1.5~2 times, swap partition can be used as little as possible, the more used, the system performance decline

The remaining space is given to/

Old boy comments:

Basically agree with saink's sub-method, but DB SERVER or a single point of separation is better.

That's all for "how to partition linux systems in production scenarios." Thanks for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report