- Nikhil Bhaskar
- July 2, 2021
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.
Open Disk storage.
parted /dev/sda
Here is the command output.
Create a Partition table.
(parted) mklabel gpt or msdos
Type yes.
Here is the command output.
Check Partition Table.
(parted) print
Here is the command output.
Create Partition & Check Partition Table.
(parted)mkpart primary ext4 0 1396MB
(parted) print
Here is the command output.
Exit from disk storage.
(parted) quit
Here is the command output.
Method2:
Partition a Disk Using fdisk Command
List Partitions
fdisk -l
Here is the command output.
Select Storage Disk.
fdisk /dev/sdb
Here is the command output.
Create a New Partition.
- Create a new partition type n.
Command (m for help): n
Here is the command output.
List New Partition table.
Command (m for help): p
Here is the command output.
Save the changes.
Command (m for help): w
Here is the command output.
Activate the Partitions.
mkfs.ext4 -F /dev/sdb1
mkfs.ext4 -F /dev/sdb2
Here is the command output.
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