[Top][All Lists]

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

Re: v3.0: scripting, args, boundaries

From: Neal Murphy
Subject: Re: v3.0: scripting, args, boundaries
Date: Sun, 14 Aug 2011 15:32:33 -0400
User-agent: KMail/1.13.5 (Linux/2.6.32-5-686-bigmem; KDE/4.4.5; i686; ; )

On Sunday 14 August 2011 14:10:46 Jim Meyering wrote:

I'll get back to most of it. But this one I can answer now.
> > And where do partitions really start and end? If I use units of MiB, then
> > I can start a partition at 1MiB and end it at 200MiB. But parted insists
> > that the partition is 199MiB. So it seems the specified end is really
> > the block *after* the last block of the parttion. But only for MiB.
> Do you mean that the length is 199MiB?
> Wouldn't you expect that if it starts at 1MiB and goes to 200MiB?

Oops. Sorry, I left out the word 'size'; I meant to say "partition size is 
199MiB', as you surmised.

For partitioning purposes, I'm using a 'logical' block size of 1MiB for 
several reasons:
  - disk blocks are 512 bytes (not 500 bytes)
  - 1MiB is guaranteed to be sector-aligned regardless of how large physical
    sectors grow in the next few years. (Well, *should be* aligned, since the
    future holds no guarantees.)
  - both the beginning and the end of the partitions are guaranteed to be
  - I want to know exactly where partitions start and end. I neither want nor
    expect the partitioning program to change my selections.
So when I say 'block', below, I mean 1MiB block.

If a partition starts on block 1 and ends on block 2:
  - it contains 2 blocks
  - its size is 2MiB
  - the next partition can start with block 3
If a partition starts on block 1 and ends on block 10:
  - it contains 10 blocks
  - its size is 10MiB
  - the next partition can start with block 11
If a partition that starts on block 1 and ends on block 200:
  - it contains 200 blocks
  - its size is 200MiB
  - the next partition can start with block 201

The math:
  size = end - (start - 1)
  size = end - start + 1

So, no. I expect a partition that starts with the 1MiB block and ends with the 
200MiB block to have a size of 200MiB. Because parted reports the unexpected 
size of 199MiB, I don't know if the size was miscomputed or if 'end' is 
outside the partition. So I asked to clarify 'begin' and 'end' and if counting 
is zero-based or one-based. Is 'begin' the first block of the partition and 
'end' the last block of the partition? That is, are 'begin' and 'end' 
contained within the partition, as one might reasonably expect from the 

> >   - Please clearly state the last usable block or byte of the drive, or 
how to
> >     compute it; please don't force any more people to restort to trial and
> >     error to find out where they can end their disk usage.
> Examples address this: use -1B for the last byte
> or -1s for the last sector.  With GPT, you'll want to use -34s.
OK. So if I simply reserve the first and last MiB blocks of the device, I 
should be safe: the beginning of the first partition and the end of the last 
partition will always be sector-aligned. Yes, I'm throwing away 2MiB of disk 
space. But disk space is cheaper than hair replacement.

So since I wrote zeroes to the first 10MiB and last 10MiB of the device, 
parted should not have found any vestiges of GPT or any other partitioning 
scheme. Yet it persists in making me verify that I really mean to execute 
mklabel, even though it found no partition scheme. And (s)fdisk insist that 
there is GPT scheme on the drive, even though I zeroed out the usual suspects.

If I run 'mkpart /dev/sda mklabel gpt' it demands I verify my intention before 
writing the new label, and it does so write. I then make a partition of some 
size. If I then run 'mkpart -s /dev/sda mklabel gpt', it finishes without 
doing anything; the partition I made is still there. Does parted read the in-
core partition in some places and the on-disk partition in others?

reply via email to

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