In Linux CentOS 7, Create A Disc Partition

by | Feb 17, 2023 | Uncategorized

In Linux CentOS 7, all that is required to create a disc partition is to format the system drive. Briefly, disc A disc is partitioned when it is split into one or more regions, or “partitions.” So, the disc must retain the details of a newly created partition, including its position and size. The partition table, which is typically found in the first sector of a disc, is where this information is kept.

Because you cannot begin writing files to an empty disc, we must establish a partition. The disc must have at least one file system-containing partition. You can create a partition with all the available disc space or, for simplicity of use, divide the space into 20 separate partitions. The disc must, in any case, have at least one partition.

The Necessity for Disk Partitioning

  • Hard Disk upgrade (to include a new Hard Disk to the system)
  • A dual boot (Multiple Operating Systems on the same machine)
  • effectively managing the disc
  • Ensure security and backup.
  • Use the same mechanism to work with many file systems.

Listing Disk In CentOS 7 Linux

Let’s first list the attached discs to the system before continuing. This will assist you in deciding which disc you wish to create a partition on. Execute the following command in a terminal with root access to list every disc that is currently installed.


# fdisk -l     ##fdisk is a linux tool that is used to configure disk partition table


The result displayed shows the partition tables for all attached discs. The sda1 partition, which contains the necessary boot components for Linux, is located on Disk 1/dev/sda. The LVM information for root and swap is located on the later sda2 partition. The report only displays disc information because discs 1 and 2 are the only ones that do not currently have any partitions.

Choosing The Disc To Be Partitioned

In this instance, we’ll choose Disk 2 to build the partition on. To choose the disc, use the command specified in the console. The disc is designated as /dev/sdb for the system.


# fdisk /dev/sdb


The result indicates that the selected disc is awaiting a command. Also, it demonstrates that since there are no partitions, the disc now lacks a partition table. Additionally, it demonstrates that any modifications made to the disc partition remain in memory until they are written to or saved.

Creating A Disk Partition

In the command line, type n to create a new partition. We are prompted to choose the partition type in the output. We’ll make a major section for /dev/sdb in this case. While it can be used to boot various operating systems, we will choose the primary partition type as the default one for this example. While the primary partition can be booted, the expanded partition cannot.

Then, there is the First Sector, which refers to the starting track of the partition. You can select any value in the range 2048-41943039, but we are selecting the default value 2048 by leaving the input blank. Enter p to choose the partition type as primary. Next, choose the partition number as 1, or leave it blank and the system will name it appropriately. Enter the Final Sector at the end to complete the disk’s partition memory allocation.Any number can be chosen depending on the size of the disc. Provide the size using the format +size (K, M, G). For instance, the input command will be +15G if you want to size the partition to 15 Gb. Type the command and hit the Enter key. This will generate partition 1 with a 15GB size.

Save the modifications to the partition table.

Type the command w and hit Enter to write the modifications to disc. We can see that the partition table has been changed, and that the ioctl control device is being used to re-read the partition table and sync it to the currently installed disc.

Conclusion

To view the revised partition table, issue the fdisk -l command once more. The output will demonstrate that the /dev/sdb disc now has a new partition. The freshly made partition is identified as /dev/sdb1.

Read Our Next Articles How to Use the Nginx Web Server to Host Several Websites