Re: bsdlabel and layout related question



Michel Talon wrote:
It is explained in man bsdlabel.

I really wanted to say: No, it isn't! Especially as the man page was the first place where I started to look for answers.
On the other hand, giving out incorrect information is definitely not how I know you, so this made me think. I mean, really think -which does tend to happen sometimes! :-)
So I checked the on-line man page on freebsd.org, and I did find a short sentence regarding this 16 sectors offset in the 6.1R manual.
I have 5.4 on my machine (planning to upgrade to 6.2R soon) and the bsdlabel manpage in 5.4 does not include this piece of explanation.
Even more interesting is that the bsdlabel examples in my 5.4 manpage show the _a_ partition at the beginning with an offset of 0, while the 6.1 manpage is careful to always show an offset of 16 at these fields.

This is what the 6.1R manpage says:

SAVED FILE FORMAT
The bsdlabel utility uses an ASCII version of the label when examining,
editing, or restoring a disk label. The format is:

8 partitions:
# size offset fstype [fsize bsize bps/cpg]
a: 81920 16 4.2BSD 1024 8192 16 *HERE!*
b: 160000 81936 swap
c: 1173930 0 unused 0 0 # "raw" part,

If the -A option is specified, the format is:

# /dev/da1c:
type: SCSI
disk: da0s1
label:
flags:
bytes/sector: 512
sectors/track: 51
tracks/cylinder: 19
sectors/cylinder: 969
cylinders: 1211
sectors/unit: 1173930
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0 # milliseconds
track-to-track seek: 0 # milliseconds
drivedata: 0

8 partitions:
# size offset fstype [fsize bsize bps/cpg]
a: 81920 16 4.2BSD 1024 8192 16 *HERE!*
b: 160000 81936 swap
c: 1173930 0 unused 0 0 # "raw" part,

Lines starting with a `#' mark are comments.

offset The offset of the start of the partition from the beginning of
the drive in sectors, or * to have bsdlabel calculate the correct
offset to use (the end of the previous partition plus one, ignor-
ing partition `c'. For partition `c', * will be interpreted as
an offset of 0. The first partition should start at offset 16,
because the first 16 sectors are reserved for metadata.



And here is what my 5.4 system displays in the bsdlabel man page:

SAVED FILE FORMAT
The bsdlabel utility uses an ASCII version of the label when examining,
editing, or restoring a disk label. The format is:


8 partitions:
# size offset fstype [fsize bsize bps/cpg]
a: 81920 0 4.2BSD 1024 8192 16 *HERE!*
b: 160000 81920 swap
c: 1173930 0 unused 0 0 # "raw" part,

If the -A option is specified, the format is:

# /dev/da1c:
type: SCSI
disk: da0s1
label:
flags:
bytes/sector: 512
sectors/track: 51
tracks/cylinder: 19
sectors/cylinder: 969
cylinders: 1211
sectors/unit: 1173930
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0 # milliseconds
track-to-track seek: 0 # milliseconds
drivedata: 0

8 partitions:
# size offset fstype [fsize bsize bps/cpg]
a: 81920 0 4.2BSD 1024 8192 16 *HERE!*
b: 160000 81920 swap
c: 1173930 0 unused 0 0 # "raw" part,

Lines starting with a `#' mark are comments.


offset The offset of the start of the partition from the beginning of
the drive in sectors, or * to have bsdlabel calculate the correct
offset to use (the end of the previous partition plus one, ignor-
ing partition `c'. For partition `c', * will be interpreted as
an offset of 0.

It can clearly be seen that the last sentence in the *offset* section is missing from 5.4 while it is present in 6.1R. No wonder why I didn't find it! :-)

Judging from the fact that even the examples were changed to represent the recommended 16 sectors offset for the _a_ partitions, I assume it is important enough. Although, I have to admit, that I still have no idea on what kind of metadata is stored in that initial 16 sectors, what puts it there, when does it put it there, when does this gets used and by what, etc. Also interesting is the question, what happens if this offset is not set to 16 but to 0, therefore this mystical metadata is probably not there. Because, I have been using my slices with the _a_ partitions defined with an offset of 0, and I didn't see any errors since. So, this metadata and the offset of 16 might not be that important after all. Or is it?!
:-)

I believe this perfectly summarizes how further I got with this topic after finding the updated manpage. I now have some additional information, but still didn't get anywhere. :-)


It it room for the label, in fact.

So my mysterious METADATA is the LABEL. Now how on Earth did you know that?!
This is definitely not in the manual. Not even in 6.1R. You my friend are reading some sort of secret handbook. :-)

It is one of the shortcomings of sysinstall
that it forgets to reserve these 16 blocks on the first partition of the
slice.

All right. This explains why I had 0 offset for partition _a_ on my first FreeBSD slice, and why I got confused between using 16 or 0.

Fortunately this is non destructive because the disk driver is smart
enough to not overwrite the label.

This could be the reason why I never experienced any trouble, even though I created my partitions with offset 0 sometimes. Although my first 16 sectors were part of the _a_ partition, the driver must have never written there.
Another reason could be that I never actually defined labels for my disks, therefore there was nothing to overwrite by accident. :-)
Final conclusion: being stupid and underinformed is quite safe! :-)

Thanks for the response!
Best regards,
Keve

--
if you need to reply directly:
keve(at)mail(dot)poliod(dot)hu
.



Relevant Pages

  • Re: BSDInstaller snapshot
    ... first partition at offset 16. ... What is this metadata on those ... +> first 16 sectors of a slice and when this metadata is really used? ...
    (freebsd-current)
  • Re: swap at beginning of slice - danger?
    ... Previously, on a 4.11 system, swapinfo said that swap size was less than ... changed and is it dangerous nowadays to have swap partition at offset 0? ... doesn't touch first several sectors, so it would be safe to start FFS partition from the offset 0, but AFAIK swap engine makes no such guaranties. ...
    (freebsd-stable)
  • Re: BSDInstaller snapshot
    ... first partition at offset 16. ... What is this metadata on those ... +> first 16 sectors of a slice and when this metadata is really used? ...
    (freebsd-current)
  • Re: partition for GELI disk
    ... +> complete remaining size of the disk, not taking the offset '16' for ... +> (why is there such an offset anyway?) or calculate it by hand. ... Swap skips first 16 sectors, ... If you configure something else on first partition which starts at ...
    (freebsd-current)
  • Re: "Cannot find file system superblock" error - how to recover?
    ... partition c: partition extends past end of unit ... disklabel: partition c doesn't start at 0! ... The 63 offset is spurious. ... I wonder whether editing the label and setting both offsets to 0 ...
    (freebsd-questions)