Re: BSD disklabel partition letters in NetBSD

2018-10-10 Thread Rocky Hotas
> Sent: Friday, October 05, 2018 at 1:55 AM
> From: "Robert Elz" 
> To: "Rocky Hotas" 
> Cc: "NetBSD Users Mailing List" 
> Subject: Re: BSD disklabel partition letters in NetBSD

[...]

>
> You can put swaps space in any partition you like, and have as many of them
> as you like

Ok!

> What you might want o be careful about is using partition b for something 
> other
> than swap. That should work as well, there's nothing truly magic about 'b',
> but there is just a possibiliity that some script, somewhere, mighht simply
> assume that if it needs to add some swap space, it might just decide to simply
> use the b partition, if one exists, without asking first, and destroy anything
> else that is there.

This is important to remember, thank you.

> The one case wherte it is needed (to have 2 different swap areas) would be
> is system A was to be a XEN Dom 0, and system Bis to be a DomU client
> (or vice versa of course) - that is, when both systems are to be running at
> the same time,

It's a very peculiar case, however, got it.

> Where to mount things is in the fstab in the root, wherever that is - 
> certainly
> not in the disklabel - but the filesystem (at least ffs filesystems) do
> contain a "last mounted on" field.
[...]
> One thing to watch when mixing NetBSD and FreeBSD - FreeBSD disklabels
> (which would be in the FreeBSD root partition normally, just as the NetBSD
> one is) are relative to the MBR partition (or slice)
[...]
> FreeBSD treats
> (or did last time I looked) MBR partitions (slices) as if they were different
> drives.
>
> If you want to put both NetBSD and FreeBSD on the same drive, then I'd
> suggest using MBR partitions as a way to keep yourself sane.

Thanks for considering all these specific and not-obvious cases, where attention
must be paid.
According to this discussion, it should be avoided to use BSD disklabel for
NetBSD and FreeBSD on the same machine: despite it seems very bizarre, MBR could
be the best choice.

Rocky

>
> kre
>
> 


Re: BSD disklabel partition letters in NetBSD

2018-10-10 Thread Rocky Hotas
Sent: Friday, October 05, 2018 at 3:37 AM
From: "Jason Mitchell" 
To: "Rocky Hotas" 
Cc: "NetBSD Users Mailing List" 
Subject: Re: BSD disklabel partition letters in NetBSD


> This posting (though old) says that FreeBSD disklabels are different from 
> NetBSD disklabels. Also back in 2011 NetBSD would overwrite a FreeBSD 
> disklabel on a FreeBSD MBR partition of type 165. FYI, NetBSD has been using 
> a MBR partition type of 169 for a long, long time.
 
> https://mail-index.netbsd.org/tech-kern/2011/02/04/msg009919.html[https://mail-index.netbsd.org/tech-kern/2011/02/04/msg009919.html]

Thanks for this!

> My objection was to NetBSD and FreeBSD sharing a disklabel, not to two 
> instances of NetBSD sharing a disklabel.

Yes, of course. I did mention that example because I was thinking that
FreeBSD and NetBSD share the same BSD disklabel format, but it is not so.
Bye!

Rocky


> Thanks,
 
> Jason M.
 


Re: BSD disklabel partition letters in NetBSD

2018-10-04 Thread Jason Mitchell




On Oct 4, 2018, at 3:59 PM, Rocky Hotas  wrote:

>> Sent: Saturday, September 29, 2018 at 4:41 AM
>> From: "Jason Mitchell" 
>> To: "Michael van Elst" 
>> Cc: netbsd-users@NetBSD.org
>> Subject: Re: BSD disklabel partition letters in NetBSD
> 
> [...]
> 
>> I don’t think this is possible. At least I remember reading here that
>> FreeBSD’s disklabel is in a different place then the NetBSD’s disklabel
>> and that NetBSD would unintentionally overwrite FreeBSD’s disklabel. (This
>> seems to imply that the FreeBSD disklabel is not in the FreeBSD MBR
>> partition, but I’m not sure about that).
> 
> Ok, this is absolutely possible and thank for remembering this probable
> issue. I put this however only as an example: the real question was not
> about compatibility, but about the... cohabitation of two bootable systems 
> ... 

This posting (though old) says that FreeBSD disklabels are different from 
NetBSD disklabels. Also back in 2011 NetBSD would overwrite a FreeBSD disklabel 
on a FreeBSD MBR partition of type 165. FYI, NetBSD has been using a MBR 
partition type of 169 for a long, long time.

https://mail-index.netbsd.org/tech-kern/2011/02/04/msg009919.html

My objection was to NetBSD and FreeBSD sharing a disklabel, not to two 
instances of NetBSD sharing a disklabel.

Thanks,

Jason M.



Re: BSD disklabel partition letters in NetBSD

2018-10-04 Thread Robert Elz
Date:Thu, 4 Oct 2018 22:14:31 +0200
From:"Rocky Hotas" 
Message-ID:  


  | > Sent: Thursday, October 04, 2018 at 9:10 PM
  | > From: "Don NetBSD" 

  | > I've never tinkered with moving swap out of 'b' -- but imagine it could be
  | > done, reliably.
  |
  | According to some previous messages, it should: it is non-conventional, but
  | not forbidden.

