How to Create a Disk Partitions in Linux.

In Linux,we can create disk partitions,is also useful when we are installing multiple operating systems on a single machine.We can create and delete partitions in Linux.It is a practice because hard drives & USB drives must be structured in some way before they can be used. Large storage devices are divided into multiple parts/sections called partitions.

Prerequisite

  • When we create disk partitions,we have sudo or root privileges.

Create a Disk Partitions

List Partitions

  • Before Creating a partition,list available storage devices and partitions.
parted -l

Here is the command output.

 

Fig 1

Open Disk storage.

parted /dev/sda

Here is the command output.

 

Fig 2

Create a Partition table.

(parted) mklabel gpt or msdos

Type yes.

Here is the command output.

 

Fig. 4

Check Partition Table.

 

(parted) print

Here is the command output.

 

Fig. 5

Create Partition & Check Partition Table.

(parted)mkpart primary ext4 0 1396MB
(parted) print

Here is the command output.

 

Fig. 6

Exit from disk storage.

 

(parted) quit

Here is the command output.

 

Fig. 7

 

Method2:

Partition a Disk Using fdisk Command

 List Partitions

fdisk -l

Here is the command output.

 

Fig. 7

Select Storage Disk.

fdisk /dev/sdb

Here is the command output.

 

Fig. 8

Create a New Partition.

  • Create a new partition type n.
Command (m for help): n

Here is the command output.

 

Fig 10

List New Partition table.

Command (m for help): p

Here is the command output.

 

Fig 11

Save the changes.

Command (m for help): w

Here is the command output.

 

Fig 12

Activate the Partitions.

 

mkfs.ext4 -F /dev/sdb1
mkfs.ext4 -F /dev/sdb2

Here is the command output.

 

Fig 12

Format the Partition.

 

mkfs -t ext4 /dev/sdb1

Create the mount points.

 

 mkdir -p /mnt/mountpoint1 /mnt/mountpoint2

Mount the new partition.

 

mount /dev/sdb1 /mnt/mountpoint1
mount /dev/sdb2 /mnt/mountpoint2

 

 

Leave a Reply

Your email address will not be published.