Subject: an fdisk that supports extended partitions
To: None <port-i386@netbsd.org>
From: David Laight <david@l8s.co.uk>
List: port-i386
Date: 01/27/2003 18:53:05
I've spent far too much time during the last week or so modifying fdisk
so that it can (sensibly) edit the extended partition list.

It would be useful, at this point, to have some feedback.  I don't
think I've broken anything (especially sysinst) but cannot really
be sure.  It is possible to test this version without being root!

$ ./fdisk -?
fdisk: unknown option -- ?
Usage: fdisk [-afiluvBS] [-b cylinders/heads/sectors] \
             [-0123 | -E num|+  [-s id/start/size[/bootmenu]]] \
             [-c bootcode] [-r|-w file] [device]
        -a change active partition
        -f force - not interactive
        -i initialise bootcode
        -l list partition types
        -u update partition data
        -v verbose output, -v -v more verbose still
        -B update bootselect options
        -S output as shell defines
$

-w file reads from device, but writes to 'file',
-r file reads and writes to 'file', both take geometry info from 'device'
(this is where I've been writing large space files....)

The output (without -v) is much more concise:
$ ./fdisk
Disk: /dev/rwd0d
NetBSD disklabel disk geometry:
cylinders: 16383, heads: 16, sectors/track: 63 (1008 sectors/cylinder)
total sectors: 40032696

BIOS disk geometry:
cylinders: 1023, heads: 255, sectors/track: 63 (16065 sectors/cylinder)
total sectors: 40032696

Partition table:
0: NetBSD (sysid 169)
    bootmenu: net 1.5.
    start 4209030, size 8289540 (4048 MB, Cyls 262-778), Active
1: Primary DOS with 32 bit FAT (sysid 11)
    bootmenu: win98
    start 63, size 4208967 (2055 MB, Cyls 0-262)
2: NetBSD (sysid 169)
    bootmenu: current
    start 32515560, size 7517136 (3670 MB, Cyls 2024-2491/234/40)
3: Ext. partition - LBA (sysid 15)
    start 12498570, size 20016990 (9774 MB, Cyls 778-2024)
Extended partition table:
E0: Primary DOS with 32 bit FAT (sysid 11)
    start 12498633, size 8193087 (4001 MB, Cyls 778-1288)
E1: Primary DOS with 32 bit FAT (sysid 11)
    start 20691783, size 2056257 (1004 MB, Cyls 1288-1416)
E2: Primary 'big' DOS, 16-bit FAT (> 32MB) (sysid 6)
    start 22748103, size 1028097 (502 MB, Cyls 1416-1480)
E3: Primary DOS with 32 bit FAT (sysid 11)
    start 24804423, size 4096512 (2000 MB, Cyls 1544-1799)
E4: Primary DOS with 32 bit FAT (sysid 11)
    start 28900998, size 3614562 (1765 MB, Cyls 1799-2024)
Bootselector enabled, infinite timeout.

I've also put the menu strings for the mbr_bootsel menu
into the main partition editing code.
That code will also:
- accept dddc and dddM for sizes in cylinders or megabytes
- offer you the first free space when creating a partition
- stops you creating overlapping partitions

Use 'e+' to create a partition in the extended partition.

If anyone wants to play, the source and an i386 binary (and my latest
mbr_bootsel code - not actually necessary) can be downloaded from
http://www.btinternet.com/~david.laight/netbsd/fdisk/

There is also a diff there, but it is larger than the source file!

	David

-- 
David Laight: david@l8s.co.uk