Fdisk
Fdisk is the command line utility in linux systems which is used to manage partitions in linux using the CLI commands and it is one of the most popular tool for managing partitions by the linux administrators.
Replace the xxx
with the target partition which we are about to change
Here is the basic manual of fdisk utility :
Use-Case 1 : Creating the partition using fdisk in ubuntu
Here we can see there are two physical disks allocated on the system sda & sdb
where the sda
partition is mounted as the main primary disk and OS is mounted on the 3 partitions on it. Now we will add the sdb
as the secondary partition on the linux.
We will enter the fdisk console with the target disk sdb
Type n
to create the new partition on the physical disk and select the primary option and then enter the partition number & pass the other parameters to keep the value default and make a primary partition of full disk.
Upon successful execution we can see that sdb1
is created with the volume size of 5G
and now we will format it as ext4
partition type to make it usable in linux
Now we will format this partition as ext4 using :
Type p
to check the current partition table the output should look like :
Now we will use the following command :
The ourput should look like :
Here we have successfully created the ext4 partition and the output should reflect in lsblk
Now we will need to mount the partition to make it usable , The steps to mount the partition is as follows :
Now we will mount the partition on the path we just created
Now the disk is mounted and we can confirm it using lsblk
There is a slight issue the partition mount will be lost in case the machine it restarted, to make it mounted on startup we will need to make following changes :
Last updated