Subject: Re: fdisk fun
To: None <port-i386@NetBSD.org>
From: Alan Barrett <firstname.lastname@example.org>
Date: 01/23/2007 18:35:24
On Tue, 23 Jan 2007, Patrick Welche wrote:
> I am trying to replace a dying SCSI disk, but can't get the new one to boot
> because I can't create an MBR partition which starts at 0. Try as I might,
> fdisk insists on starting at 63. How can I teach it otherwise?
> Bootable old disk:
> # fdisk -vvv sd0
> 3: NetBSD (sysid 169)
> start 0, size 16 (0 MB, Cyls 0-0), Active
> beg: cylinder 0, head 0, sector 1
> end: cylinder 0, head 0, sector 16
This disk appears to have been installed with the file system starting
in sector 0, as you said. In this case, the file system's PBR in
sector 0 doing double duty as an MBR as well. THis is sometimes called
"dangerously dedicated" mode. Early versions of NetBSD's installation
instructions used to give this as an option, but AFAIK modern versions
of sysinst don't allow it. The bogus size = 16 sectors used to be hard
coded in the relevant bytes of the PBR, especially to support this
usage, but the current sys/arch/i386/stand/bootxx/pbr.S doesn't do that.
Today's src/sbin/fdsk/fdisk.c insists that the first track is reserved
for the BIOS, but old versions did not have that restriction.
If your new disk is large enough that you can afford to waste the 63
sectors, you could do that. You will have less trouble in future
You could add a -f (force) flag to bypass fdisk's internal sanity
Copy sector 0 from the old disk to the new disk.
dd some zeros to the start of the disk. This will make disklabel fake
up an "a" partition matching the entire disk. newfs that. Then use
installboot to make it bootable. If your BIOS doesn't check the MBR's
partition table then you don't need to care about it, but if you do care
then use dd to write the appropriate bytes to the relevant subset of
sector 0 (you want a result in which the code comes from installboot but
the partition table is hand-crafted or copied from the old disk).
--apb (Alan Barrett)