Linux partition Guide "Ubuntu Server Best Practices" __linux

Source: Internet
Author: User
Reproduced from: http://blog.csdn.net/intlgj/article/details/8575192
Introduction to Linux File system architecture

The Linux operating system has some fixed directories. The directory structure of various Linux distributions is not exactly the same, but there is no big difference. Knowing the role of these catalogs is helpful not only for your disk partitioning program, but also for your day-to-day maintenance work to be easier.

The main directory of the Ubuntu file system is shown in table 2.2.

Table 2.2 The main directory of the Ubuntu Linux file system

Directory

English full Name

Use

/

/

The starting point for the entire directory structure, all other files and directories are underneath it

/bin

Binaries

Used to store the most commonly used binary commands

/boot

Boot

Contains primary files for booting Linux, such as grub and kernel files

/dev

Devices

All devices are in this directory, including hard drives and monitors

/etc

etc

All of the system's configuration files are placed underneath it

/home

Home

Store the Home directory ($HOME) of each user and its files and configuration

/lib

Libraries

System library files, sort of like Windows program files

/lost+found

Lost+found

Files that are missing when a system exception is stored (such as sudden downtime) to facilitate recovery

/media

Media

Load various media, such as CD-ROM, floppy disk, etc.

/mnt

Mount

Loading various file systems

/opt

Optionally

"Optional" program for storing the installation

/proc

Processes

Contains information such as processes, which are memory mappings, not real directories

/root

Root

The directory is the root directory of the root user

/sbin

System-only binaries

Store system-specific binary commands

/sys

System

Storing System Information

/tmp

Temporary files

Storing temporary files

/usr

User

Store ordinary users ' applications, library files and documents, etc.

/var

Variable files

Store files that change frequently in time, size, and content

The use of the various directories in table 2.2 should be well understood. As long as you understand the purpose of each directory, you can not make a big mistake in the hard disk partition. partitions and mount points

Usually, when we discuss Linux "partitioning", we often confuse the concept of "mount point" and "Partition". In fact, as long as we can understand it, do not have to pick words. However, as a Linux system administrator, we should still understand the differences between the two concepts.

What we normally call "/var zoning" actually says "/var", and "/var" is just a mount point. So what is "zoning"?

In Linux, "zoning" is a single device, placed in the/dev directory. If the IDE hard disk, their names should be/dev/hda1,/dev/hda2, and so on, if SATA or SCSI hard drives, their names are/dev/sda1,/dev/sda2 and so on. presentation method for hard disk partitions

So what is HDA and SDA? They are shorthand for hard Driver number A and SCSI Driver number A, that is, HD and SD point to the interface type of the hard disk, followed by an ordinal, which represents the first few hard drives. The 1th IDE hard disk is HDA, the 2nd IDE hard disk is HDB, and so on, and the 1th SCSI hard drive is represented by SDA, then the 2nd block SCSI is represented by SDB, and so on, then SDC, SDD, and so on.

In fact, SD represents more than just SCSI devices. In addition to IDE devices, storage devices for SCSI, SATA, USB, Firewire, and so on are represented in SD.

As you already know,/DEV/SDB2 refers to the 2nd partition of the 2nd SCSI hard drive, while/dev/hda5 refers to the 5th partition of the 1th IDE hard disk.

Table 2.3 Linux Hard Disk Partitioning presentation method

IDE interface Hard Disk

SCSI Interface Hard Drive

Representation of the entire hard disk

/dev/hda

/dev/hdb

/dev/hdc

......

/dev/sda

/dev/sdb

/dev/sdc

......

Presentation method for hard disk partitions

/DEV/HDA1,/dev/hda2 ...

/DEV/HDB1,/DEV/HDB2 ...

/DEV/HDC1,/dev/hdc2 ...

/DEV/SDA1,/dev/sda2 ...

/DEV/SDB1,/DEV/SDB2 ...

/DEV/SDC1,/dev/sdc2 ...

In the older Linux kernel, all IDE-related driver code is not only too complex, but also a lot of problems. As a result, Linux kernel developers start with kernel 2.6.19, providing libata based PATA drivers that enable IDE devices to be used like SCSI devices.

So, what we're using in Ubuntu, whether you're using an IDE hard disk or a SATA hard drive, you see devices that are/DEV/SDX instead of/DEV/HDX. From then on,/DEV/HDX ceased to exist.

