How to Create a Disk Partitions in Linux

In order to effectively use storage devices such as hard drives and USB drives on your computer, you need to understand and know how to structure them before using in Linux. In most cases, big storage devices are split into separate portions called partitions.

Partitioning enables you to split your hard drive into multiple parts, where each part acts as its own hard drive and this is useful when you are installing multiple operating systems in the same machine.

In this article, we will explain how to partition a storage disk in Linux systems such as CentOS, RHEL, Fedora, Debian and Ubuntu distributions.

Creating a Disk Partition in Linux

In this section, we will explain how to partition a storage disk in Linux using the parted command.

The first step is to view the partition table or layout on all block devices. This helps you identify the storage device you want to partition. You can do this using parted or fdisk command. We will use the former for purposes of demonstration, as follows, where the -l flag means list partition layout on all block devices.

# parted -l
List Partitions in Linux

List Partitions in Linux

From the output of the above command, there are two hard disks attached to the test system, the first is /dev/sda and the second is /dev/sdb.

In this case, we want to partition hard disk /dev/sdb. To manipulate disk partitions, open the hard disk to start working on it, as shown.

# parted /dev/sdb

At the parted prompt, make a partition table by running mklabel msdos or gpt, then enter Y/es to accept it.

(parted) mklabel msdos
Make Disk Label

Make Disk Label

Important: Make sure to specify the correct device for partition in the command. If you run parted command without a partition device name, it will randomly pick a storage device to modify.

Next, create a new primary partition on the hard disk and print the partition table as shown.

(parted) mkpart primary ext4 0 10024MB 
(parted) print 
Create Partition in Linux

Create Partition in Linux

You can create another partition for the reaming space as shown.

(parted) mkpart primary ext4 10.0GB 17.24GB
(parted) print 
Create Another Partition

Create Another Partition

To quit, issue the quit command and all changes are automatically saved.

Next, create the file system type on each partition, you can use the mkfs utility (replace ext4 with the file system type you wish to use).

# mkfs.ext4 /dev/sdb1
# mkfs.ext4 /dev/sdb2
Create Filesystem Type on Partition

Create Filesystem Type on Partition

Last but not least, to access the storage space on the partitions, you need to mount them by creating the mount points and mount the partitions as follows.

# mkdir -p /mnt/sdb1
# mkdir -p /mnt/sdb2
# mount -t auto /dev/sdb1 /mnt/sdb1
# mount -t auto /dev/sdb2 /mnt/sdb2

To check if the partitions are actually mounted, run the df command to report file system disk space usage.

# df -hT
Check Partitions Disk Space Usage

Check Partitions Disk Space Usage

Important: You may need to update /etc/fstab file to mount newly created partitions automatically at boot time.

You might also like to read these following related articles:

  1. 9 Tools to Monitor Linux Disk Partitions and Usage in Linux
  2. How to Backup or Clone Linux Partitions Using ‘cat’ Command
  3. 8 Linux ‘Parted’ Commands to Create, Resize and Rescue Disk Partitions
  4. How to Repair and Defragment Linux System Partitions and Directories
  5. How to Clone a Partition or Hard drive in Linux
  6. How to Add a New Disk to an Existing Linux Server
  7. Top 6 Partition Managers (CLI + GUI) for Linux

That’s all! In this article, we have shown how to partition a storage disk, create a file system type on a partition and mount it in Linux systems. You can ask questions or share you thoughts with us via the comment form below.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Aaron Kili

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

1 Response

  1. Jim says:

    Or just use Gparted, a great graphical program that is very easy to use.

Got something to say? Join the discussion.

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.