Pages

Thursday, June 29, 2017

10 fdisk Commands to Manage Linux Disk Partitions

fdisk stands (for “fixed disk or format disk“) is an most commonly used command-line based disk manipulation utility for a Linux/Unix systems. With the help of fdisk command you can view, create, resize, delete, change, copy and move partitions on a hard drive using its own user friendly text based menu driven interface.
This tool is very useful in terms of creating space for new partitions, organising space for new drives, re-organising an old drives and copying or moving data to new disks. It allows you to create a maximum of four new primary partition and number of logical (extended) partitions, based on size of the hard disk you have in your system.

fdisk command examples
fdisk command to manage disk partition
This article explains 10 basic fdisk commands to manage a partition table in Linux based systems. You must be root user to run fdisk command, otherwise you will get a “command not found” error.
Caution – Don’t Create, Delete or Modify Partitions. Unless you know what you are doing!

1. View all Disk Partitions in Linux

The following basic command list all existing disk partition on your system. The ‘-l‘ argument stand for (listing all partitions) is used with fdisk command to view all available partitions on Linux. The partitions are displayed by their device’s names. For example: /dev/sda/dev/sdb or /dev/sdc.
[root@tecmint.com ~]# fdisk -l
Disk /dev/sda: 637.8 GB, 637802643456 bytes
255 heads, 63 sectors/track, 77541 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        2624    20972857+  83  Linux
/dev/sda3            2625        4582    15727635   83  Linux
/dev/sda4            4583       77541   586043167+   5  Extended
/dev/sda5            4583        5887    10482381   83  Linux
/dev/sda6            5888        7192    10482381   83  Linux
/dev/sda7            7193        7845     5245191   83  Linux
/dev/sda8            7846        8367     4192933+  82  Linux swap / Solaris
/dev/sda9            8368       77541   555640123+  8e  Linux LVM

2. View Specific Disk Partition in Linux

To view all partitions of specific hard disk use the option ‘-l‘ with device name. For example, the following command will display all disk partitions of device /dev/sda. If you’ve different device names, simple write device name as /dev/sdb or /dev/sdc.
[root@tecmint.com ~]# fdisk -l /dev/sda
Disk /dev/sda: 637.8 GB, 637802643456 bytes
255 heads, 63 sectors/track, 77541 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        2624    20972857+  83  Linux
/dev/sda3            2625        4582    15727635   83  Linux
/dev/sda4            4583       77541   586043167+   5  Extended
/dev/sda5            4583        5887    10482381   83  Linux
/dev/sda6            5888        7192    10482381   83  Linux
/dev/sda7            7193        7845     5245191   83  Linux
/dev/sda8            7846        8367     4192933+  82  Linux swap / Solaris
/dev/sda9            8368       77541   555640123+  8e  Linux LVM

3. Check all Available fdisk Commands

If you would like to view all commands which are available for fdisk. Simply use the following command by mentioning the hard disk name such as /dev/sda as shown below. The following command will give you output similar to below.
      ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
                                                    ► Read more: http://adf.ly/1nBgmk
      ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

No comments:

Post a Comment