Bug 24435

Summary: [libdisk] [patch] changing slice type causes Auto-partition to not work
Product: Base System Reporter: Robert Watson <rwatson>
Component: kernAssignee: Bruce Cran <brucec>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.2-RELEASE   
Hardware: Any   
OS: Any   

Description Robert Watson freebsd_committer freebsd_triage 2001-01-18 17:10:01 UTC
A co-worker of mine was installing FreeBSD 4.2-RELEASE on a machine
that previously held two FAT partitions.  Rather than delete and
recreate the first partition to change it to a FreeBSD partition,
he changed the partition "type" using T.  The slice editor then showed
"the right thing".  However, when he then got to partition allocation,
hitting A resulted in the following message:

  Unable to create the root partition. Too big?

Going back and deleting the FreeBSD slice (was a FAT slice), then creating
it again caused auto-partitioning to work fine.  It sounds like the
change in slice type is not being propagated properly to the partitioning
phase.  Also, it sounds like the debugging output from the partition
creation is a tad on the not-so-specific-side.

Fix: 

Not attached.
How-To-Repeat: 
Use Partition Magic, DOS Fdisk, or some other magic tool to create
two FAT partitions on a disk.  Then run the 4.2-RELEASE install floppies
and use T to change the first slice to a FreeBSD partition.  Then
continue to the FreeBSD partitioning screen, and hit A for automatic
partition creation.  The failure should occur.
Comment 1 Vallo Kallaste 2001-01-19 06:04:59 UTC
On Thu, Jan 18, 2001 at 12:09:31PM -0500, rwatson@FreeBSD.ORG wrote:

> 
> >Number:         24435
> >Category:       bin
> >Synopsis:       Changing slice type causes Auto-partition to not work
> 
> A co-worker of mine was installing FreeBSD 4.2-RELEASE on a machine
> that previously held two FAT partitions.  Rather than delete and
> recreate the first partition to change it to a FreeBSD partition,
> he changed the partition "type" using T.  The slice editor then showed
> "the right thing".  However, when he then got to partition allocation,
> hitting A resulted in the following message:
> 
>   Unable to create the root partition. Too big?
> 
> Going back and deleting the FreeBSD slice (was a FAT slice), then creating
> it again caused auto-partitioning to work fine.  It sounds like the
> change in slice type is not being propagated properly to the partitioning
> phase.  Also, it sounds like the debugging output from the partition
> creation is a tad on the not-so-specific-side.

I've encountered this bug also. 4.2-stable as I remember.
-- 

Vallo Kallaste
vallo@matti.ee
Comment 2 Seth Kingsley 2001-03-23 04:48:05 UTC
This has to do with libdisk(3) not creating an 'unused' partition for
slice types other than 'freebsd'. This patch to libdisk checks for the
existance of the 'unused' partition and creates one if need be:

Index: chunk.c
===================================================================
RCS file: /ncvs/src/lib/libdisk/chunk.c,v
retrieving revision 1.24
diff -u -r1.24 chunk.c
--- chunk.c	2001/03/18 21:30:10	1.24
+++ chunk.c	2001/03/23 04:42:56
@@ -109,6 +109,32 @@
 	return c2;
 }
 