You can put swaps space in any partition you like, and have as many of them
as you like - and swap into files from filesystems mounted in ffs (and probably
other) partitions as well.   None of that is an issue.   You can also have no
swap soace if you want (and have enough RAM for what you need to run).

What you might want o be careful about is using partition b for something other
than swap.   That should work as well, there's nothing truly magic about 'b',
but there is just a possibiliity that some script, somewhere, mighht simply
assume that if it needs to add some swap space, it might just decide to simply
use the b partition, if one exists, without asking first, and destroy anything
else that is there.

  | Oh, actually you are right, it shouldn't be needed to duplicate also the
  | swap partitions, even because the amount of RAM is the same.

The one case wherte it is needed (to have 2 different swap areas) would be
is system A was to be a XEN Dom 0, and system Bis to be a DomU client
(or vice versa of course) - that is, when both systems are to be running at
the same time,

Or you can simply use both swap partitions if you want, on either system if
it is running alone - using one of them normally, with the other available
just in case more swap space is needed (I wouldn't advise simply using
both with equal priority, the swpped data would be all over the place, 
resulting in excessive drive head movement, and slower operations - unless
all this is on an SSD of course).

  | Ok, thanks for clarifying this. It was still a confusing issue, because
  | sometimes (also in sysinst(8)) when the BSD disklabel contents is shown, 
also
  | the mountpoints were listed, as if this information were stored in the
  | disklabel. But instead:

