fdisk implementation [read this before deciding what to do]
vince.dragonfly at hightek.org
Fri Jan 2 17:01:39 PST 2009
On Wed, Dec 17, 2008 at 09:49:21AM -0800, Matthew Dillon wrote:
> A few possible gotchas regarding fdisk and disklabels. DragonFly has
> a 64 bit disklabel feature now (disklabel64), as well as gpt support,
> but lacks boot support for either.
> I think the fdisk utility needs to be separate from the disklabel
> Also as HAMMER moves more into the mainstream the recommended
> partitioning scheme is to only have two partitions... a small UFS
> /boot, and everything else in a single HAMMER root.
We noticed the problems with the existing BSD partitioning tools and,
several years ago, my brother wrote a replacement that we have been
using since. I figured now is the time to chime in since, apparently
you guys are about to decide on a new direction for these tools.
I also liked the user interface to cfdisk but Sascha hit the nail on the
head when he mentioned the interactive tools not being scriptable.
I don't think they follow the Unix layered philosophy in that sense.
And, of course, partitioning tools that I have seen from the Linux world
such as cfdisk are licensed as GPL rather than BSD, which I don't think
is appropriate for a core BSD sys-admin utility if it can be avoided.
We have been using our tool for the last several years on NetBSD,
FreeBSD, and DragonflyBSD. We have been calling it *partition*, because
it is an intuitive name for its function (creates both bsd partitions as
well as PC partitions (slices)), but that name is not set in concrete.
If it became an official replacement for fdisk in DF, I guess it could
be named *fdisk* but I never thought that was really a good name now
days since we are dealing with more than fixed disks.
It is command line based (completely non-interactive) and designed to be
easy to use manually, yet extremely script friendly so that you can use
it in automated installation tools as well as put any kind of UI on it
you choose, even simple interactive shell scripts. It is also layered
into a C library so that C programs do not have to do a fork&exec of
a command line tool for every function. The code is clean and simple to
It does both partitioning and disk labeling. And each function is stand
alone, so you run it once for each change, (e.g. add a single partition,
Here is the usage and some examples.
usage: partition --command [/dev/device] [arg ,,,]
# partition --help
# partition --list-params /dev/ad0
# partition --list-slice /dev/ad0 1
# partition --list-slices /dev/ad0
# partition --list-slice-free-space /dev/ad0
# partition --list-slice-types
# partition --del-slice /dev/ad0 1
# partition --list-label /dev/ad0 1
# partition --list-partition /dev/ad0 1 a
# partition --add-partition /dev/ad0 1 a all auto
# partition --add-partition /dev/ad0 1 a 200mb auto
# partition --add-partition /dev/ad0 1 a 30000 10000
# partition --set-partition-type /dev/ad0 1 a 4.2BSD
# partition --set-partition-type /dev/ad0 1 b swap
# partition --set-disklabel-params /dev/ad0 1 disk name
# partition --set-disklabel-params /dev/ad0 1 label label
# partition --new-label /dev/ad0 1
# partition --check-label /dev/ad0 1
# partition --init-boot-sect /dev/ad0
The output is all script friendly, so that it can be sourced directly
from a shell script.
# partition --list-slices /dev/ad10
We planned to eventually release it under the BSD license but have never
released it yet because of several reasons.
The command line structure is temporary. The current CL requires an
exact order of arguments, which is not much of a problem for user
interfaces or scripts, but is less CL friendly and easier to make
a mistake. I planned to write a new CL parser that is more
consistent to some of the other tools we have written that do not
depend on the order of the arguments. i.e.
partition command setting=value setting=value
partition list-slices dev=/dev/ad0
partition set-partition-type dev=/dev/ad0 slice=1 partition=a type=4.2BSD
I also plan to have short and abbreviated forms of the commands.
In reference to what Matt mentioned, it does not yet support Some of
DF's new features such as 64 bit disk labels.
I think there have also been some other changes in DF disk label
that still require *partition* to be updated.
There is no manual yet because of lack of time and because of the
planned command line changes.
I could put up a binary if anybody wants to play with it. If you guys
are interested in taking it over, making it an official part of
Dragonfly, and updating it for the new disk labels, etc, we were
considering going ahead and releasing the source. If not, we will
probably hold off and release it later on as part of some other projects
after we get a chance to finish it ourselves. But that might be
More information about the Users