Bug 25683 - primary dos partition bugs
primary dos partition bugs
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: anaconda (Show other bugs)
7.0
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Michael Fulbright
Brock Organ
Florence RC-1
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-02-02 06:04 EST by Anders Blomdell
Modified: 2007-04-18 12:31 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2001-02-26 11:43:29 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Anders Blomdell 2001-02-02 06:04:49 EST
With the following lines in kickstart:

  part / --size 2000
  part swap --size 256
  part /dos/c --size 200 --type 6 --asprimary 1 --active
  part /winnt/d --size 800 --type 6

I wind up with a partitioning like this (cfdisk):

   # Flags Head Sect Cyl   ID  Head Sect Cyl    Sector  Sectors
-- ----- ---- ---- ---- ---- ---- ---- ---- -------- ---------
 1  0x80    0    1    0 0x06  126   37   25        0    409600
 2  0x00    0    1   26 0x83  254   63  280   417690   4096575
 3  0x00    0    1  281 0x05  254   63 1023  4514265  25511220
 4  0x00    0    0    0 0x00    0    0    0        0         0
 5  0x00    1    1  281 0x06  254   63  382       63   1638567
 6  0x00    1    1  383 0x82  254   63  415       63    530082

After trying to dosformat partition 1 (yes, first block were zeroed out with 
dd), the disk is useless. BUT, if I first remove partition 1 and then 
recreate it with fdisk, I get a working partitioning that looks like this:

 # Flags Head Sect Cyl   ID  Head Sect Cyl    Sector  Sectors
-- ----- ---- ---- ---- ---- ---- ---- ---- -------- ---------
 1  0x80    1    1    0 0x06  254   63   25       63    417627
 2  0x00    0    1   26 0x83  254   63  280   417690   4096575
 3  0x00    0    1  281 0x05  254   63 1023  4514265  25511220
 4  0x00    0    0    0 0x00    0    0    0        0         0
 5  0x00    1    1  281 0x06  254   63  382       63   1638567
 6  0x00    1    1  383 0x82  254   63  415       63    530082

Trying to put the dos on partition 2 with this line:

  part /dos/c --size 200 --type 6 --asprimary 2 --active

gives this partitioning:

 # Flags Head Sect Cyl   ID  Head Sect Cyl    Sector  Sectors
-- ----- ---- ---- ---- ---- ---- ---- ---- -------- ---------
 1  0x80    0    1   26 0x83  254   63  280   417690   4096575
 2  0x00    1    1    0 0x06  254   63   25       63    417627
 3  0x00    0    1  281 0x05  254   63 1023  4514265  25511220
 4  0x00    0    0    0 0x00    0    0    0        0         0
 5  0x00    1    1  281 0x06  254   63  382       63   1638567
 6  0x00    1    1  383 0x82  254   63  415       63    530082

which is correct as far as start H/S/C is concerened, but the --active 
request is not honored. Changing the bootable flag of partition 1 and 2 
gives a correct partitioning.
Comment 1 Anders Blomdell 2001-02-02 12:08:01 EST
I just realized that I forgot to attach the patch needed for the kickstart 
commands to succeed (and partitioning fail):

--- O.kickstart.py      Wed Jan 31 12:06:14 2001
+++ kickstart.py        Wed Jan 31 12:06:57 2001
@@ -504,7 +504,7 @@
                                        'grow', 'onpart=', 'ondisk=',
                                         'bytes-per-inode=', 'usepart=',
                                         'onprimary=', 'active', 'type=',
-                                        'asprimary', 'noformat'])
+                                        'asprimary=', 'noformat'])
 
        for n in args:
            (str, arg) = n
@@ -528,6 +528,7 @@
                 active = 1
             elif str == "--asprimary":
                 primOnly = 1
+                partNum = int(arg)
             elif str == "--noformat":
                 format = 0
 
Comment 2 Michael Fulbright 2001-02-02 14:07:43 EST
Thank you, assigning to a developer.
Comment 3 Anders Blomdell 2001-02-05 07:39:37 EST
The bug in constraints.c lead me astray for a moment, but here is a fix for the 
alignment problem. The --active problem for partitions other than the first one 
is not fixed...

