Disk Partitioning in Linux (original) (raw)

Last Updated : 23 Jan, 2026

Disk Partitioning is the process of dividing a disk into one or more logical areas, often known as partitions, on which the user can work separately. Disk Partitioning is used for:​

How to Partition Disks in Linux?

In order to successfully partition a disk and to make it useful, we need to ensure that we have completed the below four steps, regardless of the Operating system and Hardware of the system:​

  1. Attach the disk to the proper port​
  2. Create partitions in the disk​
  3. Create a file system on the partition​
  4. Mounting the file systems​

1. Attaching the Disk

It is clearly specified that the system has only 20 GB of Hard Disk. After installing the necessary software and downloading some movies, I found that the system Hard Disk is almost completely used up.​

Now I will have two options in front of me, either buy a new system with a higher Hard Disk capacity or upgrade the existing one. Most of you will go for the second option, just like me, unless the system is very old. Let us upgrade the system with an additional 20 GB of Hard Disk.​

Adding a New Virtual Hard Disk in VMware

**Step 1: Open Virtual Machine Settings

Initial configuration of my system

**Step 2: Start the Add Hardware Wizard

Attaching Disk:

Attaching Disk

**Step 3: Select Hard Disk as Device Type

Type of hardware to install

Type of hardware to install

**Step 4: Choose the Disk Type

Select a Disk Type

Select a Disk Type

**Step 5: Create a New Virtual Disk

**Step 6: Specify Disk Size

After attaching the new virtual Hard Disk

After attaching the new virtual Hard Disk

**Step 7: Finish

2. Create Partitions in the Disk

Power on the system and log in to the system. Ensure that you are logged in as **root (or any user of the sudo group). Once the system UI comes up, open the **Terminal****.** To view the available Hard Disks in our system, use the command lsblk or cat /proc/partitions. Both commands will display the same results, but in different ways.

lsblk

Create partitions in the disk

Create partitions in the disk

fdisk -l

fdisk -l

fdisk -l

fdisk /dev/sdb

m -> help
p -> print partition table
n -> create new partition
d -> delete partition
q -> quit without writing
w -> write to disk

While partitioning, we should be aware of certain factors.

fdisk /dev/sdb

fdisk /dev/sdb

This will create a new partition. Specify the type of partition using the **p for primary and **e for extended.

**p

You can specify the size of the partition in two ways, either as the last cylinder number or by specifying the size directly. If we need partition1 to be of 4 GB size (as a whole number), use.

+4G

Pressing **enter will create our 1st partition successfully. Follow the same steps, until we create 4 partitions on our newly attached disk.

create our 1st partition successfully

create our 1st partition successfully

3. Create a File System on the Partition

Linux uses file systems like ext4, ext3, XFS, and FAT to organize and store data on disks. Use the mkfs (make file system) command to format partitions with your chosen file system.​

**Format partition to ext4 with journaling:

mkfs.ext4 -j /dev/sdb1

**Format partition to FAT:

mkfs.ext4 -j /dev/sdb1

Create a file system on the partition

Create a file system on the partition

4. Mounting the file systems

**Step 1: Create Mount Directories
Create three directories to serve as mount points for the three partitions using the mkdir command.

**mkdir /mount1
**mkdir /mount2
**mkdir /mount3

Each directory will act as an access point to connect the formatted partitions.​

**Step 2: Mount the Partitions
Use the mount command to attach each partition to its respective directory.​

**mount /dev/sdb1 /mount1
**mount /dev/sdb2 /mount2
**mount /dev/sdb3 /mount3

mount [device] [mount_point]

**Step 3: View Mounted Disks
Use the df -h command to display disk usage in human-readable format.​

**df -h

Mounting the file systems

Mounting the file systems

Step 4: Mounting the File Systems

Create Mount Directories

Create three directories to serve as mount points for the three partitions using the mkdir command

unmount /dev/sdb2

All these mountains are temporary in nature. Once we reboot the system, mounting will be reverted. To make it permanent, we must edit the File System Table of the Operating System.

**vi /etc/fstab

fstab(File System Table) file

fstab(File System Table) file

**Step 5: Add our mounted file systems' details in the file, in the order.

**mounted partition [ space ] **directory [ space ] file system type [ space ] **defaults [ space ] **0 [ space ] 0

Save the file and come back to the terminal. Mount the partitions permanently using the **mount -a command

**mount -a

Mounting the file systems

Mounting the file systems

Verification

We can verify whether our partitions are available for our purposes by visiting the root folder of the Operating System (since we have mounted the partitions on the mount1, mount2, mount3 directories in the root folder).​

We can also verify the existence of our newly created partitions using the lsblk command.

**lsblk

We can find our partitions in the table, each of 4 GB size.

lsblk

lsblk