Detailed Linux-- disk partition

In this paper a reference to a blogger, specifically who has been found, to express my gratitude

In the process of learning Linux, the installation of Linux is the first threshold for each beginners. In the middle of this process, the greatest confusion than to partition the hard disk. Although now a variety of Linux distributions already provides a friendly graphical interface, but many people still feel unable to start. This is one of the main reasons Linux is not clear zoning regulations, as well as the most effective partitioning tool below it - Fdisk to use
we need the basic concepts of hard disk partitions some preliminary understanding, the hard disk partition is divided into primary partition ( primary partion) and extended partition (extension partion) are two, and the number of the primary partition and the partition expansion can not exceed four. And the primary partition can be used immediately but can not be partitioned. After the partition must be expanded in order to use another partition, which means that it must also be a secondary partition. So what to go by the expansion of the partition subdivision is it? It is a logical partition (logical partion), Moreover, there is no limit on the number of logical partitions
on the accustomed user dos or windows, there are several drives have several partitions, and each partition will get a letter identifier, and you can use this letter to specify files and directories on the partition, they are independent of the file structure, very easy to understand. But for these users to get started early red hat linux, and may a bit annoying. Because of the red hat linux users, regardless of several partitions, which points to the directory to use, in the final analysis it is only one root directory, a separate and unique file structure. Each red hat linux partitions are used to form part of the file system, because it uses a processing method called "loading" of the entire file system which contains a set of files and directories, and the a partition and a directory link. Then you want to load a partition will make storage space available under a directory
For windows users, the operating system must be installed in the same partition, it is a commercial software! So you have no choice! On red hat linux, you have a greater choice, you can put the system files in several areas to install (need to explain load point), it can also be installed in the same partition (mount point is "/")
under these two aspects, to explain this puzzle everyone's problem

First, the provisions of the Linux partition

1.1 Device Management

In Linux, each hardware device is mapped to a file system for hard disk drives and other IDE or SCSI devices are no exception. Linux various IDE devices assigned to a file composed of hd prefix; and for a variety of SCSI devices, then the file is assigned a prefix consisting of sd
for ide hard disk drive identifier "hdx ~", where "hd" It indicates the type of device where the partition, here refers to the ide hard drive. "X" is the tray number (a substantially disc, b is dependent substantially dish, c is the secondary master disc, d is a secondary slave disk), "~" represents the partition, the first four partitions with numbers 1-4 indicate that they are primary or extended partition, beginning from the logical partition 5. Embodiment, hda3 expressed as a third primary or extended partition on the first hard ide, hdb2 denoted as a second primary or extended partition on the second hard ide. For scsi hard disk is identified as "sdx ~", scsi hard disk is "sd" to indicate the type of device where the partition, and the rest as a hard disk ide representation, not to say
, for example, a first IDE devices, Linux on is defined as the HDA; second IDE device is defined as HDB; so below. The SCSI devices should be sda, sdb, sdc, etc.

1.2 partition number

To partition must be operated for each hardware device, that might be an IDE hard disk or a SCSI hard disk. For each hard disk (IDE or SCSI) device, Linux is assigned a serial number 1 to 16, which represents the number of the hard drive partitions above
example, the first IDE hard disk first partition map under Linux is hda1, the second partition is called hda2. For SCSI hard disk is sda1, sdb1, etc.

1.3 The role of each partition

In Linux provide that each hard disk device can have up to four primary partitions (which contains the extended partition) constitute, any one extended partition should occupy a primary partition number, that is, a hard disk, the primary and extended partitions up to a total of 4 is
for the older DOS and Windows (Windows 2000 the previous version), the system recognizes only one primary partition, a logical drive letter may be increased by the method (logical partitions) in the extended partition, further refine the partition
primary partition role the computer is used to start the operating system, so that each operating system boot, or boot program called, should be stored in the primary partition
that is the maximum difference between the primary and extended partitions and logical partitions
we specify the installation boot Linux bootloader of time, to be specified on the primary partition, is the best example
Linux provides primary partition (or extended partition) occupies 1-16 number in the first four numbers. In an example first IDE hard drive, a primary partition (or extended partition) occupies hda1, hda2, hda3, hda4, hda5 occupied logical partitions to 12 numbers, etc. hda16
Thus, Linux below each hard disk up to a total of 16 partitions
for logical partitions, Linux provisions they must be based on an extended partition (also so stated on DOS and Windows systems), rather than on the primary partition
so we can see the extended partition can provide a more flexible partition mode, but can not as a guide for the operating system. Remove differences above these various partitions, we can simply put them equal treatment of

