How to Create a Disk Partitions in Linux

How to Create a Disk Partitions in Linux.

    For using the storage devices more effectively such as hard drives. you need to understand how to structure them before using it in Linux. big storage devices are split into separate portions called partitions.

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

# parted -l



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

 

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 show.

 

(parted) mkpart primary ext4 0 10024MB

(parted) print



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



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
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Port 25 unblock

Port 25 in VCCLHOSTING  is blocked by default. If you need to send out email , you can follow...

Setup Exim to Send Email Using Gmail in Debian

Setup Exim to Send Email Using Gmail in Debian Install Exim4 apt-get install exim4...

How to Secure FreeBSD with PF Firewall

This tutorial will show you how to protect your FreeBSD server using OpenBSD PF firewall. We will...

Configuring IPv6 on your VPS

All these examples assume an IPv6 subnet of 2001:DB8:1000::/64. You'll need to update them with...

Add a Secondary IPv4 Address to Your VPS

This tutorial explains how to setup an additional IPv4 address on your KVM VPS. We will assume...