Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Oct 2000 17:31:12 -0700 (PDT)
From:      Matt Dillon <dillon@earth.backplane.com>
To:        John Baldwin <jhb@FreeBSD.org>
Cc:        Terry Lambert <tlambert@primenet.com>, (Paul Saab) <paul@mu.org>, (Danny Braniss) <danny@cs.huji.ac.il>, freebsd-stable@FreeBSD.org, hackers@FreeBSD.org, (Matt Dillon) <dillon@earth.backplane.com>
Subject:   Re: Really odd "BTX halted" problem booting FreeBSD on VALinux h
Message-ID:  <200010280031.e9S0VCl55795@earth.backplane.com>
References:   <XFMail.001027171214.jhb@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
:> I think you are specifying the wrong arguments to disklabel; I
:> seem to rememebr a -w/-W distinction...
:
:Nope.
:
:> In any case, I'm running with a disklabel inside a DOS partition
:> on all but one box of mine, and always have been.  I installed
:> 4.1 on my laptop that way.
:
:Sysinstall can create a disklabel inside of a MBR slice fine.  The
:problem is that the disklabel(8) _program_ itself doesn't know how
:to create a virgin disklabel for a MBR slice.
:
:-- 
:
:John Baldwin <jhb@FreeBSD.org> -- http://www.FreeBSD.org/~jhb/

    The patchset I put on the lists earlier today will allow disklabel
    to install a virgin label on a slice.  Did it not get out?  As matters 
    currently stand, disklabel can only edit a preexisting label on a slice.

    I'll post it again... included below (this time without the file
    descriptor cruft that snuck into my previous posting of the patch).  With
    the patch you can do this:

	# optional dd if you are paranoid
	# dd if=/dev/zero of=/dev/da0 bs=32k count=4
	fdisk -I da0
	disklabel -w -r da0s1 auto

    That's much preferable to having to use sysinstall if all you want to
    do is initialize a label on a slice.

						-Matt

Index: sbin/disklabel/disklabel.c
===================================================================
RCS file: /home/ncvs/src/sbin/disklabel/disklabel.c,v
retrieving revision 1.28.2.3
diff -u -r1.28.2.3 disklabel.c
--- sbin/disklabel/disklabel.c	2000/07/01 06:47:46	1.28.2.3
+++ sbin/disklabel/disklabel.c	2000/10/27 19:24:00
@@ -1347,10 +1347,17 @@
 		warn("cannot open %s", namebuf);
 		return (NULL);
 	}
-	if (ioctl(f, DIOCGDINFO, &lab) < 0) {
-		warn("ioctl DIOCGDINFO");
-		close(f);
-		return (NULL);
+
+	/*
+	 * Try to use the new get-virgin-label ioctl.  If it fails,
+	 * fallback to the old get-disdk-info ioctl.
+	 */
+	if (ioctl(f, DIOCGDVIRGIN, &lab) < 0) {
+	    if (ioctl(f, DIOCGDINFO, &lab) < 0) {
+		    warn("ioctl DIOCGDINFO");
+		    close(f);
+		    return (NULL);
+	    }
 	}
 	close(f);
 	lab.d_boot0 = NULL;
Index: sys/kern/subr_diskslice.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/subr_diskslice.c,v
retrieving revision 1.82
diff -u -r1.82 subr_diskslice.c
--- sys/kern/subr_diskslice.c	2000/01/28 11:51:08	1.82
+++ sys/kern/subr_diskslice.c	2000/10/27 19:23:28
@@ -366,12 +366,46 @@
 	int	slice;
 	struct diskslice *sp;
 	struct diskslices *ssp;
+	struct partition *pp;
 
 	slice = dkslice(dev);
 	ssp = *sspp;
 	sp = &ssp->dss_slices[slice];
 	lp = sp->ds_label;
 	switch (cmd) {
+
+	case DIOCGDVIRGIN:
+		lp = (struct disklabel *)data;
+		if (ssp->dss_slices[WHOLE_DISK_SLICE].ds_label) {
+			*lp = *ssp->dss_slices[WHOLE_DISK_SLICE].ds_label;
+		} else {
+			bzero(lp, sizeof(struct disklabel));
+		}
+
+		lp->d_magic = DISKMAGIC;
+		lp->d_magic2 = DISKMAGIC;
+		pp = &lp->d_partitions[RAW_PART];
+		pp->p_offset = 0;
+		pp->p_size = sp->ds_size;
+
+		lp->d_npartitions = MAXPARTITIONS;
+		if (lp->d_interleave == 0)
+			lp->d_interleave = 1;
+		if (lp->d_rpm == 0)
+			lp->d_rpm = 3600;
+		if (lp->d_nsectors == 0)
+			lp->d_nsectors = 32;
+		if (lp->d_ntracks == 0)
+			lp->d_ntracks = 64;
+
+		lp->d_bbsize = BBSIZE;
+		lp->d_sbsize = SBSIZE;
+		lp->d_secpercyl = lp->d_nsectors * lp->d_ntracks;
+		lp->d_ncylinders = sp->ds_size / lp->d_secpercyl;
+		lp->d_secperunit = sp->ds_size;
+		lp->d_checksum = 0;
+		lp->d_checksum = dkcksum(lp);
+		return (0);
 
 	case DIOCGDINFO:
 		if (lp == NULL)


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200010280031.e9S0VCl55795>