CentOS disk installation and disk partitioning scheme detailed

Source: Internet
Author: User
A few days ago I studied the next few Linux systems, or feel CentOS better. Relatively stable, at least desktop systems are better than Ubuntu.
Installation CentOS is not difficult, installation methods are, such as hard disk installation, U disk installation, the most simple and convenient, of course, CD-ROM installation, and burning a tube disk only need 10 minutes, than hard disk installation and U disk installation needs to carefully study a large number of documents easy to explain.

I have to be WINDOS7 and CentOS dual system installation. There was a windows7 system before. Then I removed the last disk G disk and used it to install CentOS.

I gave CentOS left 20+g hard disk space, if it is a novice to the words, the proposal directly divided into 2 areas can be
One is:/

The other is: Swap

It is recommended that beginners do this because if they do not understand the distribution, may cause some partitions to be less, causing system installation error, another reason is that the novice needs to install several times to try to learn, so you can be installed in the subsequent installation of the learning process in more areas, began to divide these two areas is just a test primer

Regardless of how the partition does not affect the layout of the system file directory, I began to think, if only divided into these two areas no USR, Var, etc partitions, will not be installed after the file root directory is not usr, Var, etc such folders ah?! It turns out that I'm being paranoid. File directory How else, such as to the/USR partition just let this folder has its own site quite with/usr a single hard drive, other partitions such as/and partition/var partition damage so/usr is fine.

If you do not give/usr a separate partition then he is going to mount/follow the partition, just like when with a dependant if/with the partition is damaged the/usr section also follows.

Supplementary: CentOS Zoning Programme

(1) The most basic zoning programme:

/: The recommended size is above 5GB.
Swap: Swap partition, recommended size is 1~2 times of physical memory.

(2) Advanced partitioning scheme:

/boot: Used to store programs related to Linux system startup, such as boot loader, and so on, the recommended size is 100MB.
/: The Linux system root directory, all the directories are hanging under this directory, the recommended size of more than 5GB.
/home: For ordinary users of the data, is the normal user's host directory, the recommended size for the remaining space.
Swap: Implements virtual memory, the recommended size is 1~2 times of physical memory.

(3) Advanced Partitioning programme:

/boot: Used to store programs related to Linux system startup, such as boot loader, and so on, the recommended size is 100MB.
/usr: used to store applications in the Linux system, with more data and recommendations than 3GB.
/var: Used to store frequently changing data and log files in Linux systems, more than 1GB is recommended.
/home: For ordinary users of the data, is the normal user's host directory, the recommended size for the remaining space.
/: The Linux system root directory, all the directories are hanging under this directory, the recommended size of more than 5GB.
/tmp: The temporary disk is in a separate partition to avoid the system's stability when the file system is stuffed. The recommended size is above 500MB.
Swap: Implements virtual memory, the recommended size is 1~2 times of physical memory.

CentOS Partition steps

There are 3 Linux commands involved here. FDISK partition command, MKFS Format command, Mount Mount command.

A, Fdisk has several important parameters to understand:
Command (M for help):

View Help information: Enter M, see the following information

D Delete a partition note: delete a partition;
Eg:fdisk/dev/hda1–>d (Delete one of the partitions) –>3 (delete partition with number three)

L list Known partition types Note: L is a list of partition types for us to set the appropriate partition type;
Eg:fdisk-l, Fdisk-l/dev/hda1

M Print this menu note: M is listing help information;

n Add a new partition note: Add a partition;
Eg:fdisk/dev/hda–>n (new partition) –> Select Primary partition or logical partition –> select partition size

P Print the Partition table Note: P lists the partition tables;
Q Quit without saving changes Note: Do not save the exit, the wrong point to quit
t change a partition ' s system ID Note: T changes the partition type;
V Verify the Partition Table Note: Verifying partitions
W Write table to disk and exit Note: Write the partition table to the hard drive and exit;

Here I write directly what I have used:

1.fdisk/dev/hda//Partitioning of/dev/hda
2.N//Increase Zoning
3.P//input P type is set to: Primary partition
4.3//input 3 partition number set to 3
5. Carriage return//Start position can be default
6. Enter//size set to all. This can be customized like +3000m or +3000k, where only M and K are supported
7.t//input T set partition type
8.3//Input 3, set the new 3rd partition format
9.8e//Input 8e set to LVM because the server disks are LVM
10.V//input v Check partition table
11.W//input w write partition table, end of partition
12.reboot//reboot, zoning effective:)

