The hard disk partition table can store up to four partitions, but we are generally divided into two partitions, one is the primary partition (Primary partion) is an extended partition (extended partition), the primary partition can be used immediately but no longer partition, The extended partition must be partitioned before it can be used, meaning it must also be partitioned two times. So what's the extension partition going to do? It is a logical partition (Logical partion), and there is no limit on the number of logical partitions.1.2 Meaning of drive marking
For those of you who are accustomed to using DOS or Windows, there are several partitions that have several drives, and each partition will have a letter identifier, and then you can use that letter to specify the files and directories on this partition, and their file structures are independent and very well understood. For Red Hat Linux novices, however, it's a bit annoying. Because for Linux users, regardless of a few partitions, scored for the directory use, it is ultimately only a root directory, a separate and unique file structure. Each partition in Red Hat Linux is part of the entire file system because it uses a processing method called "mount point", which contains a full set of files and directories in the entire file system, and links a partition to a directory. At this point a partition to be loaded is available in a directory on the storage space of Linux.
Let's start by looking at how Red Hat Linux drives are identified. For IDE hard drives, the drive identifier is "hdx1", where "HD" indicates the type of device on which the partition is located, which refers to the IDE hard disk. The "X" is the disk number (A is the base disk, B is the base slave, C is the secondary primary, D is the secondary slave), "1" represents the partition, the first four partitions are represented by the numbers 1 to 4, they are the primary or extended partition, and the logical partition starts from 5. Example, Hda3 is represented as the third primary or extended partition on the first IDE hard disk, and HDB2 is represented as the second primary or extended partition on the second IDE hard disk. The SCSI hard disk is identified as "sdx1", the SCSI hard disk is "SD" to indicate the type of device the partition is located, and the rest is the same as the representation of the IDE hard disk, no longer repeat.
We can see from the above that the Red hat Linux partition is different from other operating system partitions, its partition format is commonly used in EXT3 and swap two kinds, EXT3 for storing system files, swap as Red hat The Swap partition for Linux (equivalent to a virtual memory file in Windows). So now we can see that red Hat Linux requires at least two dedicated partitions (Linux Native (local) and Linux Swap (swap)). Because Red Hat Linux cannot be installed on the dos/windows partition. In general, we will install Red Hat Linux with one or more hard disk partitions of type "Linux Native", but each partition in Red Hat Linux must specify a mount point, which tells Red Hat Linux to start , which partition to use for this directory. For a "Swap" partition, it is generally defined, and it does not necessarily define the load point.
Let's start with a preliminary understanding of "Linux Native" and "Linux Swap".
There are several purposes for the division of multiple zones:
Each disk is divided into partitions, each of which has its own file system. Windows specifies a letter for each of these file systems. However, Gnu/linux uses a unique tree structure to manage the files, and each file system is mounted somewhere in the tree structure.
Just as Windows needs a C: drive, Gnu/linux must be able to mount the root file system on the root (/) of the file tree. When the root mount is complete, you can mount additional file systems on various mount points in the tree structure. Any directory under the root structure can be used as a mount point, and you can also mount the same file system on different mount points at the same time.
The mount point is actually the entry directory for the disk file system in Linux
/root directory, store system commands and user data, etc. (if the following mount points do not have separate partitions, they will be in the partition of the root directory)
/boot boot loader static link file for Linux boot-related programs
/home User directory, storing data for ordinary users
/ tmp temp file
/ usr is where the Red Hat Linux system holds the software and, if possible, the maximum space should be allocated to it
/usr/local the self-installed program is installed here
/var constantly changing data, some server services, logs are placed below.
/opt (option optional) additional application package
/bin Basic Command Execution file
/dev Device files
/etc host-specific system configuration
/lib Basic shared libraries and kernel modules
/media mount point for moving media
/MNT for temporary mounting of file systems or other hardware devices (such as optical drives, floppy drives)
A virtual directory of/proc System Information (2.4 and 2.6 cores), which is generated in memory by the system itself.
/root Root User's Directory
/sbin Basic System Command execution file
/sys virtual directory for System Information (2.6 cores)
/SRV System-supplied data for service
/usr/x1186 x-windows directory, storing some x-windows configuration files
/usr/include System header file, storing some C-language header files
/USR/SRC Linux kernel source code, Linux system installed kernel source code are stored in this
/usr/bin some additions to the/bin catalogue
/usr/sbin some additions to the/sbin catalogue
/lost+found This directory is empty in most cases. But if you have a sudden power outage at work, or if you don't shut down normally, some files will not find where they should be when you restart the machine, for these files, the system puts them in this directory.
/boot: You must always physically include/etc,/bin,/sbin,/lib, and/dev, or you will not be able to start the system.
/home: Each user will place his private data in a subdirectory of this directory.
/tmp: The temporary data created by the program is mostly stored in this directory.
/usr: contains all user programs (/usr/bin), library files (/usr/lib), Documents (/usr/share/doc), and so on.
/var: all mutable data, such as newsgroup articles, e-mails, websites, databases, cache of package systems, etc., will be put into this directory. The size of this directory depends on the purpose of your computer, but for most people, it will be used primarily as a management tool for package systems. If you make a server, space should be as large as possible. My server's actual division and actual use of the size, has not actually put into use. So the/var directory doesn't use that much. The general Web hosting Web page directory is/var/www,postfix mail storage directory is:/var/mail,var/log, is the system logging partition,/var/spool: Store some mail, news, print queue and so on.
/OPT: Storage of optional installed software.
There are several mount points described above, in general we need at least two partitions (of course, as long as A/partition can also), need a swap partition, and a "/" partition, but some of the common, important mount points to other partitions, so easy to manage. General one/partition, one/usr partition, one/home partition, one/var/log partition. Of course, there are no rules, it is entirely in accordance with the needs of the set. We can use Disk Druid, which is provided by Red Hat Linux, to complete the partitioning and mount point settings.
Comparison and catalogue introduction, you can think of the Linux system mount point as a tree
/As the root of a tree
/derivative of the other mount point for the branch of this big tree
The file under the mount point is a leaf
If you have read my previous article on the Linux series, then you should remember that I used to mark a word:Linux under All Files! in other words, the Linux operating system manages everything in the system as a file. Our common hardware devices in Windows (printers, network cards, sound cards ...) ), disk partitions and so on, all are considered as files in Linux, access to devices, partitions is to read and write the corresponding files.3, actual combat partition Mount 3.1 temporary mount
To raise a chestnut, the original partition is as follows:
3.1.1 Unmount the partition first:[Email protected]]# DF-hfilesystem Size used Availuse% mountedon/dev/sda2 20G 5. 6G 13G //dev/sda6 996M 35M 910M 4/data /dev/sda5 426G 199M 404G 1/disk1/dev/sda1 996M 46M 899M 5%/boottmpfs 7. 9G 0 7. 9G 0 %/DEV/SHM
3.1.2 and then hang up again:Umount//data
3.2 Permanent mount: Auto mount on Boot
Note: As mentioned earlier, 2 partitions cannot be mounted to/data at the same time
The method in the above steps is only temporary work, the disk partition will not be visible after the boot or mount before the appearance, want to be permanent, also need to modify the/etc/fstab, will
Label=/data /data ext3 defaults 12LABEL=/disk1 / Disk1 ext3 defaults 12
/dev/sda5 /data ext3 defaults 12/dev/sda6 /disk1 ext3 Defaults 12
Description: Fstab is the file System Allocation table configuration file, the file has strict syntax format restrictions, similar to crontab, save your input format will be verified, please use it carefully, otherwise there will be unexpected problems. A total of 6 fields, space-delimited, specific meaning of each field please refer to here, no longer repeat: http://diamonder.blog.51cto.com/159220/2825423.3 Below is add HDD & partition & Mount (high-risk operation, novice use caution!) ）
Friendly tip: partition operation is high-risk operation, especially novice students do not try in the production environment, otherwise the consequences of their own!
For a more detailed partitioning tutorial, see:
Linux disk partition fdisk command details http://linux008.blog.51cto.com/2837805/548711
4, through the fstab set up the pit of the boot mountfdisk/dev/SDB input m---n---p---1--Enter---Enter---p---/dev///dev/sdb1/disk2 /Added in /etc/fstab:/dev/sdb1 /disk2 ext3 defaults 12
Fstab file Everyone is familiar with Linux at boot time through the information in the fstab to mount each partition, a typical partition entry is like this:
/dev/sdb4/mnt/usb vfat utf8,umask=0 0 0
/DEV/SDA4 is required to mount the partition, SDA4 is the Linux detection hard disk in order to the partition naming, generally speaking, this name does not change, but if you have more than one hard disk, hard disk in the computer in order to change the time, the same name may represent different hard disk partitions, if you are from the USB Device startup, and the insertion Order of other USB devices can also cause difficulty in zoning recognition.
Therefore, the above 3.2 section of the configuration directly write/dev/sda6 is a big risk, the reboot after the order of the hard disk may change, for example, you put Nginx user log on a separate partition, then after restarting although set Fstab, However, because the sequence changes the same partition number may represent a different hard disk partition, this will cause the data service on some partitions to be unavailable.
(PS: At the beginning of the article said in the review before the load configuration of the students found a buried thunder, it is the above problem. ）
This time the UUID comes in handy, the UUID is universally unique Identifier, that is, each partition has a unique UUID value, so there is no problem of partition recognition confusion.
Mount the partition with a UUID in Fstab, which looks like this:
Uuid=1234-5678/mnt/usb vfat utf8,umask=0 0 0
You can mount the partition correctly by filling in the appropriate UUID values for the partition after the uuid=.
So how do we know the UUID of a partition?
There are 3 ways to do this:
4.2 via vol_id command# ls-l/dev/disk/by-uuid/------1-: 0909-090b. /.. /1-7c627a81-7a6b-: 4806 -987b-b5a8a0a93645. /.. /
4.3 via blkid command# vol_id/dev/sdb5id_fs_usage=Filesystemid_fs_type=vfatid_fs_version=fat32id_fs_ UUID=0909-090bid_fs_uuid_enc=0909-090bid_fs_label=Swapid_fs_label _enc=Swapid_fs_label_safe=swap
# blkid/dev/sdb5/dev/sdb5:label="SWAP" uuid="0909-090b "type="vfat "
All three methods can be used to obtain the uuid,uuid of the partition according to the partition, the length and format are different.
For example, I finally put the/DEV/SDB in the/data1 directory (not reassuring to restart or generate files under test, see Mount Partition space is occupied not):
File system Type capacity used available% mount point /dev/sda3 ext4 518G 2. 7G 489G 1%/tmpfs tmpfs 16G 0 16G 0/dev/SHM /dev/sda1 ext4 1008M 61M 896M 7/boot/dev/sdb ext4 1. 8T 1. 1G 1. 7T 1/data1
Grep-v'#'/etc/fstab |column-Tuuid=0C685E8B-DBB3-4A1C-A106-3F1716AB34DD/EXT4 Defaults,noatime1 1UUID=2d7f1bcf-06d1-486e-87df-404ba670fcd9/boot Ext4 Defaults,noatime1 2UUID=248e7a99-b459-4800-BBD3-354047E49A2F Swap swap Defaults,noatime0 0Tmpfs/dev/shm Tmpfs Defaults,nosuid,noexec,nodev0 0devpts/dev/pts devpts gid=5, mode=620 0 0Sysfs/sys SYSFS Defaults0 0proc/PROC proc Defaults0 0UUID=870ebaf6-727f-48d3-b60c-f203339d94ac/data1 Ext4 Defaults,noatime0 05. FAQ:
Linux disk and partition detailed