FDisk Command in Linux














































FDisk Command in Linux



A disk is a storage device in a computer. A disk can be optical, magnetic, or optical. Disk partition is the process of dividing disk memory into two or more separate regions so that each region of memory can be managed separately. A partition table is a data structure that provides basic information about the division of the hard disk into primary partitions. 

Linux provides few commands which can be used to create and manipulate such disk partitions. 

 

1. fdisk - fdisk, also known as format disk, is a Linux command used for creating and manipulating the disk partition table. It is used to view, create, resize, remove, copy, and move partitions through the partition table. 

The basic syntax of the fdisk command is- 

 

  

The -l option is used to view all the information about the currently available partitions on the system. This option gives a detailed explanation of all the partitions currently on the hard disk. 


 

To view the information of a certain partition, the path of the partition from the root must be mentioned along with the -l command. For example, to see the partition on disk a, the following syntax is followed- 


 

To see all the commands available to use for a particular partition, the following command is used. 

 

 

At this point, the m key must be typed to view the list of commands that can be used for this particular partition. 

 

To create a new partition, first, the following command is written. 


 

After this command is executed, the command n is typed to tell the system that a new partition must be created. 

After that, one of the following two options must be typed- 

i. p - To create a primary partition (only 4 primary partitions can be created using the fdisk command) 

ii. e - To create a logical (or extended) partition 

After entering these options, the w command is typed to write the changes to the disk and reboot the system. 


 

To delete a partition, the same command is used first as the command used to create a partition. 

After this, instead of typing n, the command d is typed. 


 

To view the size of a partition, the -s option of fdisk command is used.  

 


Comments