[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: control of partition numbers

From: D. Hugh Redelmeier
Subject: Re: control of partition numbers
Date: Wed, 1 Jan 2003 15:34:24 -0500 (EST)

| From: Andrew Clausen <address@hidden>

| > I would expect that exchanging two partition table entries would be
| > quite easy.
| It is up until you start implementing it :(

Well, you are the expert.

Can you explain?  Is it an artifact of the implementation of parted?
Is it due to the vast variety of partition table mechanisms?  The
actual table entries SEEM simple to me: for purposes of permutation,
each entry is a contiguous lump of bytes on a disk (at least in

| > |  There are some combinations
| > | that are illegal.
| > 
| > Yes: exchanging a logical and primary partition table entry isn't
| > possible.  For one thing, the space for a primary partition must not
| > be inside an extended partition but the space for a logical partition
| > must be inside the extended partition.

Perhaps this restriction can be charactarized as: a partition table
entry can only be permuted to another slot that is of the same type.

This leaves the question: what is a type.  We get to decide the
answer.  Essentially, a type system partitions (yet another use of
that word!) the set of all possible partitions.  For example, logical
and primary partitions are of a different type.  The extended
partition is of the same type as primary partitions (I don't know
whether the standard terminology would call the extended partition a
primary partition, but it does take a primary partition slot).  A
consequence is that an extended partition cannot be of the same type
as a logical partition.

| Also, you can't have "holes".  Like, you can't renumber 5 to 10
| if there's no 9.

I imagined that the only partitions that could be mentioned in a
renumber command would be existing partitions.  I then extended it in
the case of MSDOS primary partitions because the non-existent primary
partitions actually have table entries.

So what you say is right, but doesn't come up the way I conceptualized
the command.  I conceptualized a permutation as neither creating nor
destroying partitions: a conservation of partitions law would apply.

Perhaps the best characterization of this restriction is: only things
with existing table entries can be mentioned in a permutation command.

| Also, there are some cases where you can't renumber 5 at all,
| or possibly only swap 5 with 6, or some other number.

I don't recognize this restriction.  Where does it come from?  Can you
give an example?

| It's totally counter-intuitive.

MSDOS restrictions are not counter-intuitive.  They are just dumb,
intricate, and poorly documented.  Oh wait, maybe there are things I
haven't yet discovered that make my view incomplete.

| > |  Also, remember that Parted supports many different
| > | types of partition tables.
| > 
| > Good point.  Unfortunately, I don't know enough about other types of
| > partition tables to speak to this.  Perhaps you could describe the
| > constraints on exchanges for these other types.
| Msdos's layout is the only really insane one.

I would guess that other ones may not be insane but might have
inconveniently different properties.

I once installed OpenBSD on a PC and seem to remember that their slice
system interacted very oddly with the PC partition system.

| > Whenever a logical partition is deleted, all later ones get
| > renumbered.  Whenever a logical partition is added, it becomes last.
| > So if you delete and recreate a partition, it and all higher-numbered
| > ones are renumbered -- often inconvenient.
| This is because you can't have "holes"

I know why.  I was just trying to show that there is a problem.

| > How could parted address these problems?
| > 
| > - Perhaps when the user asks to create a partition, he could specify
| >   its number.  If the number were in the extended partition, all
| >   partitions with that number or higher would have their number
| >   incremented.  If the number were of an existing primary partition,
| >   parted should refuse.
| > 
| >   This solves the delete/recreate problem, but leaves other imaginable
| >   ones.  For example, if he created a partition with the wrong number,
| >   he could not fix up the mistake without deleting a partition and
| >   recreating it.
| Also, it complicates the UI somewhat.  Should partition numbers
| be optional?  Should parted infer primary vs logical via the
| partition number, or ask that also?

It depends.  From a user's standpoint, I'd say:

- partition numbers should be optional

- parted could (for MSDOS) infer the type from the number.  That seems
  a bit magical.  I like the redundancy of the user specifying the
  type and the number.  parted would then do a sanity check.

How about
        mkpart logical[5] ...
        mkpart primary[1] ...
        mkpart extended[2] ...
This last one is a bit ugly -- the extended partition lives in the
primary partitions' number space.  To my mind, extended is almost a
file system type, albeit a magical one.
        mkpart logical[2] extended ...

If you are a radical minimalist (I have sympathy for this approach),
then I'd say don't allow partition numbers to be specified, just allow
the result to be fixed up with a permutation command.

| Yep, I'm familiar with permutation groups and this notation.

Great!  You appear to be ahead of me in group theory.  It's been 30+
years since I took a course in it.

| > The tr(1) command suggests a notation for a permutation (but it does
| > not restrict itself to permutations).  How about a parted command:
| > 
| >     renumber 1 2 3 to 3 1 2
| Ah, good idea! :)

tr(1) has some other notational embelishments
        renumber 1-3 to 3 1 2
        renumber 1-3 to 3 1-2
If you want to get carried away :-)

| > It turns out that any permutation can be expressed as a sequence of
| > exchanges (the exchanges may overlap).
| But, you don't want to refer users to maths textbooks so they can
| use Parted!

[This is the point at which I can tell you are from the
Commonwealth-other-than-Canada.  We North Americans call it "math".]

Exchange is the minimal feature.  True, it isn't user-friendly.  But
the fact that parted hasn't had such a capability up to now suggests
that it is a wizard-level requirement.

Being minimal, there are fewer cases where the command could fail half
way through.  With careful prechecking, renumber could be about as

| I'm leaning towards renumber.

As a user, I would be satisfied with exchange but would prefer
renumber.  I would much prefer exchange now over renumber in the
future :-)

| > Note that for primary partitions, full power requires that unused
| > partitions table entries be candidates for exchange.  This reflects
| > what the underlying partition table allows.  It also enables all
| > possible control of minor device numbers.  There is no concept of an
| > unused partition table entry for logical partitions, as far as I
| > know.
| Correct.  This complicates the problem a bit :/
| [group theory hat on]
| I guess all existing partitions, and "free space slot" partitions
| are elements of a set, and the permutations themselves are
| form a group action on the set, with composition being the group
| operation.

I think that there are two sets or types (in MSDOS):

- primary partiton table slots
  + primary partitions
  + extended partitions
  + unused primary partition table entries

- logical partitions

The renumber command should only permute entries within a set, not
between sets.

Are there any other constraints to be expressed?

| So, above, I mentioned, for example, that you might not be able
| to renumber 5 to anything other than 6.

As I asked above, where does this constraint come from?

| Other than that, you can have the partition table type specific
| code accept/reject permutations.  But this is bad for making good
| UI's.

I feel that the ugliest aspect of my conceptualization is that we now
need to be able to denote unused primary partition table entries.  I
don't think you needed this before.  Luckily, the notation is obvious.

| > There are some other tasks that can be accomplished simply by changing
| > partition table entries, but not via permutation.  The constraints on
| > applicability make them less elegant.
| These all look like some kind of import/export logical partition
| command, in combination with renumber.

Yes.  But they cannot be broken into separate commands because when the
partition changes its type, it cannot keep its old number.

I've actually wanted these.  I do think that they are ugly.

| Thanks for the interesting email :)  This is the second time group
| theory has come in handy with Parted... pretty funny really :)

Theory is good to inform programming.  But sometimes it suggests
excessive generality.  Abstraction is a really good thing in theory but
often bad for human engineering.  In this case, I think the generality
convinced you that the implementation would be too expensive.

Hugh Redelmeier
address@hidden  voice: +1 416 482-8253

reply via email to

[Prev in Thread] Current Thread [Next in Thread]