diff -ur anaconda-7.0.1.orig/kickstart.py anaconda-7.0.1/kickstart.py
--- anaconda-7.0.1.orig/kickstart.py    Wed Aug 23 15:57:36 2000
+++ anaconda-7.0.1/kickstart.py Mon Feb  5 12:06:39 2001
@@ -504,7 +504,7 @@
                                        'grow', 'onpart=', 'ondisk=',
                                         'bytes-per-inode=', 'usepart=',
                                         'onprimary=', 'active', 'type=',
-                                        'asprimary', 'noformat'])
+                                        'asprimary=', 'noformat'])
 
        for n in args:
            (str, arg) = n
@@ -528,6 +528,7 @@
                 active = 1
             elif str == "--asprimary":
                 primOnly = 1
+                partNum = int(arg)
             elif str == "--noformat":
                 format = 0
 
diff -ur anaconda-7.0.1.orig/libfdisk/alloc.c anaconda-7.0.1/libfdisk/alloc.c
--- anaconda-7.0.1.orig/libfdisk/alloc.c        Tue Jul 25 05:24:31 2000
+++ anaconda-7.0.1/libfdisk/alloc.c     Mon Feb  5 11:57:31 2001
@@ -943,10 +943,18 @@
 #ifdef __FDISK_ALLOC_DEBUG__
                printf ("Trying fixed primary\n");
 #endif
-               if (priTried)
+               if (priTried) {
                    trynext = 1;
-               else
+               } else if ((status=fdiskFindFreeSlot(hd,freespace[drive],p,
+                                     PRIMARY,&freeslot)) != FDISK_SUCCESS) {
+                 /* If no free slot exists, fail... */
+#ifdef __FDISK_ALLOC_DEBUG__
+                   printf ("Trying fixed primary failed, going to next drive\
n");
+#endif
+                   trynext = 1;
+               } else {
                    priCreate = 1;
+               }
            } else if ((noneExists || !priExists || priRequested) && !tryExtNext) 
{ 
 #ifdef __FDISK_ALLOC_DEBUG__
                printf ("Trying primary\n");
diff -ur anaconda-7.0.1.orig/libfdisk/constraints.c anaconda-7.0.1/libfdisk/
constraints.c
--- anaconda-7.0.1.orig/libfdisk/constraints.c  Fri May 26 21:27:28 2000
+++ anaconda-7.0.1/libfdisk/constraints.c       Mon Feb  5 11:55:28 2001
@@ -66,7 +66,7 @@
 }
 
 int fdiskIsConstraintFixed( Constraint *c) {
-    if (c->active && (c->current == c->min == c->max))
+    if (c->active && (c->current == c->min) && (c->current == c->max))
        return 1;
     else
        return 0;
Comment 4 Michael Fulbright 2001-02-08 17:04:16 EST
Please try using --onprimary 1, as the option --asprimary is not intended to
take an argument. It just says that you want it to be a primary partition, not
an extended partition.
Comment 5 Anders Blomdell 2001-02-09 03:30:01 EST
It is exactly the same problem with --onprimary. The problem is that primary
allocation does not go through fdiskFindFreeSlot, which leads to incorrect
starting and ending sectors. This problem is masked by the bug in
fdiskIsConstraintFixed for all partitions except #1 (since 2 == 2 == 2 -> false). 

The reason I didn't use --onprimary was that I thought it was analogous to 
--onpart and required the partition to already exist (when things doesn't work I 
tend to jump into conclusions). Please change --onpart to mean forced allocation 
to a specific partition (and leave --usepart as is). 

The changes to alloc.c and constraint.c is still believed to be correct, on 
kickstart.py I stand corrected...
Comment 6 Michael Fulbright 2001-02-12 14:05:18 EST
Thanks for looking into this issue and for the informative bug report. I will
look into this further.
Comment 7 Michael Fulbright 2001-02-26 11:43:25 EST
Thanks I've worked in your changes. This took some work to uncover on your part,
I really appreciate it!

Note You need to log in before you can comment on or make changes to this bug.