I have finished fdisk(8) refactoring, this task we started with Davidlohr Bueso and Petr Uzel two releases ago. The result is a code that is easy to extend and all disklabel specific code is no more maintained together as a ball of spaghetti.
The goal is to have one library (libfdisk) shared between all the fdisks (sfdisk, cfdisk, ...). Now it's used in fdisk only. I hope that one day we're going to have shared library with a public stable API.
The most visible changes:
- fdisk dialogs and output unification, more verbose messages
- colors for warnings
- new (but backwardly compatible) menus
- all operations for all disklabels based on sectors by default
- man page clean up
- improved GPT disklabel support (rename partition, partition and disk UUID modification)
The last missing thing is support for manual modification of hybrid GPT. This is planned for the next release v2.25.
My laptop with GPT:
# fdisk -l /dev/sda Disk /dev/sda: 149.1 GiB, 160041885696 bytes, 312581808 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: gpt Disk identifier: 3549290F-417C-4941-8503-F7835109B821 Device Start End Size Type /dev/sda1 2048 2050047 1000M EFI System /dev/sda2 2050048 6146047 2G Microsoft basic data /dev/sda3 6146048 26462207 9.7G Linux swap /dev/sda4 26462208 98142207 34.2G Microsoft basic data /dev/sda5 98142208 230662143 63.2G Microsoft basic data /dev/sda6 230662144 312580095 39.1G Microsoft basic data
- disklabel hex dump (command 'D')
This is nice feature for advanced users. You don't have to fight with hexdump, search the right offsets etc. fdisk(8) will locate all relevant disklabel parts on the device and print all in hex format. (Don't forget that many things don't use static offsets -- for example GPT array with partitions, MBR extended partitions, etc).
For example (disk with two logical partitoins):
# echo -e 'x\nD\nq\n' | fdisk /dev/sdb Welcome to fdisk (util-linux 2.24.rc2-22-1d8c-dirty). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): Expert command (m for help): MBR: offset = 0, size = 512 bytes. 00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 * 000001b0 00 00 00 00 00 00 00 00 14 92 2b 9e 00 00 00 20 000001c0 21 00 83 df 13 0c 00 08 00 00 00 20 03 00 00 df 000001d0 14 0c 05 7c 30 4c 00 28 03 00 00 98 0f 00 00 00 000001e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa EBR: offset = 105906176, size = 512 bytes. 06500000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 * 065001c0 34 0d 83 bf 26 19 00 08 00 00 00 20 03 00 00 bf 065001d0 27 19 05 9f 39 26 00 28 03 00 00 28 03 00 00 00 065001e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 065001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa EBR: offset = 211812352, size = 512 bytes. 0ca00000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 * 0ca001b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 e0 0ca001c0 08 19 83 9f 39 26 00 08 00 00 00 20 03 00 00 00 0ca001d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 * 0ca001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa