How To Create New Partition in Linux
Creating new partition in linux a very normal practice. In this article we will be going to explain simple steps to create a new partition in linux, format it and mount it at your required mount point.
See Also:
List All Partition
lsblk command by default list all partition in a tree-like format. Run below command as follows:
# lsblk
The output is as follows:
[Or]
You can all use fdisk command to list all partition, use following command as follows:
# fdsik -l
The output is as follows:
Create New Partition
With the help of fdisk command we can create new partitions. Execute below command to create new partition.
# fdsik /dev/sdb
Type m and press Enter to see a list of the commands you can use to create partition.
Use the n command to create a new partition. You can create a logical or primary partition (l for logical or p for primary). A disk can only have four primary partitions.
Formatting a Partition
Before using the partition, you need to format new partitions with a file system. You can do this with mkfs command.
# mkfs.ext4 /dev/sdb1
Mount The Partition
You have successfully formatted the filesystem. Now you can mount the partition and use it.
Mount Temporary
# mount /dev/sda1 /mnt
Mount Permanent
You can mount the partition permanently adding entry in fstab file.
# vim /etc/fstab
Add below line at the end of file.
/dev/sda1 /mnt ext4 defaults 0 0
Run following command to mount the drive at run time.
# mount -a
Run below command to display new partition.
Enjoy it!