Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 16 Mar 1996 10:41:00 +1100
From:      Bruce Evans <bde@zeta.org.au>
To:        freebsd-SCSI@FreeBSD.org, risner@stdio.com
Subject:   Re: Disk problems
Message-ID:  <199603152341.KAA21405@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>I have having several problems with 2.2-SNAP 3-3 *AND* 2.1-RELEASE.

Don't use the 3-3 SNAP.  -current was more unstable on 3-3 than at
any other time in the last 4 months.

>8 meg, 486-sx-25 ASUS VL/I-486SV2GX4, SMC ethernet

>SCSI = FDC 850 8bit "seagate"
>1 conner 100 meg (Digital RZ23 SCSI) 
>1 seagate 235 meg ST1239N
>1 Emulex ESDI - SCSI with one ESDI disk formatted

>[things I don't know anything about...]

>I got it installed on the Seagate, but when adding the other disks I noticed
>that the FDC/Seagate controller boots from ID 6 down.  FreeBSD assigns disks
>from ID 0 and up, so it can't mount the root with more than one disk installed.

The Minutes of the SCSI PnP Meeting 1 (which I found at ftp.symbios.com)
discuss this problem.  It seems that scanning the scsi bus from id 6 down,
or at least booting from the drive on the highest id, is best, but people
can't quite agree.  All my controllers (ultrastor, buslogic, ncr) seem to
scan from the bottom up so I don't normally notice that the the FreeBSD
order isn't always right.  However, I noticed that this problem combined
with the old problem of assigning BIOS drives numbers to FreeBSD unit
numbers gave interesting behaviour when I changed some Ids to the "correct"
ones:

my default, working  setup:
	boot drive on Id 3
	Zip drive on Id 5
"correct", broken setup:
	boot drive on Id 6
	Zip drive on Id 5
		case 1: Zip disk in drive
			boot drive is actually Zip drive; BIOS and FreeBSD
			agree that it is unit 0; no problems provided there
			is a suitable MBR (and FreeBSD :-) on the Zip drive
		case 2: no ZIp disk in drive
			BIOS doesn't see the Zip drive but FreeBSD does,
			so the drive on Id 6 has BIOS number 0 and FreeBSD
			unit number 1.  Oops.  This is with an ASUS NCR
			controller _not_ using the BIOS option to treat
			removable drives as fixed drives (using this option
			seems to screw up media change).

Here are my bootblock changes to allow specifying the FreeBSD unit number
independently of the BIOS drive number at boot time.

Bruce

diff -c2 src/sys/i386/boot/biosboot/Makefile~ src/sys/i386/boot/biosboot/Makefile
*** src/sys/i386/boot/biosboot/Makefile~	Sat Mar  9 04:42:23 1996
--- src/sys/i386/boot/biosboot/Makefile	Sun Mar 10 17:26:35 1996
***************
*** 21,28 ****
  #CFLAGS+=	-DFORCE_COMCONSOLE
  
! # Assume hd(*,a) instead of wd(*,a) if the boot seems to happen from
! # a hard disk.
! # This can be useful for people booting in a mixed IDE/SCSI environment.
! #CFLAGS+=	-DBOOT_HD
  
  CLEANFILES+=	boot.nohdr boot.strip boot1 boot2 sizetest
--- 22,31 ----
  #CFLAGS+=	-DFORCE_COMCONSOLE
  
! # Bias the conversion from the BIOS drive number to the FreeBSD unit number
! # for hard disks to save typing.  E.g., BOOT_HD_BIAS=1 makes BIOS drive 1
! # correspond to 1:sd(0,a) instead of 1:sd(1,a).
! # This may be useful for people booting in a mixed IDE/SCSI environment
! # (set BOOT_HD_BIAS to the number of IDE drives).
! #CFLAGS+=	-DBOOT_HD_BIAS=1
  
  CLEANFILES+=	boot.nohdr boot.strip boot1 boot2 sizetest
diff -c2 src/sys/i386/boot/biosboot/README.386BSD~ src/sys/i386/boot/biosboot/README.386BSD
*** src/sys/i386/boot/biosboot/README.386BSD~	Fri Feb 17 08:57:51 1995
--- src/sys/i386/boot/biosboot/README.386BSD	Sun Mar 10 16:59:28 1996
***************
*** 103,116 ****
  
  ##########################################################################
! In the case you have two drives the same type (both scsi or bith IDE/ESDI),
! wd(0,a)xxx
! 	will boot xxx from drive 0, a partition.
! wd(1,a)xxx
! 	will boot xxx from drive 1, a partition.
  
! similarly for sd.
  
! if you have one wd drive and one scsi drive, then you MUST
! use device 'hd'
  
  otherwise the following will happen:
--- 103,119 ----
  
  ##########################################################################
! In the case you have several drives the same type (all scsi or all IDE/ESDI),
! 	wd(0,a)xxx
! will boot xxx from drive 0, a partition.
! 	wd(1,a)xxx
! will boot xxx from drive 1, a partition.
  
! similarly for sd and for higher drive numbers (if the BIOS supports them).
  
! if you have one or more wd drives and one or more scsi drives, then yo
! MUST specify the BIOS drive number for booting the scsi drives:
! 	2:sd(0,a)xxx
! will boot xxx from scsi drive 0, a partition, provided `2' is the correct
! BIOS drive number for sd0.
  
  otherwise the following will happen:
***************
*** 119,126 ****
  it boots the kernel correctly, then tells the kernel to use sd1 as root.
  you however may not have an sd1, and problems arise.
- 
- hd is special in that the kernel is always told to use unit 0,
- The correct TYPE of device will be specified too, so the kernel
- will be told either sd0 or wd0.
  
  Whether sd or wd is specified to the kernel is read from the disklabel,
--- 122,125 ----
diff -c2 src/sys/i386/boot/biosboot/README.serial~ src/sys/i386/boot/biosboot/README.serial
*** src/sys/i386/boot/biosboot/README.serial~	Fri Apr 21 19:43:53 1995
--- src/sys/i386/boot/biosboot/README.serial	Mon Mar 11 07:19:23 1996
***************
*** 77,83 ****
  
    >> FreeBSD BOOT @ 0x10000: 640/7168 k of memory
!   Use hd(1,a)/kernel to boot sd0 when wd0 is also installed.
!   Usage: [[[fd(0,a)]/kernel][-s][-r][-a][-c][-d][-b][-v][-h]]
!   Use ? for file list or simply press Return for defaults
    Boot:
  
--- 77,83 ----
  
    >> FreeBSD BOOT @ 0x10000: 640/7168 k of memory
!   Usage: [[[0:][fd](0,a)]/kernel][-abcCdhrsv]
!   Use 1:sd(0,a)kernel to boot sd0 if it is BIOS drive 1
!   Use ? for file list or press Enter for defaults
    Boot:
  
diff -c2 src/sys/i386/boot/biosboot/boot.c~ src/sys/i386/boot/biosboot/boot.c
*** src/sys/i386/boot/biosboot/boot.c~	Sat Mar  9 04:42:24 1996
--- src/sys/i386/boot/biosboot/boot.c	Sun Mar 10 18:24:39 1996
***************
*** 101,117 ****
  	gateA20();
  
! 
! 	/***************************************************************\
! 	* As a default set it to the first partition of the boot	*
! 	* floppy or hard drive						*
! 	* Define BOOT_HT to boot sd0 when wd0 is also installed		*
! 	\***************************************************************/
! 	part = 0;
  	unit = drive & 0x7f;
! #ifdef	BOOT_HD
! 	maj = (drive&0x80 ? 1 : 2);		/* a good first bet */
! #else
! 	maj = (drive&0x80 ? 0 : 2);		/* a good first bet */
  #endif
  
  loadstart:
--- 110,135 ----
  	gateA20();
  
! 	/*
! 	 * The default boot device is the first partition in the
! 	 * compatibility slice on the boot drive.
! 	 */
! 	dosdev = drive;
! 	maj = 2;
  	unit = drive & 0x7f;
! #ifdef dontneed
! 	slice = 0;
! 	part = 0;
! #endif
! 	if (drive & 0x80) {
! 		/*
! 		 * Hard drive.  Adjust.  Guess that the FreeBSD unit number
! 		 * is the BIOS drive number biased by BOOT_HD_BIAS,
! 		 */
! 		maj = 0;
! #if BOOT_HD_BIAS > 0
! 		if (BOOT_HD_BIAS <= unit)
! 			unit -= BOOT_HD_BIAS;
  #endif
+ 	}
  
  loadstart:
***************
*** 119,127 ****
  	/* If we have looped, use the previous entries as defaults */
  	printf("\n>> FreeBSD BOOT @ 0x%x: %d/%d k of memory\n"
! 	       "Use hd(1,a)/kernel to boot sd0 when wd0 is also installed.\n"
! 	       "Usage: [[%s(%d,a)]%s][-abcCdhrsv]\n"
  	       "Use ? for file list or press Enter for defaults\n\nBoot: ",
  	       ouraddr, bootinfo.bi_basemem, bootinfo.bi_extmem,
! 	       devs[maj], unit, name);
  
  	name = dflname;		/* re-initialize in case of loop */
--- 137,145 ----
  	/* If we have looped, use the previous entries as defaults */
  	printf("\n>> FreeBSD BOOT @ 0x%x: %d/%d k of memory\n"
! 	       "Usage: [[[%d:][%s](%d,a)]%s][-abcCdhrsv]\n"
! 	       "Use 1:sd(0,a)kernel to boot sd0 if it is BIOS drive 1\n"
  	       "Use ? for file list or press Enter for defaults\n\nBoot: ",
  	       ouraddr, bootinfo.bi_basemem, bootinfo.bi_extmem,
! 	       dosdev & 0x7f, devs[maj], unit, name);
  
  	name = dflname;		/* re-initialize in case of loop */
***************
*** 167,171 ****
  	startaddr = head.a_entry & 0x00FFFFFF;
  	addr =  startaddr;
! 	printf("Booting %s(%d,%c)%s @ 0x%x\n"
  			, devs[maj]
  			, unit
--- 185,190 ----
  	startaddr = head.a_entry & 0x00FFFFFF;
  	addr =  startaddr;
! 	printf("Booting %d:%s(%d,%c)%s @ 0x%x\n"
! 			, dosdev & 0x7f
  			, devs[maj]
  			, unit
diff -c2 src/sys/i386/boot/biosboot/sys.c~ src/sys/i386/boot/biosboot/sys.c
*** src/sys/i386/boot/biosboot/sys.c~	Mon Jun 26 15:07:31 1995
--- src/sys/i386/boot/biosboot/sys.c	Mon Mar 11 04:06:41 1996
***************
*** 39,42 ****
--- 39,44 ----
  #endif
  
+ static char biosdrivedigit;
+ 
  #define BUFSIZE 8192
  #define MAPBUFSIZE BUFSIZE
***************
*** 165,169 ****
  {
  	char **devp, *cp = name;
! 	int ret;
  	/*******************************************************\
  	* If bracket given look for preceding device name	*
--- 167,172 ----
  {
  	char **devp, *cp = name;
! 	int biosdrive, ret;
! 
  	/*******************************************************\
  	* If bracket given look for preceding device name	*
***************
*** 177,180 ****
--- 180,193 ----
  	else
  	{
+ 		/*
+ 		 * Look for a BIOS drive number (a leading digit followed
+ 		 * by a colon).
+ 		 */
+ 		if (*(name + 1) == ':' && *name >= '0' && *name <= '9') {
+ 			biosdrivedigit = *name;
+ 			name += 2;
+ 		} else
+ 			biosdrivedigit = '\0';
+ 
  		if (cp++ != name)
  		{
***************
*** 211,232 ****
  			return 1;
  	}
  	switch(maj)
  	{
- 	case 1:
- 		dosdev = unit | 0x80;
- 		unit = 0;
- 		break;
  	case 0:
  	case 4:
! 		dosdev = unit | 0x80;
  		break;
  	case 2:
! 		dosdev = unit;
  		break;
! 	case 3:
! 		printf("Wangtek unsupported\n");
  		return 1;
- 		break;
  	}
  	inode.i_dev = dosdev;
  	/***********************************************\
--- 224,256 ----
  			return 1;
  	}
+ 	if (biosdrivedigit != '\0')
+ 		biosdrive = biosdrivedigit - '0';
+ 	else {
+ 		biosdrive = unit;
+ #if BOOT_HD_BIAS > 0
+ 		/* XXX */
+ 		if (maj == 4)
+ 			biosdrive += BOOT_HD_BIAS;
+ #endif
+ 	}
  	switch(maj)
  	{
  	case 0:
  	case 4:
! 		dosdev = biosdrive | 0x80;
  		break;
  	case 2:
! 		dosdev = biosdrive;
  		break;
! 	default:
! 		printf("Unknown device\n");
  		return 1;
  	}
+ 	printf("dosdev = %x, biosdrive = %d, unit = %d, maj = %d\n",
+ 		dosdev, biosdrive, unit, maj);
+ #if 0
+ 	getchar(0);
+ #endif
+ 
  	inode.i_dev = dosdev;
  	/***********************************************\
diff -c2 src/sys/i386/boot/biosboot/table.c~ src/sys/i386/boot/biosboot/table.c
*** src/sys/i386/boot/biosboot/table.c~	Sat Mar  9 04:42:24 1996
--- src/sys/i386/boot/biosboot/table.c	Sun Mar 10 15:47:40 1996
***************
*** 137,141 ****
   * fragmentation.
   */
! char *devs[] = { "wd", "hd", "fd", "wt", "sd", 0 };
  char dflname[] = "/kernel";
  char *name = dflname;
--- 137,141 ----
   * fragmentation.
   */
! char *devs[] = { "wd", "dk", "fd", "wt", "sd", 0 };
  char dflname[] = "/kernel";
  char *name = dflname;



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