* In md_init, determine what kind of bootfloppy we are (either

by checking uname, or the BOOTMODEL environment var), and set
  the kernel setname accordingly for some bootmodels (tiny and laptop),
  to install GENERIC_TINY and GENERIC_LAPTOP respectively. There's
  no sense in installing plain GENERIC, especially on "tiny" systems;
  it may not even make it far enough to add swapspace on 4M machines.
* Make sure to always install bootcode into the MBR (unless the user
  explicitly tells us not to). Should fix PR#8887, PR#9093, PR#9999
This commit is contained in:
fvdl 2000-10-02 09:36:24 +00:00
parent 4ee4b50498
commit e615284d83
2 changed files with 83 additions and 7 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.39 2000/09/27 12:42:06 fvdl Exp $ */
/* $NetBSD: md.c,v 1.40 2000/10/02 09:36:24 fvdl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -41,6 +41,7 @@
#include <stdio.h>
#include <util.h>
#include <sys/param.h>
#include <sys/utsname.h>
#include <machine/cpu.h>
#include <sys/sysctl.h>
#include "defs.h"
@ -50,6 +51,7 @@
char mbr[512];
char kernstr[STRSIZE];
int mbr_present, mbr_len;
int c1024_resp;
struct disklist *disklist = NULL;
@ -64,6 +66,7 @@ static int mbr_part_above_chs __P((struct mbr_partition *));
static int mbr_partstart_above_chs __P((struct mbr_partition *));
static void configure_bootsel __P((void));
static void md_upgrade_mbrtype __P((void));
static char *get_bootmodel __P((void));
struct mbr_bootsel *mbs;
int defbootselpart, defbootseldisk;
@ -105,7 +108,18 @@ edit:
md_read_bootcode(_PATH_BOOTSEL, mbr, sizeof mbr);
configure_bootsel();
netbsd_mbr_installed = netbsd_bootsel_installed = 1;
} else {
msg_display(MSG_installnormalmbr);
process_menu(MENU_yesno);
if (yesno) {
mbr_len = md_read_bootcode(_PATH_MBR, mbr,
sizeof mbr);
netbsd_mbr_installed = 1;
}
}
} else {
mbr_len = md_read_bootcode(_PATH_MBR, mbr, sizeof mbr);
netbsd_mbr_installed = 1;
}
if (mbr_partstart_above_chs(part) && !netbsd_mbr_installed) {
@ -481,6 +495,9 @@ md_cleanup_install(void)
char realfrom[STRSIZE];
char realto[STRSIZE];
char cmd[STRSIZE];
char *bootmodel;
bootmodel = get_bootmodel();
strncpy(realfrom, target_expand("/etc/rc.conf"), STRSIZE);
strncpy(realto, target_expand("/etc/rc.conf.install"), STRSIZE);
@ -504,11 +521,26 @@ md_cleanup_install(void)
run_prog(1, 0, NULL, "mv -f %s %s", realto, realfrom);
strncpy(realfrom, target_expand("/etc/ttys"), STRSIZE);
strncpy(realto, target_expand("/etc/ttys.install"), STRSIZE);
sprintf(cmd, "sed "
"-e '/^ttyE/s/off/on/'"
" < %s > %s", realfrom, realto);
/*
* For GENERIC_TINY, do not enable any extra screens or wsmux.
* Otherwise, run getty on 4 VTs.
*/
if (strcmp(bootmodel, "tiny") == 0) {
strncpy(realfrom, target_expand("/etc/wscons.conf"), STRSIZE);
strncpy(realto, target_expand("/etc/wscons.conf.install"),
STRSIZE);
sprintf(cmd, "sed"
" -e '/^screen/s/^/#/'"
" -e '/^mux/s/^/#/'"
" < %s > %s", realfrom, realto);
} else {
strncpy(realfrom, target_expand("/etc/ttys"), STRSIZE);
strncpy(realto, target_expand("/etc/ttys.install"), STRSIZE);
sprintf(cmd, "sed "
"-e '/^ttyE/s/off/on/'"
" < %s > %s", realfrom, realto);
}
if (logging)
(void)fprintf(log, "%s\n", cmd);
if (scripting)
@ -647,3 +679,40 @@ disp_bootsel(part, mbsp)
}
msg_display_add(MSG_newline);
}
char *
get_bootmodel()
{
struct utsname ut;
char *envstr;
envstr = getenv("BOOTMODEL");
if (envstr != NULL)
return envstr;
if (uname(&ut) < 0)
return "";
if (strstr(ut.version, "TINY") != NULL)
return "tiny";
else if (strstr(ut.version, "SMALL") != NULL)
return "small";
else if (strstr(ut.version, "LAPTOP") != NULL)
return "laptop";
return "";
}
void
md_init()
{
char *bootmodel;
bootmodel = get_bootmodel();
if (strcmp(bootmodel, "") != 0 && strcmp(bootmodel, "small") != 0) {
/*
* XXX assumes the kernset is the first in the array.
*/
snprintf(kernstr, sizeof kernstr, "kern-%s", bootmodel);
dist_list[0].name = &kernstr[0];
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.md.en,v 1.19 2000/05/11 02:27:25 hubertf Exp $ */
/* $NetBSD: msg.md.en,v 1.20 2000/10/02 09:36:24 fvdl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -251,6 +251,13 @@ off this partition. Do you want to install the NetBSD bootcode into
the Master Boot Record so that this is ensured? Note that this will
overwrite the existing code in the MBR, like some bootselectors.}
message installnormalmbr
{You have chosen not to install a bootselector. If this was because you
already have a bootselector installed, no further action is needed.
However, if no bootselector is installed, the normal bootcode must be
used, or your system will not boot properly. Do you want to use the normal
NetBSD bootcode?}
message configbootsel
{Configure the different bootselection menu items. You can change the
simple menu entries for the matching partition entries that are displayed