Add hard disk partitions in linux

Source: Internet
Author: User

In RHEL5 Linux, the command line fdisk partition:

1. Here we will first talk about the linux partition format. The linux partition is different from that of windows. The hard disk device name in linux (the hard disk name in IDE is hdx (x is from a-d), because the maximum number of IDE hard disks is four, SCSI, SATA, and USB hard disks are sdx (x is a-z), and the primary partition of the hard disk is up to four. Needless to say, everyone knows that ..... Therefore, the primary partition starts from sdb1 to sdb4, and the logical partition starts from sdb5 (the logical partition always starts from sdb5 ...) You can use fdisk-l for device names.

 

 

2. Insert a USB flash drive (formatted first) into the VM and enter fdisk-l to view all hard disk partition tables ,...

 

 

 

 

 

 

 

 

 

 

Because there are two hard disks, the first one is installed with the system. We need to see the information of the second hard disk ,...

 

 

 

 

 

 

This is the information of the second hard disk. disk/dev/sdb: 42.9 GB, 42949672960 bytes, indicating that the hard disk type is scsi or sata, And the size is 40 GB...

3. Input fdisk/dev/sdb to partition the hard disk ,...

 

 

 

 

 

 

Enter n and press enter to create a partition. Enter p and press enter to create a primary partition ,...

 

 

 

 

 

 

 

First cylinder (2824-10443, default 2824...

 

Last cylinder or + size or + sizeM or + sizeK (2824-10443, default 10443): (this step is to set the end of the shard. + 5G indicates that the end of the Shard is 5 GB after the start of the shard, it is also to set the partition size, + 5G is to set the size to 5G) Input + 5G and then press enter ,...

 

Enter t and press enter (enter t and press enter to change the partition file system type. If you do not know which partition file system types are available, enter l and press enter to display them ,), enter the Partition Number 1 and press enter (four primary partitions in total, because the partition file system type is set for the first primary partition, So input 1 ), enter the code before the partition file system type (the code before the type represents that type, so enter the code) Enter 83 here. The default system is the linux partition system type, that is, the 83 type, therefore, if the file system is ext2 or ext3, you do not need to enter t to select the file system type. For this reason, you can use t to modify the file system type (83 indicates the ext2 and ext3 file system types ),...

 

 

 

 

 

 

 

Enter n and press enter to create a partition. Enter e and press enter to create an extended partition. Enter 2 and press enter to set the start cylindrical column. Press enter to select the default value. Set the size and press enter to distribute all partitions to the extended partition ,...

 

 

 

 

 

 

 

 

 

 

 

Enter n and press enter to create a partition. Enter l and press enter to create a logical partition. Set the start cylindrical column. Press enter to select the default value. Set the partition size and press ENTER + 10g, enter t press enter to set the partition file system type, enter number 5 to represent partition 5 Press enter, enter 83 press enter to set the file system type to linux (ext2, ext3 )...

 

Enter n press enter to create a partition, enter l press enter to create a logical partition, set start cylindrical press enter to select default, Set Partition size input + 10g press enter, enter t press enter to Set Partition file system type, enter the number 6 to represent partition 6, press enter, and enter c to press enter to set the file system type to fat32 (fat16, fat32 collectively referred to as vfat ),...

Enter n press enter to create a partition, enter l press enter to create a logical partition, set start cylindrical press enter to select default, Set Partition size input + 13g press enter, enter t press enter to Set Partition file system type, enter the number 7 to represent partition 7, and enter 83 to represent the linux File System type ......

Then enter n to create a partition, enter l to press enter to create a logical partition, set the start cylindrical column, press enter to select the default value, set the partition size, and press enter to allocate all the remaining 2G Capacity to it, input t to set the partition file system type. Input 8 to represent the partition 8 and press Enter. Input 82 (representing the swap partition swap) to set the file system type to the swap partition. Press enter...

Enter a to activate the primary partition and press Enter. Enter the primary Partition Number 1 and press Enter ,...

 

 

 

 

Enter w (write Partition Table, equivalent to executing PM partition) and press enter ,...

 

 

 

 

 

 

 

 

 

 

 

 

 

 

After the partition is completed, run fdisk-l to view the partition table. The result is as follows...

 

 

 

 

 

 

 

Next, format the file system and create a file system ....

Enter mkfs. ext3/dev/sdb1 and press enter to format sdb1 into ext3 format ,...

Enter mkfs. ext3/dev/sdb5 and press enter to format sdb5 into ext3 format...

Enter mkfs. vfat/dev/sdb6 and press enter to format sdb6 into fat32 format ,...

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Enter mkfs. ext2/dev/sdb7 and press enter to format sdb7 into ext2 format...

Enter mkswap/dev/sdb8 and press enter to create a swap file system on the sdb8 partition ,...

 

 

 

 

 

The partition is formatted, that is, the file system is created here ....

The fdisk command is used to partition the hard disk. The following describes the parameter explanations of the fdisk, mkfs, and mkswap commands ....

Fdisk command details:

M: get help

N: Create a partition.

P: Display partition tables

D: delete a partition.

B: Set the volume label

W: Write Partition Table

T: Change the partition file system type.

V: Test Partition

L: displays the file system code supported by fdisk.

Q: Exit

File System creation:

Mkfs parameter partitioning

-T file system type: specifies the type of the created file system.

Note: mkfs-t ext3 = mkfs. ext3

-C check whether there is any bad track before establishing the File System

-L file name: When a bad track is read from the file

-V: display details

Mkswap partitions create swap partitions on the partitions

For example, the command to create a swap partition on sdb8 is as follows:

Mkswap dev/sdb8

The revolution has not yet succeeded. comrades still need to work hard. Come on !!!

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.