How to Use the Linux partition Tool

Source: Internet
Author: User
Article Title: How to Use the Linux partition tool. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Installing Linux is the first threshold for beginners. In this process, the biggest confusion is to partition the hard disk. Although Linux of various Release versions already provides a friendly graphic interaction interface, many people still feel unable to start. The main reason for this is that you are not clear about Linux's Partition Rules, and how to use the most effective partition tool Fdisk below. We will start from these two aspects to explain the problem that has plagued everyone.
  
   Linux Partition Rules
1. device management
  
In Linux, each hardware device is mapped to a system file, which is no exception for hard drives, optical drives, and other IDE or SCSI devices.
  
Linux allocates a file consisting of hd prefixes to various IDE devices, while a file consisting of sd prefixes to various SCSI devices. For example, for the first IDE device, Linux is defined as hda; for the second IDE device, hdb; and so on. The SCSI devices should be sda, sdb, and sdc.
  
2. Number of partitions
  
To partition, you must operate on each hardware device. This may be an IDE hard disk or a SCSI hard disk. For each hard disk (IDE or SCSI) device, Linux assigns a serial number ranging from 1 to 16, which indicates the Partition Number on the hard disk. For example, the first partition of the first IDE Hard Disk maps hda1 in Linux, and the second partition is called hda2. For SCSI hard disks, such as sda1 and sdb1.
  
3. Functions of each partition
  
In Linux, it is stipulated that each hard disk device can have a maximum of four primary partitions (including the extended partition). Any extended partition must occupy one primary Partition Number, that is, in a hard disk, there are a maximum of four primary and extended partitions. For earlier DOS and Windows (versions earlier than Windows 2000), the system recognizes only one primary partition. You can add a logical drive letter (logical partition) to the extended partition, further refine the partition.
  
A primary partition is used by a computer to start the operating system. Therefore, the boot of each operating system, or a boot program, should be stored in the primary partition. This is the biggest difference between primary and extended partitions and logical partitions. This is the best example when we specify the bootloader for Linux installation and boot on the primary partition.
  
Linux requires that the primary partition (or extended partition) occupies the first four numbers from 1 to 16. Taking the first IDE hard disk as an example, the primary partition (or extended partition) occupies hda1, hda2, hda3, and hda4, while the logical partition occupies 12 numbers from hda5 to hda16. Therefore, each Hard Disk in Linux has a total of 16 partitions.
  
For logical partitions, Linux requires that they must be built on extended partitions (also in DOS and Windows systems), rather than on the primary partition. Therefore, we can see that the extended partition provides a more flexible partition mode, but it cannot be used as a boot for the operating system.
  
Apart from the differences between the above partitions, we can simply treat them equally.
  
5. Partition indicators
  
For each Linux partition, the partition size and type are the most important indicators. The size of the capacity is easy to understand, but the partition type is not so easy to accept. The partition type specifies the format of the file system above the partition. Linux supports a variety of File System formats, including our familiar FAT32, FAT16, NTFS, HP-UX, and a variety of Linux Native and Linux Swap partition types. In Linux, you can use the partition type number to differentiate these partitions. Various types of numbers will be introduced when introducing the usage of Fdisk.
  
   Fdisk Usage Details
The following describes how to use Fdisk to consolidate the knowledge about Linux partitions.
  
Fdisk is the most commonly used partition tool in various Linux releases and is defined as an Expert-level partition tool, which makes beginners a little discouraged.
  
1. Fdisk parameter description
  
When running Fdisk, the welcome interface shown in Figure 1 is displayed first. You can operate Fdisk by entering command parameters in this interface.
    
   Fdisk welcome page
Enter "m" as prompted to display the description of each parameter of the Fdisk command.
  
You can see that Fdisk has many parameters, but it is often used. If you are familiar with these parameters, You can smoothly use Fdisk to partition Linux hard disks. First, we will briefly introduce the meaning of each parameter, and then describe several key parameters in detail, as shown in table 1.
  
Table 1 Fdisk parameter description
  
When users partition in Linux, the most common parameters are d, l, m, n, p, q, t, w, etc.
  
2. Use Fdisk for partitioning
  
In the Linux partition process, the p parameter is usually used to display the hard disk partition table information, and then the future partition is determined based on the information. 2.
    
   Show existing Partition
Displays the partition size and type. If you want to completely change the partition format of the hard disk, you can use the d parameter to delete the existing hard disk partitions one by one. For example, d1 and d2.
  
After deletion, you can use the n parameter to add a new partition. After pressing "n", we can see the new partition shown in.
    
   Add Partition
Select the new partition type, primary partition or extended partition, and then select p or e. Their differences are described above. Then, set the partition size. Note that if there are extended partitions on the hard disk, you can only add logical partitions but not extended partitions, as shown in figure 4.
    
   Add logical Partition
When a partition is added, its type is the default Linux Native. If you need to change some of the partitions to other types, such as Linux Swap or FAT32, you can use the command t to change them, 5.
    
   Convert partition type
When you press "t" to change the partition type, the system will prompt Which partition you want to change and why (if you want to know the partition type supported by the system, type l ). Indicates to change the partition 5 type to the Swap type of No. 82 Linux.
  
For details about the partition type numbers supported by Linux and their corresponding partition types, refer to Table 2 (these information can be obtained by using the l command ).
  
   Table 2 partition type table
  
After changing the partition type, you can press "w" to save and exit. If you do not want to save it, you can select "q" to exit.
  
Through the above two aspects of learning, I believe that for beginners, partition is no longer a stumbling block in the Linux advanced.
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.