Subject: bin/21021: fdisk touches parts of the disk it should not change
To: None <gnats-bugs@gnats.netbsd.org>
From: Martin Husemann <martin@duskware.de>
List: netbsd-bugs
Date: 04/05/2003 11:42:54
>Number: 21021
>Category: bin
>Synopsis: fdisk touches parts of the disk it should not change
>Confidential: no
>Severity: critical
>Priority: high
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Apr 05 01:43:01 PST 2003
>Closed-Date:
>Last-Modified:
>Originator: Martin Husemann
>Release: NetBSD 1.6Q
>Organization:
>Environment:
System: NetBSD night-porter.duskware.de 1.6Q NetBSD 1.6Q (PORTER) #4: Fri Apr 4 14:17:30 MEST 2003 martin@night-porter.duskware.de:/usr/src/sys/arch/i386/compile/PORTER i386
Architecture: i386
Machine: i386
>Description:
I had trouble getting my NetBSD partition bootable with a boot selector, so
I thought I'd try making it boot all by itself first.
So I did a backup of the first 63 sectors of the hard disk by
doing "dd if=/dev/rwd0d of=/saved_track0 count=63" and used
"fdisk -i -c /usr/mdec/mbr wd0" to install the NetBSD MBR code. Then I used
"fdisk -a wd0" to set the NetBSD partition active.
This failed to make NetBSD boot from hard disk (different PR), so I restored
the old state (or so I thought) by doing
"dd if=/saved_track0 of=/dev/rwd0d" and tried to reboot into the other OSs
I have installed on that disk.
The Win2K in the first NTFS partition (see label below) booted up, but won't
allow me to log in. I have no clue what broke, maybe the assignement of
volumes to disk names (i.e. it's now calling it's boot partition G:, but it
was E: before, for historic reasons).
But the point is: I did not want fdisk to change anything outside the MBR.
I just asked it to install the MBR code (clearly that's changing the MBR
only) and later change the active flag (clearly MBR only too).
Since I restored the first 63 sectors of the disk, all changes it had done
to the MBR have been restored - but something is still different. So I conclude
fdisk must fiddle with the extended partition, and it should not do that.
Next time I'll backup & restore the start of the extended partition too :-(
Here is the disklabel and fdisk output *after* the failed experiment.
# /dev/rwd0d:
type: unknown
disk: boot
label:
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 16
sectors/cylinder: 1008
cylinders: 16383
total sectors: 240121728
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0 # microseconds
track-to-track seek: 0 # microseconds
drivedata: 0
16 partitions:
# size offset fstype [fsize bsize cpg/sgs]
a: 8200332 12298608 4.2BSD 1024 8192 46448 # (Cyl. 12201 - 20336*)
b: 2097333 10201275 swap # (Cyl. 10120*- 12200)
c: 10297665 10201275 unused 0 0 # (Cyl. 10120*- 20336*)
d: 240121728 0 unused 0 0 # (Cyl. 0 - 238215)
e: 10201212 63 MSDOS # (Cyl. 0*- 10120*)
f: 10297665 10201275 unused 0 0 # (Cyl. 10120*- 20336*)
g: 219608550 20498940 unused 0 0 # (Cyl. 20336*- 238201*)
h: 33575787 20499003 MSDOS # (Cyl. 20336*- 53645*)
i: 33575787 54074853 MSDOS # (Cyl. 53645*- 86954)
j: 32884992 87650703 MSDOS # (Cyl. 86955*- 119579*)
k: 78622047 120535758 NTFS # (Cyl. 119579*- 197577*)
l: 40949622 199157868 NTFS # (Cyl. 197577*- 238201*)
Disk: /dev/rwd0d
NetBSD disklabel disk geometry:
cylinders: 16383 heads: 16 sectors/track: 63 (1008 sectors/cylinder)
BIOS disk geometry:
cylinders: 1024 heads: 255 sectors/track: 63 (16065 sectors/cylinder)
Partition table:
0: sysid 11 (Primary DOS with 32 bit FAT)
start 63, size 10201212 (4981 MB), flag 0x80
beg: cylinder 0, head 1, sector 1
end: cylinder 634, head 254, sector 63
1: sysid 169 (NetBSD)
start 10201275, size 10297665 (5028 MB), flag 0x0
beg: cylinder 635, head 0, sector 1
end: cylinder 1023, head 254, sector 63
2: sysid 15 (Ext. partition - LBA)
start 20498940, size 219608550 (107230 MB), flag 0x0
beg: cylinder 1023, head 254, sector 63
end: cylinder 1023, head 254, sector 63
Extended partition table:
0: sysid 11 (Primary DOS with 32 bit FAT)
start 20499003, size 33575787 (16394 MB), flag 0x0
beg: cylinder 1023, head 1, sector 1
end: cylinder 1023, head 254, sector 63
1: sysid 5 (Extended partition)
start 54074790, size 33575850 (16394 MB), flag 0x0
beg: cylinder 1023, head 0, sector 1
end: cylinder 1023, head 254, sector 63
Extended partition table:
0: sysid 11 (Primary DOS with 32 bit FAT)
start 54074853, size 33575787 (16394 MB), flag 0x0
beg: cylinder 1023, head 1, sector 1
end: cylinder 1023, head 254, sector 63
1: sysid 5 (Extended partition)
start 87650640, size 32885055 (16057 MB), flag 0x0
beg: cylinder 1023, head 0, sector 1
end: cylinder 1023, head 254, sector 63
Extended partition table:
0: sysid 11 (Primary DOS with 32 bit FAT)
start 87650703, size 32884992 (16057 MB), flag 0x0
beg: cylinder 1023, head 1, sector 1
end: cylinder 1023, head 254, sector 63
1: sysid 5 (Extended partition)
start 120535695, size 78622110 (38389 MB), flag 0x0
beg: cylinder 1023, head 0, sector 1
end: cylinder 1023, head 254, sector 63
Extended partition table:
0: sysid 7 (OS/2 HPFS or NTFS or QNX2 or Advanced UNIX)
start 120535758, size 78622047 (38389 MB), flag 0x0
beg: cylinder 1023, head 1, sector 1
end: cylinder 1023, head 254, sector 63
1: sysid 5 (Extended partition)
start 199157805, size 40949685 (19994 MB), flag 0x0
beg: cylinder 1023, head 0, sector 1
end: cylinder 1023, head 254, sector 63
Extended partition table:
0: sysid 7 (OS/2 HPFS or NTFS or QNX2 or Advanced UNIX)
start 199157868, size 40949622 (19994 MB), flag 0x0
beg: cylinder 1023, head 1, sector 1
end: cylinder 1023, head 254, sector 63
1: <UNUSED>
2: <UNUSED>
3: <UNUSED>
2: <UNUSED>
3: <UNUSED>
2: <UNUSED>
3: <UNUSED>
2: <UNUSED>
3: <UNUSED>
2: <UNUSED>
3: <UNUSED>
3: <UNUSED>
>How-To-Repeat:
No. I won't repeat it.
>Fix:
n/a
>Release-Note:
>Audit-Trail:
>Unformatted: