HOW WE CAN CREATE A PARTITION AND FILESYSTEM ON THE NEWLY INSATLLED DRIVE IN LINUX ?

 


Today, In this article we are going to learn some Linux Command line utilities to create a Partition and Filesystem on the newly installed drive/disk ?

So, let us first understand why we need to create a partition .

Partitioning a disk/drive provides the user a advantage to split the disk into several blocks of spaces where they can store different programs or any data of their choice.
  So, if their is any crash or issue in one of the partition then their will be no any effects on other because each partition acts as a separate hardrive.  

How we can create a partition through command line?
Generally, there are several command line utilities to create a partition in linux but today we will be looking at cfdsik command which is easier to use and also user-friendly for beginners.

Before partitioning the disk or drive we need to make sure to check the drives available on our system.    

   To-do so, we need to type:

  • sudo fdisk -l 

  

After we specify the command, the terminal will prompt us several results and will show different drives and their respective names. In linux every drive has it's one unique name so, we need to be sure which drive are we going to make partition . So, for this example I will be going with /dev/sdc which you can see in the bottom of the above screenshot.

Note: Your Drive name can be different. So, you need to make sure which drive you are going to use

Now, after we have checked all the drives present in our system then it's time to create a partition on it.

  To do so, we need to type:

  • sudo cfdsik /dev/sdc  

After we type the cfdisk command and pass the drive name(/dev/sdc) with it the terminal will now show us different types of partition that we can create on it.So, you can select one of them. In this example i have selected dos. 

Now , the terminal will show us:

Now, we simply need to select new and hit enter and again it will ask us the size of partition we can give for it.


In this scenario I have used 15.2 GB but you can give the size of your choice , it depends on How much space is available in your drive?
 
After we specify the size and hit enter terminal will show us:

The terminal has asked whether we want to create primary partition or extended because as i have already specified i am using MBR Partition for this scenario but if you are going with GPT Partition then it will not ask you anything.

The common difference between MBR and GPT Partition is that we can create only 4 partition table in MBR whereas in GPT we can create upto 128 partition table on our hardrive.
To know more about it you can visit this link:

So, In this example, we will select Primary and after we select primary we need to save all those changes we made by selecting the write option as you can see in the screen:


After we select the write option and save all those changes now the terminal will ask to re-verify whether we are sure or not:


Now, we need to type yes to verify the changes made in the drive, after it we can simply quit from this window by selecting the quit option:


Congratulations, now we have created a partition in our /dev/sdc/ drive. So, if you want to be sure whether we have created the partition successfully or not we can type fdisk -l /dev/sdc  in terminal again:

As, you can see in the terminal there is a newly device called /dev/sdc1 of size 15.2 GB which means we have successfully created a partition.

After we created a Partition on our hardrive. Now, it's time to create a new filesystem on it. so, if we don't create any filesystem in our newly partition drive then the drive will be non-usable because we can't store any data or information on it.

  To Create a file system we need to type:

  • sudo mkfs.vfat -n 'BACKUP' /dev/sdc1

Above command illustrate that we are creating a fat32 file system on our newly drive which is /dev/sdc1 and the name we have given for this drive is 'BACKUP'.

Now we are ready to use this drive. 

Note: If you want to know what type of filesystem are supported in your system you can simply type man mkfs in your terminal. 

Thankyou,
Author - Saroj Khadka

 

Follow us on:





Comments