fdisk command in Linux with examples

Configurare noua (How To)

Situatie

fdisk also known as format disk is a dialog-driven command in Linux used for creating and manipulating disk partition table. It is used for the view, create, delete, change, resize, copy and move partitions on a hard drive using the dialog-driven interface.
fdisk allows you to create a maximum of four primary partitions and the number of logical partition depends on the size of the hard disk you are using. It allows the user:

-To Create space for new partitions.
-Organizing space for new drives.
-Re-organizing old drives.
-Copying or Moving data to new disks(partitions).

Synopsis:

fdsik [options] device

or

fdisk -l [device…]

Solutie

Pasi de urmat

View All Disk Partitions:The first thing to do before doing any thing with the disks and partition is to view basic details about all available partition in the system. The below command is used to list the partitions on your system and see their /dev names. For example /dev/sda, /dev/sdb or /dev/sdc.

$ sudo fdisk -l

View Partition on a Specific Disk: Below command is used to view all disk partitions on device /dev/sda.

$ sudo fdisk -l /dev/sda

View all fdisk Commands: To see all the command which are available under fdisk command you can use /dev/sda partition with fdisk command.

$ sudo fdisk /dev/sda

Note: This will prompt for a command. Type m for seeing all the operations which can perform on /dev/sda. After pressing m you will get:

Create a Hard Disk Partition: For this go inside the hard drive partition that is the /dev/sda partition, and use the following command:

$ sudo fdisk /dev/sda

Now you have to type n to create new partition and then type p for making a primary partition and e for making an extended or logical partition depending on the type of partition to make.

Run w command to write the changes and reboot your system

Delete a Hard Disk Partition: To delete a partition for the hard disk and free up space occupied by that partition for example /dev/sdb. Go to the command menu using following:

$ sudo fdisk /dev/sda

and then type d to go to the delete partition menu. It will prompt the partition number you want to delete(type the number).

Run w command to write the changes and reboot the system.

How to view the size of your Partition:

$ sudo fdisk -s /dev/sda

Note:

-To check for the manual page of fdisk command, use the following command:

$ man fdisk

-To see the help message and listing of all options, use the following command option:

$ sudo fdisk -h

Tip solutie

Permanent

Voteaza

(24 din 57 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?