Tool Battle Royale - FDISK vs. PARTED
In this exciting world of "The Linux" people have lots of options and tools to get their jobs done. Folks take tool choice VERY seriously. Sometimes it's nice to peek at one of two and compare and contrast maybe learn a thing or two about different ways of getting the same job done. So I'm curious to hear: what's YOUR favourite tool of choice to work with disks: fdisk or parted? Both have great features, but which one do YOU choose to use? We'd love to hear your opinions on which tool makes you a better, stronger, faster admin.
Responses
Hey Chris and Everyone else,
So I always used to switched between the two. However, I recently had a sev1 incident where a customer accidentally wiped the first 1mb of /dev/sda. That's when I found that in a moment of crisis I chose fdisk.
Using fdisk and switching from cylinders to sectors we used the info in /sys/block/sda/sda1/start and /sys/block/sda/sda1/size to rebuild the partition table. While I'm sure parted has the same functionality, fdisk seemed to come to me eaiser while under pressure. I didn't realize that I had a preference prior to that.
- Nick Greene
Cool discussion. For me it's not so much the tool, but the reporting method with which it's used.
fdisk's default to "cylinders" is useless, no hard drive has used CHS addressing for almost 20 years. "Cylinder 1" in the partition list means "anywhere within cylinder 1". On large enterprise-grade storage you end up with the kernel guessing a "cylinder" of 8Mb or more, and you have no accuracy in your partition reporting.
Running fdisk in sector mode with the -u switch gets around this. View partitions with the fdisk -ul /dev/sdX command.
Parted's default "compact" reporting mode is equally as frustrating, as it defaults to "1000 kilobytes = 1 megabyte" and not "1024 kilobytes = 1 megabyte" like it should. So if you start a partition on sector 2048 (1 megabyte into the disk) then parted will report it as "1049kB" or "1.05MB".
Starting parted in sector mode with the "unit s" option gets around this. View partitions with the parted /dev/sdX "unit s" "print" command.
As far as other functionality, you can script with parted which is handy - parted mklabel, parted mkpart, and so on.
I'm firmly undecided.
Today I was working on a reproducer/test case for a support case that deals with LVM, partitioning/disk labeling and resizing LUNs. This involved a fair amount of steps (especially as being a poor remotee, I don't happen to have a SAN around for testing purposes, so I had to fake LUNs by loop-mounting a sparse file), so I ended up writing a script. For this, the parted --script functionality was very helpful. As far as I know, fdisk doesn't have this type of scripting capability, so scripting something similar with fdisk would likely have been a lot more complex (using expect or somesuch to script an interactive program). On the other hand, fdisk allows me to use just about every partition type ever invented, whereas parted's mkpart only supports a very limited list of partition types.
For me it's a question of context. If I'm doing interactive partitioning, I use `fdisk`. If I'm writing KickStarts designed to create storage-aligned partitions, I use `parted` in the %pre section of my KickStart file.
For me, `fdisk`s interface is just more "intuitive" and easier from an interactive standpoint. Though, that may be more from decades of habit rather than legitimate ease-of-use differentials. At any rate, if I'm worrying about aligning disks, I just ad an 'x' and a 'b' to my normal partitioning process.
`parted` is too much like trying to lay down a partition table in Solaris using `fmthard`. Great for scripting and kickstarts but kinda ugly as an interactive tool.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
