Detailed explanation of Linux disk partition (fdisk)

1. What is a partition?

Partitioning is to divide a hard disk drive into several logical drives, which can treat contiguous blocks of the hard disk as an independent disk.

 2. Why should there be multiple partitions?

◇  Prevent data loss: If the system has only one partition, if this partition is damaged, the user will lose all the data.

◇  Increase the efficiency of disk space usage: you can format partitions with different block sizes. If there are many 1K files and the disk partition block size is 4K, then every file stored will waste 3K space. At this time, we need to take the average of these file sizes to divide the block size.

◇When the data surges to the limit, it causes the system to hang: Separating the user data from the system data can prevent the user data from filling up the entire disk and causing the system to hang.

3. Partitioning, formatting and mounting of Linux disks

◇ The fdisk -l command can see all disks:

You can see that /dev/sdc is not partitioned yet, let's try partitioning it. First execute fdisk /dev/sdc:

Enter n to create a new partition

   Enter p to create a raw partition

   This area is numbered as 1 when entering 1 form

   Entering carriage return means that this area starts from the default starting cylinder number

   Enter a carriage return/or size to indicate that this area ends with the default/or entered size

   Enter w to save

◇After the partition is completed, fdisk -l can see it:

Next format the partition and execute mkfs.ext4 /dev/sdc1:

Then mount it:

Finally open the /etc/fstab file, set it to automatically mount at boot, and save it and it will be OK:

Last check, the mounting is successful:

In the next section, we will talk about how to partition a disk with a size of 2TB or more. Goodbye~

 

 

Guess you like

Origin blog.csdn.net/wxt_hillwill/article/details/103872879