Where to mount things is in the fstab in the root, wherever that is - certainly
not in the disklabel - but the filesystem (at least ffs filesystems) do 
contain a "last mounted on" field.   This isn't used for much, though fsck
will print it, and it can be useful if you lose your fstab file and need to
attempt to remember which partition had which filesystem on it (not such
a big issue when you have just root and home (and swap) but when you
have many filesystems it can help.

One thing to watch when mixing NetBSD and FreeBSD - FreeBSD disklabels
(which would be in the FreeBSD root partition normally, just as the NetBSD
one is) are relative to the MBR partition (or slice) - NetBSD labels always
number sector 0 on the disk  as sector 0 in the label, and count from there,
the MBR partitioning info is used only to locate the NetBSD label (and if there
isn't one found, to create a fictional one in the kernel.)  FreeBSD treats
(or did last time I looked) MBR partitions (slices) as if they were different 
drives.

If you want to put both NetBSD and FreeBSD on the same drive, then I'd
suggest using MBR partitions as a way to keep yourself sane.

kre



Re: BSD disklabel partition letters in NetBSD

2018-10-04 Thread Rocky Hotas
> Sent: Thursday, October 04, 2018 at 9:10 PM
> From: "Don NetBSD" 
> To: "NetBSD Users Mailing List" 
> Subject: Re: BSD disklabel partition letters in NetBSD

[...]

> I've never tinkered with moving swap out of 'b' -- but imagine it could be
> done, reliably.

According to some previous messages, it should: it is non-conventional, but
not forbidden.

> I'm not sure why you would need two DIFFERENT swap partitions as only one
> would be in use (based on which OS was booted).  But, let someone else
> argue that point.

Oh, actually you are right, it shouldn't be needed to duplicate also the
swap partitions, even because the amount of RAM is the same.

> You can specify which NetBSD partition to boot at the boot prompt.  Or,
> build a "menu" that provides a simpler interface to this.

Ok!

> fstab(5) in each root partition (/etc being part of that, in this example)
> would call out 'e' or 'h' as the partition to be mounted on /home in that
> particular root file system.  The "other" home partition could then be
> mounted somewhere else (assuming the filesystem type is supported by the
> kernels built for A/B.

Ok, and thank you also for the detailed fstab(5) example.

> The disklabel is the same for each (there's only one, in this case).  I am
> assuming that these are non-overlapping regions of the medium.  I.e., the
> physical sectors used by A's root partition differ from those used by B's.

Yes, of course: I didn't explicitly write it, but the disklabel partitions
of the example must be non-overlapping regions of the disk.

> So, set up those partitions (size+offset) as befitting your needs.  Then,
> just elect which to boot (boot prompt) and where to mount the others (fstab).

[...]

> The disklabel just cuts the medium into "pieces" (avoiding the term "slices").
> It doesn't know where those will be mounted

Ok, thanks for clarifying this. It was still a confusing issue, because
sometimes (also in sysinst(8)) when the BSD disklabel contents is shown, also
the mountpoints were listed, as if this information were stored in the
disklabel. But instead:

>  fstab(5)'s role is
> to specify these mount points

> (assuming you don't deliberately do something
> "outside" the normal approach -- like running a special script to mount stuff)

No, of course in this example we are referring to fstab(5) only, so a "standard"
usage.
Thank you so much!

Rocky


Re: BSD disklabel partition letters in NetBSD

2018-10-04 Thread Rocky Hotas
> Sent: Saturday, September 29, 2018 at 4:41 AM
> From: "Jason Mitchell" 
> To: "Michael van Elst" 
> Cc: netbsd-users@NetBSD.org
> Subject: Re: BSD disklabel partition letters in NetBSD

[...]

> I don’t think this is possible. At least I remember reading here that
> FreeBSD’s disklabel is in a different place then the NetBSD’s disklabel
> and that NetBSD would unintentionally overwrite FreeBSD’s disklabel. (This
> seems to imply that the FreeBSD disklabel is not in the FreeBSD MBR
> partition, but I’m not sure about that).

Ok, this is absolutely possible and thank for remembering this probable
issue. I put this however only as an example: the real question was not
about compatibility, but about the... cohabitation of two bootable systems
that share the same BSD disklabel structure. Is this possible?

More details in this reply just posted:

http://mail-index.netbsd.org/netbsd-users/2018/10/04/msg021517.html

Bye,

Rocky


Re: BSD disklabel partition letters in NetBSD

2018-10-04 Thread Don NetBSD

So, in a degenerate example, put 2 partitions on a disk that each represent
an entire root filesystem TO THE OS THAT IS BOOTED.


This is exactly the degenerate example I wanted to refer to. Let's consider
a BSD disklabel in the first sector of a hard disk (so, without MBR) with
the following partitions defined:

a: /, root partition of system A
b: unused
c: unused (in some cases, it represents the whole disk)
d: unused


In those cases where c is not the whole disk, then d would be.


e: /homeA, home partition of system A
f: swap partition of system A
g: /, root partition of system B
h: /homeB, home partition of system B
i: swap partition of system B

Let both system A and B be NetBSD, for example 8.0 e 7.1, so we are sure
that they are both fully-compatible with the BSD disklabel layout.


I've never tinkered with moving swap out of 'b' -- but imagine it could be
done, reliably.

I'm not sure why you would need two DIFFERENT swap partitions as only one
would be in use (based on which OS was booted).  But, let someone else
argue that point.

You can specify which NetBSD partition to boot at the boot prompt.  Or,
build a "menu" that provides a simpler interface to this.

fstab(5) in each root partition (/etc being part of that, in this example)
would call out 'e' or 'h' as the partition to be mounted on /home in that
particular root file system.  The "other" home partition could then be
mounted somewhere else (assuming the filesystem type is supported by the
kernels built for A/B.

E.g., fstab(5) for A's system would contain (assuming an sd(4) device):
   /dev/sd0a/   ffs ...
   /dev/sd0fnoneswap...
   /dev/sd0e/home   ffs ...
   /dev/sd0h/otherhome  ffs ...
   /dev/sd0g/otherroot  ffs ...
while B's would be:
   /dev/sd0g/   ffs ...
   /dev/sd0inoneswap...
   /dev/sd0h/home   ffs ...
   /dev/sd0e/otherhome  ffs ...
   /dev/sd0a/otherroot  ffs ...


Now, boot system A from partition `a'. First: is it possible to do so? Then,
how would partitions `g', `h' and `i' be detected? In other words, what
would the output of `disklabel wd0' be from system A?


The disklabel is the same for each (there's only one, in this case).  I am
assuming that these are non-overlapping regions of the medium.  I.e., the
physical sectors used by A's root partition differ from those used by B's.

So, set up those partitions (size+offset) as befitting your needs.  Then,
just elect which to boot (boot prompt) and where to mount the others (fstab).


Ideally, at least partitions `g' and `h' should be mounted, fully readable
and writeable. But as regards mountpoints, there is some confusion, given
that partition `g' should be mounted in the same place as the already
mounted partition `a'. Or does this only depend on how fstab(5) has been set
up?


The disklabel just cuts the medium into "pieces" (avoiding the term "slices").
It doesn't know where those will be mounted -- if at all!  fstab(5)'s role is
to specify these mount points (assuming you don't deliberately do something
"outside" the normal approach -- like running a special script to mount stuff)


Then, boot system B from partition `g'. Same questions as above.


Re: BSD disklabel partition letters in NetBSD

2018-10-04 Thread Rocky Hotas
> Sent: Friday, September 28, 2018 at 9:04 PM
> From: "Don NetBSD" 
> To: netbsd-users@netbsd.org
> Subject: Re: BSD disklabel partition letters in NetBSD

[...]

Hi and sorry for the delay!

> 
> Remember, the partitions have no knowledge of where they actually exist in a
> FILESYSTEM!

Yes, of course.

> So, in a degenerate example, put 2 partitions on a disk that each represent
> an entire root filesystem TO THE OS THAT IS BOOTED.

This is exactly the degenerate example I wanted to refer to. Let's consider
a BSD disklabel in the first sector of a hard disk (so, without MBR) with
the following partitions defined:

a: /, root partition of system A
b: unused
c: unused (in some cases, it represents the whole disk)
d: unused
e: /homeA, home partition of system A
f: swap partition of system A
g: /, root partition of system B
h: /homeB, home partition of system B
i: swap partition of system B

Let both system A and B be NetBSD, for example 8.0 e 7.1, so we are sure
that they are both fully-compatible with the BSD disklabel layout.

Now, boot system A from partition `a'. First: is it possible to do so? Then,
how would partitions `g', `h' and `i' be detected? In other words, what
would the output of `disklabel wd0' be from system A?

Ideally, at least partitions `g' and `h' should be mounted, fully readable
and writeable. But as regards mountpoints, there is some confusion, given
that partition `g' should be mounted in the same place as the already
mounted partition `a'. Or does this only depend on how fstab(5) has been set
up?

Then, boot system B from partition `g'. Same questions as above.

> I think you can actually get even messier if you use an MBR to create 4
> different MBR "slices" -- and put NetBSD labels *in* each of those defining
> 4/8/16 different "NetBSD partitions".  Then boot some particular NetBSD
> partition from that set of 4/8/16 available!

This would be extreme :).

> Sorry to further complicate the discussion by drawing a distinction between
> MBR /slices/ (which the rest of the world calls a /partition/) and NetBSD
> /partitions/ within said slice(s).

Don't worry, I know this distinction, it's maybe the easier thing here!
Thank you :),

Rocky


Re: BSD disklabel partition letters in NetBSD

2018-09-28 Thread Jason Mitchell


> I guess you can have NetBSD and FreeBSD using different partitions but
> the same disklabel 

I don’t think this is possible. At least I remember reading here that FreeBSD’s 
disklabel is in a different place then the NetBSD’s disklabel and that NetBSD 
would unintentionally overwrite FreeBSD’s disklabel. (This seems to imply that 
the FreeBSD disklabel is not in the FreeBSD MBR partition, but I’m not sure 
about that).

Thanks,

Jason M.

Sent from my iPhone


Re: BSD disklabel partition letters in NetBSD

2018-09-28 Thread Don NetBSD

On 9/27/2018 3:32 AM, Rocky Hotas wrote:

For the sake of completeness, let's consider another case, hopefully
interesting to others. If you decide to install on the same disk two or more
BSD systems, all compatible with BSD disklabel (for example, two different
versions of NetBSD, or NetBSD and FreeBSD), would that unique BSD disklabel
in sector 1 of the disk be able to handle this?


Remember, the partitions have no knowledge of where they actually exist in a
FILESYSTEM!

So, in a degenerate example, put 2 partitions on a disk that each represent
an entire root filesystem TO THE OS THAT IS BOOTED.

Boot partition 1 and you get one "system" (OS and filesystem).  Boot partition
2 and you get another.

To be more exotic, fstab(5) in the filesystem represented in partition 1
can call for /home to be mounted from partition 6 with /oldhome mounted from
partition 7.  Meanwhile, the fstab(5) in the filesystem represented in
partition 2 swaps this order (/home from partition 7 and /oldhome from
partition 6).


In all the examples I've seen, this data structure is conceived to describe
only a single system, with one root partition (and then optional separate
partitions as /home, /var, /usr according to the administrator's choice, but
all referred to the same root). Multiple OSs would mean multiple root
partitions.


Yes.


However, it would be very odd if, in order to allow the existence of
multiple BSD OSs, a third-party partitioning scheme as MBR would be needed.
If these questions can be answered by reading some documentation or some
other source and you know the link, I would check it out (unfortunately I
found almost nothing about this).


I think you can actually get even messier if you use an MBR to create 4
different MBR "slices" -- and put NetBSD labels *in* each of those defining
4/8/16 different "NetBSD partitions".  Then boot some particular NetBSD
partition from that set of 4/8/16 available!

Sorry to further complicate the discussion by drawing a distinction between
MBR /slices/ (which the rest of the world calls a /partition/) and NetBSD
/partitions/ within said slice(s).

[Graphics would really make a lot of this easier to explain!  :< ]


Re: BSD disklabel partition letters in NetBSD

2018-09-28 Thread Don NetBSD

On 9/27/2018 3:41 AM, Rocky Hotas wrote:

Sent: Tuesday, September 25, 2018 at 11:51 PM
From: "Don NetBSD" 
To: netbsd-users@netbsd.org
Subject: Re: BSD disklabel partition letters in NetBSD


[...]


But it isn't placed in any of these places unless/until the system is
DIRECTED to do so.  I.e., you can access a brand-new, never-before-powered-on
disk drive via the fictitious IN-KERNEL disklabel STRUCTURE.  But, need
never actually write it to the medium to allow such access (on a NetBSD box).


IIUC, this is a subtle (but important) clarification.


There are some caveats, IIRC.  E.g., the fictitious disk label also "imagines"
(a fictitious) 'a' partition.  But, an attempt to "newfs /dev/rsd#a" will fail.

The only thing you can be sure of is the "whole disk" partition -- and ONLY if
you haven't altered the in-kernel instance of it WITHOUT writing that to the
medium (cuz there is no other instance!).

ISTR (many major releases ago) having to put ALL of the label information on
the medium (using disktab(5)).


Re: BSD disklabel partition letters in NetBSD

2018-09-27 Thread Michael van Elst
rockyho...@post.com ("Rocky Hotas") writes:

>Do you mean that who generates disklabel collects information about the
>disk, cylinders, etc. and creates a brand new data structure? I can't
>understand what you are referring to as "other information".

The driver provides a 'default label' based on information like cylinders.

Then the disk is searched for an MBR (to find the NetBSD partition type 169).

If this is found, it searches for a disklabel in that partition, otherwise
it computes a disklabel based on MBR partitions and continues to look for
a disklabel at the beginning of the disk.

Some non-MBR-based platforms have additional heuristics to read other
kinds of partitioning information, e.g. an Amiga "Rigid Disk Block".



>For the sake of completeness, let's consider another case, hopefully
>interesting to others. If you decide to install on the same disk two or more
>BSD systems, all compatible with BSD disklabel (for example, two different
>versions of NetBSD, or NetBSD and FreeBSD), would that unique BSD disklabel
>in sector 1 of the disk be able to handle this? 

I guess you can have NetBSD and FreeBSD using different partitions but
the same disklabel on a single disk. OpenBSD did change the disklabel
format to support larger disks, so that probably conflicts.

Wether you can have a bootloader on that disk that handles different
systems is another question. But for data disks that's not a problem.


>In all the examples I've seen, this data structure is conceived to describe
>only a single system, with one root partition (and then optional separate
>partitions as /home, /var, /usr according to the administrator's choice, but
>all referred to the same root). Multiple OSs would mean multiple root
>partitions.

Yes. But it's possible to boot NetBSD using a partition different from 'a'.


>However, it would be very odd if, in order to allow the existence of
>multiple BSD OSs, a third-party partitioning scheme as MBR would be needed.

You don't need an MBR to make the disk accessible.

On x86 hardware you do need an MBR just for being able to boot an OS,
and I'm not even talk about UEFI, just about plain old BIOS.

-- 
-- 
Michael van Elst
Internet: mlel...@serpens.de
"A potential Snark may lurk in every tree."


Re: BSD disklabel partition letters in NetBSD

2018-09-27 Thread Rocky Hotas
> Sent: Tuesday, September 25, 2018 at 11:51 PM
> From: "Don NetBSD" 
> To: netbsd-users@netbsd.org
> Subject: Re: BSD disklabel partition letters in NetBSD

[...]

> But it isn't placed in any of these places unless/until the system is
> DIRECTED to do so.  I.e., you can access a brand-new, never-before-powered-on
> disk drive via the fictitious IN-KERNEL disklabel STRUCTURE.  But, need
> never actually write it to the medium to allow such access (on a NetBSD box).

IIUC, this is a subtle (but important) clarification.

> [I.e., write the entire medium -- except the label portion -- and mount it on
> some foreign OS and they won't see ANY label in place!  But, the DATA that
> you wrote will still be there!]

Yes, of course other OSs won't show anything! Amazing :).

Rocky


Re: BSD disklabel partition letters in NetBSD

2018-09-27 Thread Rocky Hotas
> Sent: Tuesday, September 25, 2018 at 7:52 PM
> From: "Michael van Elst" 
> To: "Rocky Hotas" 
> Cc: netbsd-users@netbsd.org
> Subject: Re: BSD disklabel partition letters in NetBSD
>

[...]

> disklabel is a data structure. If there is none on the disk, it is
> generated from other information.

Do you mean that who generates disklabel collects information about the
disk, cylinders, etc. and creates a brand new data structure? I can't
understand what you are referring to as "other information".

> With MBR, the disklabel is usually placed on relative sector 1 of
> the MBR partition tagged as 'NetBSD' (type 169).
> 
> Without MBR, it is placed on absolute sector 1 of the medium.
> 
> N.B. the sector number can also be platform dependent, most use sector 1
> but some use other sectors.

Ok! Very clear.
For the sake of completeness, let's consider another case, hopefully
interesting to others. If you decide to install on the same disk two or more
BSD systems, all compatible with BSD disklabel (for example, two different
versions of NetBSD, or NetBSD and FreeBSD), would that unique BSD disklabel
in sector 1 of the disk be able to handle this? 
In all the examples I've seen, this data structure is conceived to describe
only a single system, with one root partition (and then optional separate
partitions as /home, /var, /usr according to the administrator's choice, but
all referred to the same root). Multiple OSs would mean multiple root
partitions.
However, it would be very odd if, in order to allow the existence of
multiple BSD OSs, a third-party partitioning scheme as MBR would be needed.
If these questions can be answered by reading some documentation or some
other source and you know the link, I would check it out (unfortunately I
found almost nothing about this).

> wedges are an abstraction that can be used for arbitrary partitioning
> schemes, GPT is the most popular. But I use it for everything, including
> disks that uses the BSD disklabel (you need a custom kernel for that).

Ok!
Again, thank you so much!

Rocky

> 
> 
> Greetings,
> -- 
> Michael van Elst
> Internet: mlel...@serpens.de
> "A potential Snark may lurk in every tree."
> 


Re: BSD disklabel partition letters in NetBSD

2018-09-25 Thread Don NetBSD

On 9/25/2018 10:52 AM, Michael van Elst wrote:

On Tue, Sep 25, 2018 at 05:05:44PM +0200, Rocky Hotas wrote:


only if none is written to disk,
a fictious label is generated from other data like an MBR.


Sorry, I can't understand this. Maybe it's related to the following
description:


disklabel is a data structure. If there is none on the disk, it is
generated from other information.


The problem comes from the fact that the term is severely overloaded.
There is a "data structure", a "portion of the medium" and a "software
program" that all share the name "disklabel".

The (fictitious) data structure needs to be explicitly written to the
medium -- by a sysadm's deliberate actions (most typically, by disklabel(8)!).
Otherwise, it is a purely ephemeral concept.


The disklabel would be used and 'd' would still be the raw partition.
The disklabel would also be placed on sector 1.


So, two disklabels in total. But what would be the contents of the
disklabel in sector 1?


With MBR, the disklabel is usually placed on relative sector 1 of
the MBR partition tagged as 'NetBSD' (type 169).

Without MBR, it is placed on absolute sector 1 of the medium.

N.B. the sector number can also be platform dependent, most use sector 1
but some use other sectors.


But it isn't placed in any of these places unless/until the system is
DIRECTED to do so.  I.e., you can access a brand-new, never-before-powered-on
disk drive via the fictitious IN-KERNEL disklabel STRUCTURE.  But, need
never actually write it to the medium to allow such access (on a NetBSD box).

[I.e., write the entire medium -- except the label portion -- and mount it on
some foreign OS and they won't see ANY label in place!  But, the DATA that
you wrote will still be there!]


Re: BSD disklabel partition letters in NetBSD

2018-09-25 Thread Michael van Elst
On Tue, Sep 25, 2018 at 05:05:44PM +0200, Rocky Hotas wrote:

> > only if none is written to disk,
> > a fictious label is generated from other data like an MBR.
> 
> Sorry, I can't understand this. Maybe it's related to the following
> description:

disklabel is a data structure. If there is none on the disk, it is
generated from other information.


> > The disklabel would be used and 'd' would still be the raw partition.
> > The disklabel would also be placed on sector 1.
> 
> So, two disklabels in total. But what would be the contents of the
> disklabel in sector 1?

With MBR, the disklabel is usually placed on relative sector 1 of
the MBR partition tagged as 'NetBSD' (type 169).

Without MBR, it is placed on absolute sector 1 of the medium.

N.B. the sector number can also be platform dependent, most use sector 1
but some use other sectors.


> > If you don't use disklabel but the wedge system, you get a device per
> > partitition, so there is no inherent limit.
> 
> I guess you are talking about GPT again.
> Sorry for having added some questions and thank you for all your information.

wedges are an abstraction that can be used for arbitrary partitioning
schemes, GPT is the most popular. But I use it for everything, including
disks that uses the BSD disklabel (you need a custom kernel for that).


Greetings,
-- 
Michael van Elst
Internet: mlel...@serpens.de
"A potential Snark may lurk in every tree."


Re: BSD disklabel partition letters in NetBSD

2018-09-25 Thread Rocky Hotas
> Sent: Tuesday, September 25, 2018 at 7:01 AM
> From: "Don NetBSD" 
> To: "NetBSD Users Mailing List" 
> Subject: Re: BSD disklabel partition letters in NetBSD
>
[...]
> I don't want to have to keep notes as to how each machine is (was!)
> configured.  So, it's easier for me to just standardize on an approach
> and commit THAT to memory.

Definitely!

> Having a separate partition for /var helps if some process goes wonky
> and starts to fill the /var "directory" (in the case when /var is part
> of the / partition).  I can get to single user (which almost always
> means the offending process is not running) and work with a / partition
> that isn't overfull with all that /var cruft -- which has been preserved
> on the /var *partition*, if I want to examine it)

I never had this issue, but it's useful to know: this lets you fix.

> I don't know if any architectures (Sun?) still have requirements
> as to where the / partition must reside "physically", on the medium.
> I always lay the partitions out consecutively and contiguously
> just cuz it makes the arithmetic more straightforward.

Putting `/' in the beginning of the disk is easy to remember and very
straightforward. I was asking about the order and letters only to know if
it's also mandatory.

> [There are (?) also some issues wrt sector alignment if you're using
> drives with 4K sectors -- though I think those are only performance
> related (??)]

They would be not a big problem in my case.

> Also consider what OTHER systems might want to have a peek at that
> disk. Make sure your partitioning/GPT/MBR choices are compatible
> there, as well!

> [I physically move disks around a lot and want to be sure each machine
> can access the entire contents of the drive. If the drive is in an
> external enclosure -- SCSI, FW, USB -- then doubly so!]

Yes, of course. I don't move hard disks very frequently, but in general
it's recommended to use a more "universal" partitioning scheme.

Rocky


Re: BSD disklabel partition letters in NetBSD

2018-09-25 Thread Rocky Hotas
> Sent: Monday, September 24, 2018 at 11:56 PM
> From: "Michael van Elst" 
> To: netbsd-users@netbsd.org
> Subject: Re: BSD disklabel partition letters in NetBSD
>

[...]

> The system always uses the disklabel

Yes, IIUC the partition which hosts the NetBSD system always has
a disklabel at its beginning.

> only if none is written to disk,
> a fictious label is generated from other data like an MBR.

Sorry, I can't understand this. Maybe it's related to the following
description:

> The disklabel would be used and 'd' would still be the raw partition.
> The disklabel would also be placed on sector 1.

So, two disklabels in total. But what would be the contents of the
disklabel in sector 1?

> The raw partitition is always special. The extra 'c' partition on MBR
> systems (where the raw partition is 'd') is just helpful but not
> strictly needed. But it's still a good idea to not use it for anything
> else.

Yes, absolutely.

> While it is possible to move root and swap and sometimes it comes handy
> (e.g. to have an alternate root), the default and fallback is to use
> 'a' and 'b'.

Yes, of course, I was asking only to know if they are mandatory or not.

> There is a build parameter MAXPARTITIONS, depending on platform it's 8,12 or 
> 16.
> The maximum value for MAXPARTITIONS is MAXMAXPARTITIONS which is 22.

Ok, good!

> If you don't use disklabel but the wedge system, you get a device per
> partitition, so there is no inherent limit.

I guess you are talking about GPT again.
Sorry for having added some questions and thank you for all your information.

Rocky


Re: BSD disklabel partition letters in NetBSD

2018-09-24 Thread Don NetBSD

On 9/24/2018 12:30 PM, Rocky Hotas wrote:

Now, of course, this all became mood on most modern machines with the move
to GPT, and this is good. As you probably know, we use full devices for
these (dk* and rdk*), so no limiting alphabet nor reserved letters.


Despite vaguely knowing that GPT is replacing MBR and similar, I never
installed NetBSD with GPT, so I didn't know this.


Also consider what OTHER systems might want to have a peek at that
disk.  Make sure your partitioning/GPT/MBR choices are compatible
there, as well!

[I physically move disks around a lot and want to be sure each machine
can access the entire contents of the drive.  If the drive is in an
external enclosure -- SCSI, FW, USB -- then doubly so!]


Re: BSD disklabel partition letters in NetBSD

2018-09-24 Thread Don NetBSD

On 9/24/2018 12:34 PM, Rocky Hotas wrote:

I like to mount /var on 'e', /usr on 'f', /usr/pkg on 'g' (picking up on
the g in pkG as a mnemonic), /home on 'h', /Sources on 'i', /Playpen on 'j'
and /Archive on 'k' (the hard ch as a mnemonic for the k) with /Leftovers
for 'l'.


This is a very clever way to remember the partitions, and also to make them
uniform across several different disks.


I don't want to have to keep notes as to how each machine is (was!)
configured.  So, it's easier for me to just standardize on an approach
and commit THAT to memory.

By putting the "extra" partitions up high, it lets me adapt the same
general layout to systems that only support 8 partitions (/home being
the last -- 'h' -- partition, in those cases).

Having a separate partition for /var helps if some process goes wonky
and starts to fill the /var "directory" (in the case when /var is part
of the / partition).  I can get to single user (which almost always
means the offending process is not running) and work with a / partition
that isn't overfull with all that /var cruft -- which has been preserved
on the /var *partition*, if I want to examine it)

I don't know if any architectures (Sun?) still have requirements
as to where the / partition must reside "physically", on the medium.
I always lay the partitions out consecutively and contiguously
just cuz it makes the arithmetic more straightforward.

[There are (?) also some issues wrt sector alignment if you're using
drives with 4K sectors -- though I think those are only performance
related (??)]


Re: BSD disklabel partition letters in NetBSD

2018-09-24 Thread Michael van Elst
rockyho...@post.com ("Rocky Hotas") writes:

>So, the distinction between systems that only reserve partition "c" and
>those who also reserve partition "d" is the necessity to use MBR.
>I wonder if in those systems one can install BSD disklabel to replace MBR
>(without caring about incompatibilities with other OSs): and, if yes,
>what would be the use of "c" and "d" when MBR doesn't exist at all.

The system always uses the disklabel, only if none is written to disk,
a fictious label is generated from other data like an MBR.

The raw partitition is always special. The extra 'c' partition on MBR
systems (where the raw partition is 'd') is just helpful but not
strictly needed. But it's still a good idea to not use it for anything
else.


>In other words: with amd64, if it is possible to use the whole disk and
>to install BSD disklabel as the only partition table, what would happen?

The disklabel would be used and 'd' would still be the raw partition.
The disklabel would also be placed on sector 1.


>> All other partition letters are free for arbitrary use. Very common (but not
>> mandatory) is "a" as root partition, and "b" as swap.

>Ok!

It's better to use 'a' only as root and 'b' only as swap.

While it is possible to move root and swap and sometimes it comes handy
(e.g. to have an alternate root), the default and fallback is to use
'a' and 'b'.


>Like for `rawdisk', is there any other sysctl parameter with the number of
>available partitions in the current system?

There is a build parameter MAXPARTITIONS, depending on platform it's 8,12 or 16.
The maximum value for MAXPARTITIONS is MAXMAXPARTITIONS which is 22.

This limit is caused by the size of the disklabel structure that has to
fit into a standard block of 512 bytes.

If you don't use disklabel but the wedge system, you get a device per
partitition, so there is no inherent limit.

-- 
-- 
Michael van Elst
Internet: mlel...@serpens.de
"A potential Snark may lurk in every tree."


Re: BSD disklabel partition letters in NetBSD

2018-09-24 Thread Rocky Hotas
> Sent: Saturday, September 22, 2018 at 4:04 PM
> From: "Don NetBSD" 
> To: "NetBSD Users Mailing List" 
> Subject: Re: BSD disklabel partition letters in NetBSD
>
> With the exception of the "whole disk" partition, the others can be used
> as you wish.

Ok!

> As 'c' is "whole disk" on only SOME ports -- with 'd' being the whole disk
> on others -- I don't ever use these for anything but those roles:  consider
> mounting a disk that started out in life on one architecture (port) and now
> you want to mount it on another!

This is a very important thing to take into account.

> I like to mount /var on 'e', /usr on 'f', /usr/pkg on 'g' (picking up on
> the g in pkG as a mnemonic), /home on 'h', /Sources on 'i', /Playpen on 'j'
> and /Archive on 'k' (the hard ch as a mnemonic for the k) with /Leftovers
> for 'l'.

This is a very clever way to remember the partitions, and also to make them
uniform across several different disks.
Thank you for all your advices!

Rocky


Re: BSD disklabel partition letters in NetBSD

2018-09-24 Thread Rocky Hotas
> Sent: Saturday, September 22, 2018 at 11:39 AM
> From: "Martin Husemann" 
> To: "Rocky Hotas" 
> Cc: "NetBSD Users Mailing List" 
> Subject: Re: BSD disklabel partition letters in NetBSD
>
> It is actually quite simple (with a few twists, muahahah :-}):

I guessed it :).

> You can check with "sysctl kern.rawpartition", it is 3 on these architectures.

Ok, thanks!

> Then there are architectures that traditionally required an MBR
> partitioning scheme (usually to cooperate with ancient other OSes), so
> you have to use fdisk before disklabel to partition a disk.

So, the distinction between systems that only reserve partition "c" and
those who also reserve partition "d" is the necessity to use MBR.
I wonder if in those systems one can install BSD disklabel to replace MBR
(without caring about incompatibilities with other OSs): and, if yes,
what would be the use of "c" and "d" when MBR doesn't exist at all.
In other words: with amd64, if it is possible to use the whole disk and
to install BSD disklabel as the only partition table, what would happen?

> All other partition letters are free for arbitrary use. Very common (but not
> mandatory) is "a" as root partition, and "b" as swap.

Ok!

> For the number of disklabel partitions: this depends on the architecture - 
> where the disklabel structure is shared itself with other OSes (say on Sun
> machines) we can not arbitrarily change it. On some others (e.g. VAX)
> there are size limitations due to boot code placement (or similar).

Like for `rawdisk', is there any other sysctl parameter with the number of
available partitions in the current system?

> Now, of course, this all became mood on most modern machines with the move
> to GPT, and this is good. As you probably know, we use full devices for
> these (dk* and rdk*), so no limiting alphabet nor reserved letters.

Despite vaguely knowing that GPT is replacing MBR and similar, I never
installed NetBSD with GPT, so I didn't know this.

> Martin

Thank you!

Rocky


Re: BSD disklabel partition letters in NetBSD

2018-09-22 Thread Don NetBSD

On 9/22/2018 2:24 AM, Rocky Hotas wrote:

As regards NetBSD: this use of ‘a’ and ‘b’ is mandatory? Or is it
possible to arbitrarily change the letter assignments? (E.g. partition
/home to ‘a’ and root partition and swap to ‘e’, ‘f’, ‘g’ ...)

Any suggestion/information about this would be very useful.
Thank you anyway,


With the exception of the "whole disk" partition, the others can be used
as you wish.

However, I've tried to be consistent with my choices.

As 'c' is "whole disk" on only SOME ports -- with 'd' being the whole disk
on others -- I don't ever use these for anything but those roles:  consider
mounting a disk that started out in life on one architecture (port) and now
you want to mount it on another!

I use a small 'a' partition as "/" and 'b' as swap.

I like to mount /var on 'e', /usr on 'f', /usr/pkg on 'g' (picking up on
the g in pkG as a mnemonic), /home on 'h', /Sources on 'i', /Playpen on 'j'
and /Archive on 'k' (the hard ch as a mnemonic for the k) with /Leftovers
for 'l'.

But, that's because most of my boxes are development systems so the ijkl
are considerably different from machine to machine (whereas aefgh tend to
be very similar in content).

Just pick something that you can easily remember.  There WILL be a time
when your box won't go to multiuser and you'll be poking around fstab(5)
with ed(1) instead of vi(1).  It helps to know what to expect, there!


Re: BSD disklabel partition letters in NetBSD

2018-09-22 Thread Martin Husemann
It is actually quite simple (with a few twists, muahahah :-}):

On many architectures there is a single reserved partition, in all cases
I am aware of: "c".

You can check with "sysctl kern.rawpartition", it is 3 on these architectures.

Sparc64 and alpha are examples for this.

Then there are architectures that traditionally required an MBR
partitioning scheme (usually to cooperate with ancient other OSes), so
you have to use fdisk before disklabel to partition a disk.

On these architectures (amd64 is an example) you have sysctl
kern.rawpartition return 4, so the disklabel reserved "whole disk"
partition is "d", and the fdisk reserved part available for disklabel
partitioning is "c".

All other partition letters are free for arbitrary use. Very common (but not
mandatory) is "a" as root partition, and "b" as swap.

For the number of disklabel partitions: this depends on the architecture - 
where the disklabel structure is shared itself with other OSes (say on Sun
machines) we can not arbitrarily change it. On some others (e.g. VAX)
there are size limitations due to boot code placement (or similar).

On architectures where we had the choice, it has been extended to 16.

Now, of course, this all became mood on most modern machines with the move
to GPT, and this is good. As you probably know, we use full devices for
these (dk* and rdk*), so no limiting alphabet nor reserved letters.

Martin