Subject: Re: bin/21021: fdisk touches parts of the disk it should not change
To: <>
From: David Laight <david@l8s.co.uk>
List: netbsd-bugs
Date: 04/05/2003 22:09:44
> >Synopsis:       fdisk touches parts of the disk it should not change
> 
> 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).

Can't help - I don't do M$

> 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).

It doesn't, fdisk will only write to sector zero of the disk (unless
/usr/mdec/mbr is larger than 512 bytes!)

> 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.

Nope! some anti-virus software might play with the rest of track zero.
Indeed the system bios might!

Actually fdisk should have the ability to edit the extended partition
list - provided it does it properly!

It is even possible that your attempts to restore the contents are actually
what broke things :-(

>         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

Which fdisk generated the above?

Note that the head and sector values for the start of the partition
are valid, whereas the cylinder value is truncated to 1023.
(the main partition has 254/63 for the start).

My win98 fdisk just knocked off the top bits of the extended
partition cylinders numbers.

	David

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