1.4 Zoning Index

For every Linux partition in terms of size and partition type partition is the most important indicator. The capacity of the size of the audience is easy to understand, but the type of partition is not so easy to accept. Partition type specifies the format of this file system partition on
Linux supports a variety of file system format, which contains the familiar FAT32, FAT16, NTFS, HP- UX, Linux and a variety of specific Linux Native and Linux Swap partitions type
in the Linux system, you can distinguish between these different types of partitions by partition type number. Various types of numbers describes ways to use Fdisk of time will introduce

1.5 Frequent Partitions

/boot分区Contains the operating system kernel and boot the system in the course of the use to the file, built this partition is necessary because most of the current pc confidential restricted bios, and moreover if they have a separate / boot partition boot , even if the main root partition there is a problem, the computer is still able to start. The partition size of between about 50mb-100mb. But if you want to start with the red hat linux system lilo words containing / boot partition must be entirely within the cylinder 1023 or less. Also, because data can not be read lilo after 8gb, so red hat linux to be installed within the area 8gb
/usr分区place is red hat linux system storage software, if possible, should be the maximum space allocated to it
/home分区is the user's home directory location, this partition size depends on how many users. If multiple users share a computer, then this partition is absolutely necessary, besides the root user could control the ordinary users to use a computer, such as imposing hard limits the use of the user or group of users, restrict ordinary users which file access Wait. In fact, single-user also necessary to establish this partition, because no partition, then you can only root user's identity landing system, this is dangerous, because the root user has the absolute right to use the system, but once you are on the system made a mistake, trouble will come
/var/log分区is the system logging partition, if set up this separate partition, so that even if the log file system, there is a problem, they do not affect the main operating system partition
/tmp分区used to store temporary file. This is a multi-user system or network server is necessary. So even if the program is run to generate a lot of temporary files, or the user of the system was in error, the other part of the file system is still safe. Because this part of the file system still suffered under the read and write operations, so it is often a problem more quickly than other parts
/bin分区storage standard system utility
/dev分区storage device file
/opt分区storage software installed optional
/sbin分区storage standard file system management
The above describes several commonly used partition, in general, we need a swap partition, a / boot partition, a / usr partition, a / home partition, a / var / log partition. Of course, this is no provision entirely according to your personal to set. But remember to have at least two partitions, one swap partition, a / partition

Two, Fdisk uses detailed

By using the method described below Fdisk, and to consolidate a variety of knowledge about Linux partition above learned
Fdisk various Linux distributions is the most common partitioning tool, is defined as Expert-level partitioning tool that allows beginners a little discouraged

2.1 Fdisk Parameter Description

Run Fdisk when the first thing you see is the welcome screen, the user input command parameters in this interface to operate Fdisk. Prompted for a user by "m", may be displayed Fdisk command description for each parameter. Readers can see the Fdisk has many parameters, but is a few frequently used, if the reader familiar with these parameters can smoothly use Fdisk, on the Linux partition the hard drive. We briefly describes the meaning of each parameter, and the detailed description of several key parameters of
the user partition in Linux, the most commonly used parameters are d, l, m, n, p, q, t, w , etc.

2.2 partition with Fdisk

