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: Trimming a diskless distribution

2018-10-04 Thread Cág
Don wrote:

> To date, I've been exporting an *empty* filesystem and incrementally adding
> stuff to it, based on errors detected in the process of going to singleuser...
> and, likewise, proceeding on to multiuser.

It's always nice to see that you are not alone :)

--
caóc



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


Trimming a diskless distribution

2018-10-04 Thread Don NetBSD

A question similar, in spirit, to that of Cág ("Correct way to trim the
distribution?")

What's a "good" way to trim the exported filesystem for a diskless
system?  (The goal being to eventually crunchgen a local system image
and eliminate the NFS mount entirely)

To date, I've been exporting an *empty* filesystem and incrementally adding
stuff to it, based on errors detected in the process of going to singleuser...
and, likewise, proceeding on to multiuser.

Of course, late bindings are a potential SNAFU in this approach -- unless
I inherently know how to precipitate those events!


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