[comp.unix.wizards] Trashed Disk Labels Under Sun OS 3.5

simpson@usc.edu (Scott Simpson) (08/10/89)

How come when I mount all of the disk as swap or anything in an 'a'
partition on a local Micropolis 1355 disk connected to one of our
clients the disk label gets trashed?  I have to recover the label with
diag.  Allocating file systems and swap on the disk shouldn't trash the
disk label, should it?  Sorry if this question was asked before.
	Scott Simpson
	TRW Space and Defense Sector
	usc!trwarcadia!simpson  	(UUCP)
	trwarcadia!simpson@usc.edu	(Internet)

envbvs@epb2.lbl.gov (Brian V. Smith) (08/10/89)

writes:
< 
< How come when I mount all of the disk as swap or anything in an 'a'
< partition on a local Micropolis 1355 disk connected to one of our
< clients the disk label gets trashed?  I have to recover the label with
< diag.  Allocating file systems and swap on the disk shouldn't trash the
< disk label, should it?  Sorry if this question was asked before.


Never put a swap area on partition 'a' of any drive.  The superblock
will be written over by swapping. 
This is true for Ultrix (2.x and 3.0 at least).  I'm not sure
about other os's.
Make at least a small 'a' partition followed by the 'b' swap partition.
_____________________________________
Brian V. Smith    (bvsmith@lbl.gov)
Lawrence Berkeley Laboratory
We don't need no signatures!

chris@mimsy.UUCP (Chris Torek) (08/10/89)

In article <5253@wiley.UUCP> trwarcadia!simpson@usc.edu (Scott Simpson) writes:
>How come when I mount all of the disk as swap or anything in an 'a'
>partition on a local Micropolis 1355 disk connected to one of our
>clients the disk label gets trashed?

SunOS starts swap space at sector 0 of the swapon partition.  The label
is in disk sector 0.  Thus, SunOS will swap on top of the label if the
partition begins at disk sector 0.

4.3BSD-tahoe starts swap space at sector CLSIZE of the swapon
partition, so it never overwrites the first sector (since CLSIZE is at
least 1).  See /sys/sys/vm_swap.c, routine swfree() (when dvbase==0).
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris@mimsy.umd.edu	Path:	uunet!mimsy!chris

chris@mimsy.UUCP (Chris Torek) (08/10/89)

In article <18969@mimsy.UUCP> I wrote:
>... See /sys/sys/vm_swap.c, routine swfree() (when dvbase==0).

Oops, that is /sys/sys/vm_sw.c (or /sys/kern/vm_sw.c in 4.4BSD,
someday).
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris@mimsy.umd.edu	Path:	uunet!mimsy!chris

datri@concave.uucp (Anthony A. Datri) (08/10/89)

>How come when I mount all of the disk as swap or anything in an 'a'
>partition on a local Micropolis 1355 disk connected to one of our
>clients the disk label gets trashed?

Sun's RTF or release notes document this -- the label occupys the
first sector (track?) on the disk, and using the normal a partition
as swap overwrites it; it seems that the filesystem code skips over it.
Their solution is to make a 1 cylinder a partition, then have b go
from there to the end of the disk, and use b for swap.  I suspect that
making the label with the a parititon starting at cylinder 1 instead of
0 would work as well.

mojo@legato (Joseph Moran) (08/11/89)

In article <18969@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes:
>SunOS starts swap space at sector 0 of the swapon partition.  The label
>is in disk sector 0.  Thus, SunOS will swap on top of the label if the
>partition begins at disk sector 0.

SunOS 3.x and earlier followed the conventions of 4.2 BSD for
allocating swap space which resulted in disk labels and boot blocks
getting trashed if you swapped onto a partition that started at
cylinder 0 (typically `a' and `c').

SunOS 4.0 and greater has a totally different VM system.  During this
rewrite, code was added to skip over the first part of each swap device
to prevent the "disk label overwrite" problem.

Joseph Moran
Legato Systems, Inc.
260 Sheridan Avenue
Palo Alto, CA  94306
(415) 329-7886
mojo@Legato.COM or {sun,uunet}!legato!mojo

idall@augean.OZ (Ian Dall) (08/11/89)

In article <3555@helios.ee.lbl.gov> envbvs@epb2.lbl.gov (Brian V. Smith) writes:
->writes:
->< 
->< How come when I mount all of the disk as swap or anything in an 'a'
->< partition on a local Micropolis 1355 disk connected to one of our
->< clients the disk label gets trashed?  I have to recover the label with
->< diag.  Allocating file systems and swap on the disk shouldn't trash the
->< disk label, should it?  Sorry if this question was asked before.
->
->
->Never put a swap area on partition 'a' of any drive.  The superblock
->will be written over by swapping. 
->This is true for Ultrix (2.x and 3.0 at least).  I'm not sure
->about other os's.
->Make at least a small 'a' partition followed by the 'b' swap partition.

Well, at SysV got something right. The version I have (at least) keeps
the partition table (= "label") on the first sectors of the disk and
this is stuck in its own partition. On my system partition "6" is the
first cylinder (0) of the disk and has no file system on it. You arrange
for other partitions to NOT include cyinder 0.

I see no reason why one could not do this with SunOS.  I think that it
is a really bad idea to have swap/mkfs etc. have special code to skip
the first cylinder if it is the "a" partition.


-- 
 Ian Dall           life (n). A sexually transmitted disease which afflicts
                              some people more severely than others.
idall@augean.oz

chris@mimsy.UUCP (Chris Torek) (08/12/89)

In article <557@augean.OZ> idall@augean.OZ (Ian Dall) writes:
>Well, at SysV got something right.

(sort of)

>I think that it is a really bad idea to have swap/mkfs etc. have special
>code to skip the first cylinder if it is the "a" partition.

They should not skip the first cylinder; that would be wasteful.

They should (and do) skip the label sector (on 4.3BSD-tahoe).  File
systems furthermore skip the boot block area.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris@mimsy.umd.edu	Path:	uunet!mimsy!chris