+/*
+ * Check to see if this slice has no partitions. If it does not, create
+ * an empty one spanning the entire slice. This can happen when an
+ * existing slice of a different type is changed into a 'freebsd' slice.
+ */
+void
+Check_Unused(struct chunk *cp)
+{
+	struct chunk	*ncp = new_chunk();
+
+	if (cp->part)
+	    return;
+	if (!ncp) barfout(1,"malloc failed");
+	memset(ncp,0,sizeof *ncp);
+	ncp->disk = cp->disk;
+	ncp->offset = cp->offset;
+	ncp->size = cp->size;
+	ncp->end = cp->end;
+	ncp->type = unused;
+#ifdef PC98
+	ncp->sname = strdup(cp->sname);
+#endif /* PC98 */
+	ncp->name = strdup("-");
+	cp->part = ncp;
+}
+
 int
 #ifdef PC98
 Insert_Chunk(struct chunk *c2, u_long offset, u_long size, const char *name,
@@ -263,6 +289,8 @@
 		c1 = Find_Mother_Chunk(d->chunks,offset,end,freebsd);
 	if(!c1)
 		return __LINE__;
+	if(type == part)
+		Check_Unused(c1);
 	for(c2=c1->part;c2;c2=c2->next) {
 		if (c2->type != unused)
 			continue;
Index: create_chunk.c
===================================================================
RCS file: /ncvs/src/lib/libdisk/create_chunk.c,v
retrieving revision 1.55
diff -u -r1.55 create_chunk.c
--- create_chunk.c	2001/03/18 21:30:10	1.55
+++ create_chunk.c	2001/03/23 04:45:41
@@ -240,6 +240,7 @@
     
     if (!parent)
 	parent = d->chunks;
+    Check_Unused(parent);
     for (c1=parent->part; c1 ; c1 = c1->next) {
 	if (c1->type != unused) continue;
 	if (c1->size < size) continue;
Index: libdisk.h
===================================================================
RCS file: /ncvs/src/lib/libdisk/libdisk.h,v
retrieving revision 1.37
diff -u -r1.37 libdisk.h
--- libdisk.h	2001/03/18 21:30:10	1.37
+++ libdisk.h	2001/03/23 04:44:47
@@ -265,6 +265,7 @@
 void Debug_Chunk(struct chunk *);
 void Free_Chunk(struct chunk *);
 struct chunk * Clone_Chunk(struct chunk *);
+void Check_Unused(struct chunk *);
 #ifdef PC98
 int Add_Chunk(struct disk *, long, u_long, const char *, chunk_e, int, u_long, const char *);
 #else

-- 
|| Seth Kingsley || BSDi/Open Source Division || sethk@osd.bsdi.com ||
Comment 3 smazerski 2002-07-13 23:22:37 UTC
This email submitted to the "Submit Followup" link on:

http://www.freebsd.org/cgi/query-pr.cgi?pr=3Dbin%2F24435

I have experienced the same problem with 4.6-RELEASE
while attempting to rededicate a Linux ext2fs partition
as a FreeBSD slice.

Despite having changed the partition type to FreeBSD,
in the partition allocation screen any attempt to
create a partition produced the error message

  Unable to create the partition. Too big?

I was able to remedy the situation by using the Linux
fdisk to set the partition system ID to FreeBSD.
On restarting the installation process, I was able
to configure the slice correctly; the error message
did not reoccur.


Yours

S.Mazerski
Comment 4 crist.clark 2002-07-14 09:21:31 UTC
On Sat, Jul 13, 2002 at 03:30:03PM -0700, Steve Mazerski wrote:
> The following reply was made to PR bin/24435; it has been noted by GNATS.
> 
> From: Steve Mazerski <smazerski@yahoo.co.jp>
> To: freebsd-gnats-submit@FreeBSD.org
> Cc: rwatson@FreeBSD.org
> Subject: Re: bin/24435: Changing slice type causes Auto-partition to not work
> Date: Sun, 14 Jul 2002 00:22:37 +0200
> 
>  This email submitted to the "Submit Followup" link on:
>  
>  http://www.freebsd.org/cgi/query-pr.cgi?pr=3Dbin%2F24435
>  
>  I have experienced the same problem with 4.6-RELEASE
>  while attempting to rededicate a Linux ext2fs partition
>  as a FreeBSD slice.
>  
>  Despite having changed the partition type to FreeBSD,
>  in the partition allocation screen any attempt to
>  create a partition produced the error message
>  
>    Unable to create the partition. Too big?

Did you reboot? I believe that once the kernel loads up it's idea of a
slice table, it doesn't change even though you _do_ change the table
on the disk.

That would still be a bug tho'.
-- 
Crist J. Clark                     |     cjclark@alum.mit.edu
                                   |     cjclark@jhu.edu
http://people.freebsd.org/~cjc/    |     cjc@freebsd.org
Comment 5 smazerski 2002-07-14 10:21:00 UTC
On Sunday 14 July 2002 10:21, Crist J. Clark wrote:
> On Sat, Jul 13, 2002 at 03:30:03PM -0700, Steve Mazerski wrote:
> > The following reply was made to PR bin/24435; it has been noted by GN=
ATS.
> >
> > From: Steve Mazerski <smazerski@yahoo.co.jp>
> > To: freebsd-gnats-submit@FreeBSD.org
> > Cc: rwatson@FreeBSD.org
> > Subject: Re: bin/24435: Changing slice type causes Auto-partition to =
not
> > work Date: Sun, 14 Jul 2002 00:22:37 +0200
> >
> >  This email submitted to the "Submit Followup" link on:
> >
> >  http://www.freebsd.org/cgi/query-pr.cgi?pr=3D3Dbin%2F24435
> >
> >  I have experienced the same problem with 4.6-RELEASE
> >  while attempting to rededicate a Linux ext2fs partition
> >  as a FreeBSD slice.
> >
> >  Despite having changed the partition type to FreeBSD,
> >  in the partition allocation screen any attempt to
> >  create a partition produced the error message
> >
> >    Unable to create the partition. Too big?
>
> Did you reboot? I believe that once the kernel loads up it's idea of a
> slice table, it doesn't change even though you _do_ change the table
> on the disk.

I didn't get to the point in the installation program where changes were
written to disk. I don't know whether it is possible to coerce the=20
installation programm to commit changes to the partition table before
proceeding to the disklabel editor. I did restart the installation proces=
s=20
several times, in the belief I had missed something.

After rebooting into Linux, changing the partition/slice type to FreeBSD,
then restarting the installation process, the problem went away.

> That would still be a bug tho'.

I suspect it is.

If I can be of any help (reproducing the situation, testing a fix)
please let me know.

Many thanks for your feedback.

Yours

S.Mazerski
Comment 6 John Baldwin freebsd_committer freebsd_triage 2002-11-13 16:03:35 UTC
Responsible Changed
From-To: freebsd-bugs->qa

This is a sysinstall/libdisk PR, so kick it over to qa@.  There is also a 
patch in the followups that should be tested.
Comment 7 Bruce Cran freebsd_committer freebsd_triage 2010-03-13 00:17:49 UTC
Responsible Changed
From-To: freebsd-bugs->brucec

Take.
Comment 8 Bruce Cran freebsd_committer freebsd_triage 2010-04-24 14:30:13 UTC
State Changed
From-To: open->feedback

It looks like this was fixed in r109080 in 2003. Can you  
still reproduce this issue?
Comment 9 Bruce Cran freebsd_committer freebsd_triage 2010-04-24 14:50:11 UTC
State Changed
From-To: feedback->closed

I have confirmed that the bug is present on 4.2 and fixed in 6.3.