*BSD News Article 28921


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!munnari.oz.au!spool.mu.edu!howland.reston.ans.net!cs.utexas.edu!swrinde!ihnp4.ucsd.edu!news.acns.nwu.edu!ftpbox!mothost!mdisea!mmddvan!vanbc.wimsey.com!rwsys.wimsey.bc.ca!rw
From: rw@rwsys.wimsey.bc.ca (Randy Wright)
Newsgroups: comp.unix.bsd
Distribution: world
Subject: Re: NetBSD + DOS coexisting
References: <1994Mar31.220958.2405@ludens>
Message-ID: <9404011520@rwsys.wimsey.bc.ca>
Organization: RW development, Surrey BC, Canada
Date: Fri,  1 Apr 94 13:22:07 PST
Lines: 109

csb@Augusta (Csizmazia Balazs) writes:
> Hello, World!
> 
>   I tried to install NetBSD 0.9 - it succeeded, but the disklabel
> deleted my previouis DOS=Linux partition.
> With a partition editor I restored the loss data - but I was not very successful.
> I merked: NetBSD will bel always installed at the 4. partition. Is it
> true?
> Where begins the disk sector numbering? From 1 or from 0?
> Rewrites the disklabel always the bootsector?
> Is this problem solved in NetBSD-current? Or I made a mistake?
> 
> 
>                        Regards:
> 
>                               Csizmazia Balazs
>                               csb@tomx.elte.hu
> 
disklabel uses NetBSD's internal partitioning scheme. This
is not the same as the dos partition table that occurs at
block 0 on your drive (not necessarily block 0 of your
first NetBSD partition).

I wrote a small utility to get the dos partitioning info from
my drive. You can modify it in order to change the partition
info and rewrite the partition block. My drive has NetBSD installed
on partition 3 and Coherent on partition 0 with a boot selection
program installed in the partition block. My NetBSD partition
is laid ot with 3 file systems addressed as wd0a, kernfs and wd0e.

In order to get at the dos partition tables from NetBSD, I used
/dev/rwd0d. I have included the program so you can see what
it does. 


--Randy
----cut here---
/* filename	: partget.c
 * purpose	: get dos partition info
 * author	: Randy Wright
 *
 * copyright ((C)) 1994 Randy Wright.
 * permission is granted to distribute, use and modify
 * this file provided this copyright notice remains attached
 * and unmodified.
 * 
 * Compile instructions:
 *	cc partget.c -o partget
 *
 * Usage:
 *	partget <RawDevice>
 *
 * Example:
 * 	partget /dev/rwd0d 
 */

#include <fcntl.h>
#include "/usr/src/sys/sys/disklabel.h"
#include <stdio.h>
#include <errno.h>

main( argc, argv )
int argc;
char ** argv;
{
	int fd, i;			/* file descriptor and iterator */
	struct dos_partition * mypart; 	/* defined in disklabel.h */
	char buf[521];			/* a buffer to read in the partition block */
	

	if( (fd= open( argv[1], O_RDONLY )) < 0 ) {
		perror( "partget open: " ); 
		exit(1); 
	}

	if( (lseek( fd , 0L, 0 )) < 0 ) {
		perror( "partget lseek: " );
		exit(1);
	}

	if( (read( fd , buf, 512 )) != 512 ) {
		perror( "partget read : " );
		exit(1);
	}

	mypart = &buf[446];

		/* the macros DPSECT and DPCYL are defined in
   		 * disklabel.h. The 2 high order bits of dp_esec
		 * and dp_bsec contain the 2 high order bits of
		 * dp_ecyl and dp_bcyl respectively
                 */
	for ( i = 0; i < 4; i++, mypart++ ) {
		printf( "Partition %d\n", i );
		printf( "\tflags:%x \ttype:%x\n\tbhd:%x ssect:%x scyl:%x\n\t ehd:%x esect:%x ecyl:%x\n\tbase:%x size:%x\n",
			mypart->dp_flag, mypart->dp_typ,
			mypart->dp_shd, DPSECT( mypart->dp_ssect ), DPCYL( mypart->dp_scyl, mypart->dp_ssect ),
			mypart->dp_ehd, DPSECT( mypart->dp_esect ), DPCYL( mypart->dp_ecyl, mypart->dp_esect ),
			mypart->dp_start, mypart->dp_size );
	}
	exit(0);
}
/* end partget.c */

---cut here----
____________________________________________________________________________
rw@rwsys.wimsey.bc.ca (Randy Wright)                        (604) 581-0518
                ICBM address = 49d 12m 5s N    122d 51m 49s W
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--