Partition of the hard disk under Linux:

Source: Internet
Author: User

Refer to the partition of the hard disk, formerly is very chaotic, what is the main partition/extended partition/logical partition, etc; what's the difference? Now a simple look;

Because in the MBR master boot record in the partition table can only record 4 partition records, this is not enough Ah, in order to solve this problem, it is allowed to create an extended partition, in the extended partition we can continue to partition (that is, logical partition), for example: we can create up to 4 primary partitions, When we want to create 6 partitions: We can create 3 primary partitions an extended partition, and then create 3 logical partitions within the extended partition;
In the master boot record, only the primary partition and the extended partition information are included, and the logical partition information is stored in the extended partition;

In Linux, it is represented by hd*x or sd*x, where * denotes a, B, c .... The number 1, 2, 3 ... x indicates that the HD is mostly an IDE hard disk; SD is mostly SCSI or removable storage, and the.

Learn a Linux partition tool, fdisk command;

Fdisk is a hard disk partitioning tool under Linux, but Fdisk can only partition partitions smaller than 2T;

Syntax: fdisk [-l] [device name]
When the-L is not followed by the device name, all disks and partition tables are listed, and when the device name is added, the partition table of the written device is listed;

For example, when not with the device name:

FDISK-lpartition3does not start on physical sector boundary. Disk/DEV/SDA:465.8GiB,500107862016bytes976773168sectorsunits:sectors of1* += +bytessector size (logical/physical): +Bytes/4096Bytesi/o Size (minimum/optimal):4096Bytes/4096Bytesdisklabel type:dosdisk Identifier:0xcef2688cDevice Boot Start End sectors Size Id Type/DEV/SDA1 *2048 960833535 960831488 458.2G theLinux/dev/sda2960835582 976771071  15935490   7.6G5Extended/dev/sda5960835584 976771071  15935488   7.6G theLinux Swap/Solaris

With the device name:

Fdisk-l/dev/sda:partition3does not start on physical sector boundary. Disk/DEV/SDA:465.8GiB,500107862016bytes976773168sectorsunits:sectors of1* += +bytessector size (logical/physical): +Bytes/4096Bytesi/o Size (minimum/optimal):4096Bytes/4096Bytesdisklabel type:dosdisk Identifier:0xcef2688cDevice Boot Start End sectors Size Id Type/DEV/SDA1 *2048 960833535 960831488 458.2G theLinux/dev/sda2960835582 976771071  15935490   7.6G5Extended/dev/sda5960835584 976771071  15935488   7.6G theLinux Swap/solaris

Because, we have a hard disk on the computer, so the results show the same;

When Fdisk does not add-l, it will enter another mode, at which time the disk can be partitioned operations;

Such as:

fdisk/dev/sdawelcome to fdisk (util2.25.  2inuntilwrite write to help):

At this point, press the M key, will come out the role of the various keys:

Help:dos (MBR) A toggle a bootable flag//set up an active partition, which can be used to boot the system;b Edit nested BSD disklabel C toggle the DOS compatibility flag Generic d Delete a partition//delete a partition;L list known partition types//display therefore partition type;n Add a new partition//create a new partition;P Print the partition table//displays a list of partitions;t change a partition type//change the type of partition; very powerful;v Verify the partition table Misc m print this menu//Display this Help menu;U Change display/entry units x extra functionality (experts only) Save&ExitW   WriteTable to disk and exit//change into the partition table, save the changes;Q Quit without saving changes//do not save the exit;Create a new label G create a new empty GPT partition Table G Create A new empty SGI (IRIX) partition table o Create a new empty DOS partition table s create a new empty Sun partition Tablecommand (M forHelp):

Commonly used in Chinese marked, and do not specify the points:
Type ' t ', change the partition flag (this is the most essential part of the Linux fdisk!), the newly created partition default flag is EXT2 (Linux), you can change it to the "FAT32" (Linux swap), or ' B ' (/F ') (FAT32 Extend, Extended partition only), ' * * ' (NTFS) ... And so on dozens of different types. This way, friends using multiple operating systems can use the Linux fdisk to partition all the partitions you want!
Type ' a ' to toggle the partition activation switch. Note: Each time you type, the selected partition will change between active and inactive, but you must ensure that only one partition is active at the end. At this point the ' P ' command is used, and the active partition will have a ' * ' number.
Type ' d ', delete the extended partition, if there is logical partition in the extended partition, the logical partition will also be removed;

In the partition, pay attention to see the English hints on it;
Let's go through the process:
(Add a process)

To format a partition of a disk:

After the partition is complete, the disk must be formatted for each partition before it can be used; the nature of the format of the disk:

Hard disk format, in fact, is the initialization process of the file system, the establishment of directory area and file allocation table, file system, that is, the file directory/folder and other data storage/management system; Windows typically uses ntfs,linux under EXT3 or Ext4. So, there is a file management system on each partition;

The following knowledge references (Http://www.apelearn.com/study_v2/chapter9.html#id2, Amin's Linuux teachings)

Command: MKE2FS, Mkfs.ext2, Mkfs.ext3, MKFS.EXT4:

When you query the Help documentation for these four commands with man, you will find that we see the same help document, which means that four commands are the same. MKE2FS Common options are:

2048 and 4096 bytes each block. '-i ' Set the inode size '-N ' to set the inode number, sometimes using the default inode number is not enough, so you have to set the inode number. '-C ' before formatting the disk to detect whether there is a problem, plus this option will be very slow '-L ' preset the label of the partition label '-J ' build ext3 format partition, if you use MKFS.EXT3 You don't have to add this option. The '-t ' is used to specify what type of file system, which can be ext2, ext3 can also be EXT4 per block.

So, remember that MKE2FS can do it; Mke2fs-t Ext2/ext3/ext4 is equivalent to MKFS.EXT2/MKFS.EXT3/MKFS.EXT4 command;

For example: [[email protected] ~]# mke2fs-t EXT4/DEV/SDB5

After formatting is complete, mount the disk:

Using the Mount command:
such as: Mount/dev/sda6/new_drir

To this, this disk can be used, complete!

Partition of the hard disk under Linux:

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.