Disk Partition in Centos 7

Disk Partition in Centos 7

HOW TO CREATE DISK PARTITION ON CENTOS 7

In the following steps I will show you how to create partitions in Centos 7 with fdisk command.

1. Specify the disk device to create the partition.

Here I am using the utility fdisk to create a new partition. First find the name of the device and use fdisk command like this.

The syntax is fdisk <hard-disk> and hit enter.

# fdisk /dev/sda

After hitting enter it will ask you commands to create partitions.

2. Request a new primary or extended partitions

Enter ‘n’ to request a new partition and hit enter. In the next step it will ask you to specify whether the partition should be created a primary or extended partition. The default selection is primary partition type.

Command (m for help): n

Partition type:

p primary (2 primary, 0 extended, 2 free)

e extended

Select (default p):

3. Select the size of partition

In this step it will ask you a partition number, enter 1 or don’t enter anything, just you can hit enter it will take 1 as default. Next it will ask you first sector value, here also just hit enter or don’t enter any values, by default it will take 2048.

In the next step it will ask you last sector size. Here you can mention the size of our partition. I am choosing 20 gb partition, for that I need to enter +20G.

The syntax is +numberG

If you want more size you can choose as your wish.

Partition number (1-4, default 1):

First sector (2048-41943039, default 2048):

Using default value 2048

Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039):

Using default value 41943039

Partition 1 of type Linux and of size 20 GiB is set

4. Verifying the partitions

To verify the partitions created or not by typing p and hit enter. It will show you all partitions in your hard drive. Here my hard drive is /dev/sda. Just now we have created one new partition, you can see new partition /dev/sda1.

Command (m for help): p

Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk label type: dos

Disk identifier: 0x0008c000

Device Boot Start End Blocks Id System

/dev/sda1 2048 41943039 20970496 83 Linux

5. Save the created partition.

We have created the partition, but it is not saved for that we need to enter w command. So type w and hit enter. Now we have successfully created partition /dev/sda1 in hard drive /dev/sda.

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

6. Partprobe

Partprobe command informs the OS kernel to re read the partitions in hard drive. Then our newly created partitions will become active.

The syntax of partprobe is,

partprobe <hard-drive>

partprobe /dev/sda

7. Reboot

After completing all the above steps, you can reboot your machine. So you can only visible the partitions.

To reboot your machine you can use the command below.

reboot

 

 

 

Leave a Comment

Your email address will not be published. Required fields are marked *