Clear the first sector of the disk so that OpenFirmware recognizes it and

can load a kernel from its file system.

Also tell the user what command he needs to run from the OpenFirmware shell
to configure automatic booting of the system.

Closes PR port-shark/35576.
This commit is contained in:
jmmv 2007-03-12 11:19:37 +00:00
parent b02917f2f9
commit 4233342b6f
6 changed files with 159 additions and 6 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.19 2006/04/05 16:55:07 garbled Exp $ */
/* $NetBSD: md.c,v 1.20 2007/03/12 11:19:37 jmmv Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -53,6 +53,31 @@
#include "msg_defs.h"
#include "menu_defs.h"
/*
* Clears the disk's first sector by writing all zeros over it.
* Returns 0 on success, -1 on failure. Leaves the disk's path in
* the output diskpath buffer for further usage in error messages.
*/
static int
clear_mbr(const char *disk, char *diskpath, size_t diskpathlen)
{
int fd;
char sector[512];
fd = opendisk(disk, O_WRONLY, diskpath, diskpathlen, 0);
if (fd < 0)
return -1;
memset(sector, 0, sizeof(sector));
if (pwrite(fd, &sector, sizeof(sector), 0) < 0) {
close(fd);
return -1;
}
close(fd);
return 0;
}
int
md_get_info(void)
{
@ -103,6 +128,13 @@ md_get_info(void)
int
md_pre_disklabel(void)
{
char diskpath[MAXPATHLEN];
if (clear_mbr(diskdev, diskpath, sizeof(diskpath)) == -1) {
msg_display(MSG_badclearmbr, diskpath);
process_menu(MENU_ok, NULL);
}
return 0;
}
@ -178,5 +210,9 @@ md_init(void)
int
md_post_extract(void)
{
msg_display(MSG_setbootdevice);
process_menu(MENU_ok, NULL);
return 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.md.de,v 1.4 2004/10/21 12:14:22 martin Exp $ */
/* $NetBSD: msg.md.de,v 1.5 2007/03/12 11:19:37 jmmv Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -81,3 +81,27 @@ message arm32fspart
message set_kernel_1
{Kernel (GENERIC)}
message setbootdevice
{In order to make your system boot automatically from the on-disk file
system, you need to manually configure OpenFirmware to tell it where to
load the kernel from.
OpenFirmware can load a NetBSD a.out kernel (sorry, ELF is not supported)
straight from a FFS partition on the local hard disk. So, to configure it
to boot the just-installed kernel, run the following command from
OpenFirmware's shell:
setenv boot-device disk:\\netbsd.aout
You only need to run this once and only if the 'boot-device' property did
not already contain the value shown above.
}
message badclearmbr
{Failed to clear the disk's first sector. If OpenFirmware cannot see the
disk, try to run the following command manually from the installer's shell
utility:
dd if=/dev/zero of=%s bs=512 count=1
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.md.en,v 1.6 2003/06/12 11:20:13 dsl Exp $ */
/* $NetBSD: msg.md.en,v 1.7 2007/03/12 11:19:37 jmmv Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -77,3 +77,27 @@ message arm32fspart
message set_kernel_1
{Kernel (GENERIC)}
message setbootdevice
{In order to make your system boot automatically from the on-disk file
system, you need to manually configure OpenFirmware to tell it where to
load the kernel from.
OpenFirmware can load a NetBSD a.out kernel (sorry, ELF is not supported)
straight from a FFS partition on the local hard disk. So, to configure it
to boot the just-installed kernel, run the following command from
OpenFirmware's shell:
setenv boot-device disk:\\netbsd.aout
You only need to run this once and only if the 'boot-device' property did
not already contain the value shown above.
}
message badclearmbr
{Failed to clear the disk's first sector. If OpenFirmware cannot see the
disk, try to run the following command manually from the installer's shell
utility:
dd if=/dev/zero of=%s bs=512 count=1
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.md.es,v 1.2 2005/08/26 16:32:33 xtraeme Exp $ */
/* $NetBSD: msg.md.es,v 1.3 2007/03/12 11:19:37 jmmv Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -80,3 +80,26 @@ Compensaci
message set_kernel_1
{Núcleo (GENERIC)}
message setbootdevice
{Para conseguir que el sistema arranque automaticamente desde el sistema
de ficheros del disco, necesita configura manualmente OpenFirmware para
indicarle desde dónde debe cargar el núcleo del sistema.
OpenFirmware puede cargar un núcleo a.out de NetBSD (perdone, pero ELF no está soportado) directamente desde una partición FFS del disco local. Así que, para
configurarlo para que arranque desde disco deberá ejecutar manualmente el
siguiente comando desde la interfaz de OpenFirmware:
setenv boot-device disk:\\netbsd.aout
Sólo tiene que ejecutar esto una vez y sólamente si la propiedad
'boot-device' no contenía el valor mostrado arriba.
}
message badclearmbr
{Ha ocurrido un error al intentar borrar el primer sector del disco. Si el
firmware no puede verlo, pruebe a ejecutar el siguiente comando manualmente
desde la linea de comandos de la utilidad de instalación:
dd if=/dev/zero of=%s bs=512 count=1
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.md.fr,v 1.6 2003/06/12 11:20:13 dsl Exp $ */
/* $NetBSD: msg.md.fr,v 1.7 2007/03/12 11:19:37 jmmv Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -82,3 +82,26 @@ message arm32fspart
message set_kernel_1
{Kernel (GENERIC)}
message setbootdevice
{In order to make your system boot automatically from the on-disk file
system, you need to manually configure OpenFirmware to tell it where to
load the kernel from.
OpenFirmware can load a NetBSD a.out kernel (sorry, ELF is not supported)
straight from a FFS partition on the local hard disk. So, to configure it
to boot the just-installed kernel, run the following command from
OpenFirmware's shell:
setenv boot-device disk:\\netbsd.aout
You only need to run this once and only if the 'boot-device' property did
not already contain the value shown above.
}
message badclearmbr
{Failed to clear the disk's first sector. If OpenFirmware cannot see the
disk, try to run the following command manually from the installer's shell
utility:
dd if=/dev/zero of=%s bs=512 count=1
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.md.pl,v 1.5 2003/06/12 11:20:13 dsl Exp $ */
/* $NetBSD: msg.md.pl,v 1.6 2007/03/12 11:19:38 jmmv Exp $ */
/* Based on english version: */
/* NetBSD: msg.md.en,v 1.2 2002/04/02 17:02:54 thorpej Exp */
@ -80,3 +80,26 @@ message arm32fspart
message set_kernel_1
{Kernel (GENERIC)}
message setbootdevice
{In order to make your system boot automatically from the on-disk file
system, you need to manually configure OpenFirmware to tell it where to
load the kernel from.
OpenFirmware can load a NetBSD a.out kernel (sorry, ELF is not supported)
straight from a FFS partition on the local hard disk. So, to configure it
to boot the just-installed kernel, run the following command from
OpenFirmware's shell:
setenv boot-device disk:\\netbsd.aout
You only need to run this once and only if the 'boot-device' property did
not already contain the value shown above.
}
message badclearmbr
{Failed to clear the disk's first sector. If OpenFirmware cannot see the
disk, try to run the following command manually from the installer's shell
utility:
dd if=/dev/zero of=%s bs=512 count=1
}