Linux partition process in general is to be displayed by the hard disk partition table information parameter p, then partition the information to determine the future. If you want to completely change the format of the hard disk partition, will be deleted by the presence of one parameter d hard disk partition
e.g. d1, d2. Deletion is complete, you can add a new partition by n parameters. When you press the "n", we can see the new partition. Here you select the new partition type, or the extended partition is a primary partition; then select p or e. The difference between them has been described hereinbefore. Then it is to set the size of the partition. Need to be reminded to note that if there is an extended partition on the hard disk, it can only increase the logical partition, extended partition can not be increased, and the increase when the district, which is the default type of Linux Native, if you need to change some of these partitions other types, such as such as Linux Swap or FAT32, can t be changed by the command, when you press "t" to change the partition type, the system will be prompted to change which partition, and why the change type (if you want to know the system supports partition type, type l). Linux partition types supported by their corresponding partition numbers and types, those listed in Table 2 (the command information can be obtained by l). Change over the partition type, you can press the "w", save and exit. If you do not want to save, you can select the "q" to exit
fdisk is a powerful tool for disk operations, from util-linux package, we are here to just say how his view disk partition table and partition structure; parameter -l, by - l parameter, to obtain the number of machines in all disks, disk partitions can list all cases

[root@localhost beinan]# fdisk -l
Disk /dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 765 6144831 7 HPFS/NTFS
/dev/hda2 766 2805 16386300 c W95 FAT32 (LBA)
/dev/hda3 2806 7751 39728745 5 Extended
/dev/hda5 2806 3825 8193118+ 83 Linux
/dev/hda6 3826 5100 10241406 83 Linux
/dev/hda7 5101 5198 787153+ 82 Linux swap / Solaris
/dev/hda8 5199 6657 11719386 83 Linux
/dev/hda9 6658 7751 8787523+ 83 Linux

Blocks above, the size of the partition is indicated, Blocks unit is byte, we can be converted into M, such as the first partition / dev / hda1 if the size in terms of M, should be 6144831/1024 = 6000M, i.e. about 6G, in fact, not so troublesome, rough look forward to moving the decimal point three, you know approximately how much volume the
file system system representation, such as / dev / hda1 is NTFS format; / dev / hda2 representation is fat32 formatted file system
in this case, we pay special attention to is that / dev / hda3 partition, which is the extended partition; he includes the following logical partition, in fact, this partition is equivalent to a container; subordinate to her there hda5, hda6 , hda7, hda8, hda9
we also note that, how not hda4 it? Why hda4 not included in the extended partition? A disk up to four primary partitions; hda1-4 are considered primary partition; hda4 not contain the extended partition, the partition can be considered further extended primary partition; in this case, no hda4 this partition, we can of course wherein a partition set primary partition, but I did not do it when the district
take a closer look at statistics, we take a look at this disk space is not there? hda1 + hda2 + hda3 = actual volume has been partitioned, so we can count hda1 + hda2 + hda3 = 6144831 + 16386300 + 39728745 = 62259876 (b), in terms of M units to move forward three decimal places, so now divided good partition volume is occupied by approximately 62259.876 (M), in fact the most accurate calculation 62259876/1024 = 60800.67 (M) ; and the size of the disk is 80.0 GB (80026361856byte), in fact, the actual size is 78150.744 (M); through us calculation series, we can come to this space there are still hard to use; there are still about 18G unpartitioned space
we can also specify the fdisk -l to see which of partitioning a hard drive

[root@localhost beinan]# fdisk -l /dev/sda
Disk /dev/sda: 60.0 GB, 60011642880 bytes
64 heads, 32 sectors/track, 57231 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 57231 58604528 83 Linux

Can know by the above case, / dev / sda the disk, only one partition; the use of almost a hundred percent
we can see since / dev / hda of

[root@localhost beinan]# fdisk -l /dev/hda

Try it yourself?
We can also: cat / proc / partitions to see the current machine all disks and partitions case
df command from the coreutils package, it comes with the installation of the system; we can view disk usage and file system are linked by this command the position of the carrier, e.g.

[beinan the root @ localhost] # DF -LH
the Filesystem capacity has been available with a mount point%
/ dev / hda8 11G 6.0G 4.4G 58% /
/ dev / SHM 236M 236M 0 0% / dev / SHM
/ dev / sda1 56G 22G 35G 39% / mnt / sda1

From which we can see, the system installed in the / dev / hda8; there is a 56G disk partition / dev / sda1 mounted on / mnt / sda1 in
other parameters, please refer to man df

By studying these two aspects, I believe that for beginners, advanced Linux partition is no longer a stumbling block in the

Guess you like

Origin www.cnblogs.com/xxwang1018/p/11546688.html