It should be noted that in Linux, there is another way to represent a hard disk partition, which is used in grub. Grub originated in Grand Unified Bootloader, is a general-purpose computer bootstrapper that supports multiple booting of multiple operating systems. In grub, whatever the interface's storage device, it is represented by HDX, where x is the number, starting at 0. For example, the 1th partition of the 1th hard disk is represented as (hd0,0). Linux Zoning Guide

With any Linux system, there must be at least two partitions: one is the root partition, the "/" is the other, and the other is the swap (swap) partition. So, the simplest partitioning method is to create a swap partition, where all the remaining space is allocated to the root partition "/".

The size of the swap partition should be as large as memory, with a maximum of twice times the size of memory.

The swap partition is like a Windows virtual memory Exchange file Pagefile.sys, which the system uses as virtual memory when needed. For example, when running a large program, in memory optimization, or when the system is dormant. When the system sleeps, writes the entire memory data to the swap partition, which is why your swap partition should be at least as large as memory.

Also, it's a good idea to create/boot on a single partition. Because the files in this directory are more important, the system may not start if the partition is corrupted. If you create a separate partition, other partitions will not damage it, thereby increasing the stability of the system. Under normal circumstances, the/boot partition does not need to be too large, 128MB is enough.

As for the other partitions, it depends on your actual needs.

For example, if your server will have a lot of users log in to put files, then/home best separate partition, and give enough space.

For example, if your server is to put the database, the database may become very large, then/var best separate partition, and give enough space. Because the database is placed under/var by default.

The same is true for Web servers, because Web pages are placed under/var by default. So if you think someone will upload a lot of files, it's best to separate the/var and give it plenty of space.

hint : As a server, Hiweed also recommends/TMP as a separate partition. Because most applications will write temporary files to this directory, although the directory will be emptied every time Ubuntu restarts, no one will be able to reboot the server at all times. Linux Partition Case

Hiweed is doing a system architecture for a friend's company, a development server inside the company, and a Web server and database server in the engine room.

The development server is for the company developers who want to store a large number of files in the home directory. Normally, when their workstation is started, it automatically mounts their own "home directory" on the development server to the local. Therefore, this server's/home is used most, and needs the relatively big space.

In addition, because it is the development server, we also need a version management source code warehouse, this warehouse is placed under the/var. Although the file size of the source code is not particularly large, it does not require extra space, but the code is very important, so we also need to protect them like/boot.

Therefore, for this development server, our partitioning scheme (server hard disk has a total of gb[10 GB], memory is 1 gb[512 MB), see table 2.4.

Table 2.4 Development Server partition scheme

File system

Mount point

Size

Partition format

/DEV/SDA1 (Main)

/boot

254 mb[254]

Ext2

/dev/sda2 (Main)

/

Ten gb[2]

Ext4

/dev/sda5

No

2 gb[768]

Swap

/dev/sda6

/var

20.3 Gb[2]

Ext4

/dev/sda7

/home

46.8 gb[4.3]

Ext4

/dev/sda8

/tmp

2 gb[768]

Ext4

The above zoning plan is only a reference, the actual zoning plan should be based on its own actual situation.

Our zoning scheme (2T)

File system Mount point Size Partition format
Sda2 / 500G Ext4
Sda3 /boot 2G Ext4
Sda4 /home 1.2T Ext4
Sda5 20G Swap
Sda6 /tmp 50G Ext4
Sda7 /var 200G Ext4



/etc/fstab Introduction

All of the static file systems in the Linux system are described in the/etc/fstab file. Fstab is a shorthand for the file system table, which is the "FileSystem tables." When the system starts, it is through the information in the fstab to mount each partition. The Fstab file System entry has 6 fields, as shown in Table 2.5.

Table 2.5 fstab Format

Equipment

Mount point

Format

Mount Options

Whether to back up

Check Order

/dev/sdb2

/home

Ext4

Defaults

0

2

Let's take a look at what each field means, as shown in table 2.6.

Table 2.6 fstab each field meaning

The option to mount the

Word      paragraph

Stroke        ;

Device

Storage device (  partition)   name or uuid

Mount point

The destination folder name to be mounted. When mounted, the device can be accessed from the folder

Format

File system format, such as: Ext4

.  mount options

. The same options as the mount  command, please refer to the man Mount

Whether backup

Enable/  disable dump  Back up

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.