[comp.os.minix] ibmpc: fdisk problem & partition

rtregn@immd3.informatik.uni-erlangen.de (Robert Regn) (12/07/88)

In article <283@ge1cbx.UUCP>,  usenet@ge1cbx.UUCP (Terry Lee) writes:
> the fdisk on minix 1.2 seems to be bugged in that the partition numbers it
> reports is incorrect, and does not correspond to /dev/hd* or anything else.

Fdisk shows the entries in the partition table without ordering.
The  REAL partition number (for /dev/hd? - by the driver determined) is given
by the rule: lowest part. = hd1, highest = hd4.

> Has anyone experienced this problem?
I think, in doc/READ_ME are some words about it.


In article <388@ives.randvax.UUCP>, edhall@randvax.UUCP (Ed Hall) writes:
> 
> Be CAREFUL!  I managed to render my DOS partition unbootable by using
> Minix fdisk.  I was never able to figure out quite why, either.


Peculiar. Should not be. You must have destroyed you DOS partition
and remade it. Probably your forgot making it active?
Or you have a disk with more than 4 heads and not changed fdisk ?

For such disks I have a little improved fdisk.c. It's usage is:
		 fdisk [-heads] [/dev/hdx]
The default is -4  and /dev/hd0. It recognizes DOS4 (for 3.3) and
Xenix partitions also.
Cdiffs follow

***
BTW: We should establish a system indicator number for Minix.
(possibly two different for root image and /usr )

With it, it will be possible to make a system which has the root fs
on HD with a NOT hard-coded partition number. This number can be determined
with the system indicator for Minix.  Such a boot floppy will be portable!


*** minix/1.3/a.fertig/commands/fdisk.c	Tue Oct  4 12:43:10 1988
--- FDISK.C	Tue Dec  6 16:53:34 1988
***************
*** 55,61 ****
--- 55,64 ----
  char	secbuf[SECSIZE];
  char	*devname;
  char	*dosstr  = "  DOS  ";
+ char	*dosstr4 = " DOS  4";
  char	*ndosstr = "Non-DOS";
+ char	*xenstr = " Xenix ";
+ int heads;
  
  #ifdef DOS
  union	REGS	regs;
***************
*** 75,86 ****
  
  	/* init */
  
! 	if (argc != 2) {
! 		printf("Usage: fdisk /dev/hdx\n");
  		exit(1);
  	}
  
! 	devname = argv[1];
  	getboot(secbuf);	/* get boot sector	*/
  
  	do {
--- 78,99 ----
  
  	/* init */
  
! 	if (  argc > 1 && (*++argv)[0] == '-')		/*flag*/
! 		{heads = atoi( & (*argv)[1]);
! 		 printf("heads: %d	", heads);
! 		 argv++;
! 		 argc--;
! 		}
! 	else	heads = NHEAD;
! 
! 	if (argc > 2) {
! 		printf("Usage: fdisk [-heads] [/dev/hdx]\n");
  		exit(1);
  	}
  
! 	if ( argc == 1)
! 		devname = "/dev/hd0";
! 	else	devname = *argv;
  	getboot(secbuf);	/* get boot sector	*/
  
  	do {
***************
*** 339,346 ****
  
  	if (entry->sysind == 0x01)
  		typestring = dosstr;
! 	else
! 		typestring = ndosstr;
  	printf("%5d         %s  ",number,typestring);
  	temp = entry->start_sec & 0xc0;
  	low_cyl = (entry->start_cyl & 0xff) + (temp << 2);
--- 352,363 ----
  
  	if (entry->sysind == 0x01)
  		typestring = dosstr;
! 	else	if (entry->sysind == 0x02)
! 		typestring = xenstr;
! 	else	if (entry->sysind == 0x04)
! 		typestring = dosstr4;
! 		else
! 			typestring = ndosstr;
  	printf("%5d         %s  ",number,typestring);
  	temp = entry->start_sec & 0xc0;
  	low_cyl = (entry->start_cyl & 0xff) + (temp << 2);
***************
*** 423,432 ****
  {
  	int	bigcyl;
  
! 	bigcyl = logsec / (NHEAD * NSEC);
  	*sec = (logsec % NSEC) + 1 + ((bigcyl >> 2) & 0xc0);
  	*cyl = bigcyl & 0xff;
! 	*hd = (logsec % (NHEAD * NSEC)) / NSEC;
  }
  
  /*
--- 440,449 ----
  {
  	int	bigcyl;
  
! 	bigcyl = logsec / (heads * NSEC);
  	*sec = (logsec % NSEC) + 1 + ((bigcyl >> 2) & 0xc0);
  	*cyl = bigcyl & 0xff;
! 	*hd = (logsec % (heads * NSEC)) / NSEC;
  }
  
  /*
***************
*** 487,497 ****
  		return;
  	}
  	low = first & 0xffff;
! 	low = low * NSEC * NHEAD;
  	if (low == 0)
  		low = 1; /* sec0 is master boot record */
  	high = last & 0xffff;
! 	high = (high + 1)*NSEC*NHEAD - 1;
  	entry->lowsec = low;
  	entry->size = high - low + 1;
  	sec_to_hst(low,
--- 504,514 ----
  		return;
  	}
  	low = first & 0xffff;
! 	low = low * NSEC * heads;
  	if (low == 0)
  		low = 1; /* sec0 is master boot record */
  	high = last & 0xffff;
! 	high = (high + 1)*NSEC*heads - 1;
  	entry->lowsec = low;
  	entry->size = high - low + 1;
  	sec_to_hst(low,
		Robert Regn	
rtregn@faui32.uucp
rtregn@immd3.informatik.uni-erlangen.de			West Germany