2. mkfs format, the partition is good on the format of the disk file type.

There are several file types that can be selected for EXT2,EXT3. Here Ext3 has new Exception log processing than ext2, so we choose Ext3.
Mkfs.ext3/dev/hda3///dev/hda3 build ext3 file system, you can use MKFS.EXT2 to establish ext2 file system

3. Mount mount, only the formatted partition can be mounted

1.mkdir/www//linux partitions are mounted in the directory, so we first set up the WWW directory under the root directory
2.MOUNT/DEV/HDA3/WWW//mount the partition to the directory, OK.
3.DF-HL//view disk remaining space information, you can see/www have 10G free space
Note: This mount operation is only one effective, reboot need to mount, if you want to boot automatically mount this partition, you can modify/etc/fstab in this file last line plus/dev/hda3/www ext3 defaults 1 1 Save, A reboot is available.
4.1. Vim/etc/fstab
4.2. GG->end Cursor moved to end of file,
4.3. I//Enter edit mode
4.4. Input/dev/hda3/www ext3 defaults 1 1
4.5. esc//Press the Exit key
4.6:WQ//Save exit, done! will be automatically mounted the next time.

OK, the partition format mount is basically done.
Set/Modify the swap partition on the CentOS
To set the swap partition on the CentOS
As the most stable server version in the Linux world, RHAS5 has always had a very large application face, which has always been concerned about FreeBSD, because of the need to apply, especially in conjunction with MySQL and Oracle Red Hat has too many advantages.
Using CentOS to replace the use of Red Hat as, because CENTOS5 is to use RHAS5 source code, remove Redhat trademarks, icons compiled after the release, is the most compiled version of the source code, I use the CentOS 5.2
When installing CentOS 5.2, forget to set swap swap partition, in the case of small memory, increase the role of swap more effective.

The first step is to create a file block

#cd/var (Enter a folder)
#dd If=/dev/zero of=swapfile bs=1024 count=524288 (create 512M swap, typically twice times the ram)
#/sbin/mkswap swapfile (Create swap file)
#/sbin/swapon swapfile (Activate swap file)
#/sbin/swapon-s (check if swap is correct)
Filename Type Size Used Priority
/var/swapfile file 524016 0-1
#vi/etc/fstab (add to Fstab file to let system boot automatically)
Add the following at the end:
/var/swapfile Swap Defaults 0 0
After reboot, the top command looks at the size of the swap partition.

The problem with swap has been resolved (originating from the network)


2. Format China and start swap file

Next, execute the mkswap command, format the Myswap file as s file system, switch to the/tmp directory, and execute the following command:
# Mkswap Swapfree (#将文件格式化为swap文件格式)
Setting up Swapspace version 1, size = 262144 KB
# Swapon/tmp/swapfree (#启动swap分区)
To stop using the newly created swap file, you can delete the file if the swap file is no longer in use, as long as the Swapoff/tmp/swapfree command is executed.

3. Check Swap


4. Automatically start the newly added swap partition on power-on

If you have to perform a swapon command to start the swap partition or file every time you turn it on, this is too much trouble. You can use the text editor to add a line to the/etc/fstab file so that you start the swap partition and file automatically when you boot up:
/DEC/HDB5 Swap defaults 0 0 (start this swap partition on power-on)
/tmp/swapfree Swap defaults 0 0 (start this swap file on power-on).

Swap space Size:

Typically, the swap space should be greater than or equal to the physical memory size, the minimum should not be less than 64M, and usually the size of the swap space should be 2-2.5 times times the physical memory. But according to different applications, there should be different configuration: if it is a small desktop system, it requires only a small swap space, and large server systems depending on the situation requires different size of swap space. In particular, database servers and Web servers, with the increase in traffic, the demand for swap space will also increase, specific configuration see the description of the server products.

Swap quantity:

The number of swap partitions also has a significant impact on performance. Because swap operations are disk IO operations, if there are more than one swap swap area, the allocation of swap space will be operated in rotation to all of the swap, which will greatly balance IO load, speed swap exchange speed. If there is only one swap area, all switching operations make the swap area very busy, making the system wait for most of the time, and inefficient. With performance monitoring tools, you will find that the CPU is not very busy at this time, but the system is slow. This shows that the bottleneck on Io, relying on increasing the speed of the CPU can not solve the problem

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