Subject: Re: shooting oneself in the foot
To: None <tech-kern@netbsd.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-kern
Date: 01/16/2002 16:11:28
>> disklabel(8) should not be allowing modifications of mounted
>> filesystems (by checking at write time).
> Ok, My system has been running with root on wd0a, I've generated a
> new root filesystem (say for a new version of netbsd) on wd0h.  [...]
> So what I want to do is swap over wd0a and wd0h on the disklabel and
> reboot.

There are two disklabels here: the on-disk one and the in-core one.
Modifying the in-core one in such a way as to move a mounted filesystem
is a Dangerous Thing and hence arguably shouldn't be allowed.
Modifying the on-disk one _without_ modifying the in-core one is a much
more reasonable thing to do, and is probably what you want here.

If disklabel(8) can't do it, that's a deficiency in disklabel(8).  I'd
use bsdlabel (which I wrote for frobbing BSD disklabels even on
machines whose kernels don't grok them) for this.  You'll need
something of the sort (to write disklabels the kernel doesn't grok) for
cross-installs anyway.

Greywolf suggests

> NetBSD# cd /usr/mdec
> NetBSD# ./installboot bootbios.sym /dev/rwd0h

That might make it boot from wd0h.  It wouldn't achieve the stated goal
(which is to swap the name->partition mapping so that you still call
your boot partition wd0a, but it's the piece of the disk that used to
be called wd0h).

alfred suggests

> boot single user, read-only root, do your mucking/mirroring, swap the
> disklabel then reboot...

Not enough - you're still mucking with a mounted partition.  Moving
partitions out from under a read-only fs is almost as dangerous as a
read-write fs.  (You might not corrupt the disk, but you quite likely
will panic the system.)

Those said, for what little it may be worth, I am opposed to anything
more than a warning when doing this.  Changing disklabels, to me, is a
YAFIYGI operation.

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML	       mouse@rodents.montreal.qc.ca
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B