fdisk
- 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.
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.
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.
Print all Partition Table in Linux
- To print all partition table of hard disk, you must be on command mode of specific hard disk say /dev/sda.
- From the command mode, enter ‘p‘ instead of ‘m‘ as we did earlier. As we enter ‘p‘, it will print the specific /dev/sda partition table.
How to Format a Partition in Linux:
- After the new partition is created, don’t skip to format the newly created partition using ‘mkfs‘ command.
- Type the following command in the terminal to format a partition. Here /dev/sda4 is my newly created partition.
How to Check Size of a Partition in Linux:
- After formatting new partition, check the size of that partition using flag ‘s‘ (displays size in blocks) with fdisk command. This way you can check size of any specific device.