Linux disk partition fdisk command details

Source: Internet
Author: User

Original article link

1. What is a partition?
Partitioning refers to dividing a hard drive into several logical drives, and partitioning refers to using the continuous blocks of the hard disk as an independent hard disk. A partition table is an index of a hard disk partition. The partition information is written into the partition table.
2. Why multiple partitions?

    • Prevent data loss: if the system only has one partition, the partition is damaged and all data is lost.
    • Increase the efficiency of disk space usage: You can use different block sizes to format partitions. If there are many 1 K files, and the size of the Hard Disk Partition Block is 4 K, therefore, each stored file will waste 3 K space. At this time, we need to take the average value of these file sizes to divide the block size.
    • Data surges to the limit will not cause system suspension: separating user data from system data can prevent user data from filling up the entire hard disk, resulting in system suspension.

3. usage of the partitioning tool fdisk
Fdisk Command Parameters
P. Print the partition table.
N. Create a New partition.
D. delete a partition.
Q. Exit and do not save.
W. Write the partition into the partition table, save and exit.
Instance:
[Root @ localhost ~] # Fdisk/dev/HDD

Press "p" to print the Partition Table

This hard disk has not been partitioned
Press "N" to create a partition.

Two menu e is displayed, indicating the extended partition, and P is indicating the primary partition.
Press the "P" key. The following message is displayed: "Partition Number (1-4):" select the primary Partition Number.
Enter "1" to indicate the first primary partition.

Press enter to start partitioning on the 1-axis.

The last cylinder or size is displayed.
Enter + 5620 m and press ENTER
The first partition is 5 GB space.
Click "p" to view the partition

Such a primary partition can be split.
Next, divide the second primary partition and allocate the remaining space to the Second Primary partition.
Press "N"
Key to add a partition
Press the "P" key to set as the primary partition.
Enter "2" to set the primary Partition Number to 2
Press twice and press enter to distribute the remaining space to the Second Primary partition.
Press "p" to print the Partition Table

Press "W" to save and exit.
Readers can divide Appropriate Partitions based on their hard disk sizes.

4. Use partitions
Before using a hard disk, you must format and mount the partition.
[Root @ localhost ~] # Mkfs. ext3/dev/hdd1
[Root @ localhost ~] # Mkfs. ext3/dev/hdd2
Create a mount directory
[Root @ localhost ~] # Mkdir/hdd1/hdd2
Mount/dev/hdd1/dev/hdd2
[Root @ localhost ~] # Mount/dev/hdd1/hdd1
[Root @ localhost ~] # Mount/dev/hdd2/hdd2
View
[Root @ localhost ~] # DF-H
Filesystem size used avail use % mounted on
/Dev/hda3 7.5g 2.8g 4.3g 40%/
/Dev/hda1 99 m 17 m 78 M 18%/boot
Tmpfs 62 M 0 62 m 0%/dev/SHM
/Dev/hdd1 2.5g 68 m 2.3g 3%/hdd1
/Dev/hdd2 2.5g 68 m 2.3g 3%/hdd2

Now write data to the/hdd1 directory and store it to the/dev/HDD hard disk.

 

LinuxAutomaticMount a file/Etc/fstab

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.