Improve luna68k md part of sysinst.
- setup a boot UFS partition and install native bootloader - add messages how to setup NVRAM variables for firmware to load bootloader - enable swap on <= 32MB machines
This commit is contained in:
parent
7e3311382f
commit
2bfe408bb8
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: md.c,v 1.2 2011/11/04 11:27:03 martin Exp $ */
|
||||
/* $NetBSD: md.c,v 1.3 2014/02/19 12:14:40 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
@ -38,7 +38,9 @@
|
||||
#include <sys/disklabel.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <curses.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
@ -49,6 +51,9 @@
|
||||
#include "msg_defs.h"
|
||||
#include "menu_defs.h"
|
||||
|
||||
#define PART_BOOT_BSIZE 4096
|
||||
#define PART_BOOT_FSIZE 512
|
||||
|
||||
void
|
||||
md_init(void)
|
||||
{
|
||||
@ -120,6 +125,16 @@ int
|
||||
md_check_partitions(void)
|
||||
{
|
||||
|
||||
/*
|
||||
* Make sure that a boot partition (old 4.3BSD UFS) is prepared
|
||||
* properly for our native bootloader.
|
||||
*/
|
||||
if (bsdlabel[PART_BOOT].pi_fstype != FS_BSDFFS ||
|
||||
(bsdlabel[PART_BOOT].pi_flags & PIF_NEWFS) == 0) {
|
||||
msg_display(MSG_nobootpartdisklabel);
|
||||
process_menu(MENU_ok, NULL);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -140,29 +155,45 @@ int
|
||||
md_post_disklabel(void)
|
||||
{
|
||||
|
||||
if (get_ramsize() <= 32)
|
||||
set_swap(diskdev, bsdlabel);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
copy_bootloader(void)
|
||||
{
|
||||
const char *mntdir = "/mnt2";
|
||||
|
||||
msg_display(MSG_copybootloader, diskdev);
|
||||
if (!run_program(RUN_SILENT | RUN_ERROR_OK,
|
||||
"mount /dev/%s%c %s", diskdev, 'a' + PART_BOOT, mntdir)) {
|
||||
mnt2_mounted = 1;
|
||||
run_program(0, "/bin/cp /usr/mdec/boot %s", mntdir);
|
||||
run_program(RUN_SILENT | RUN_ERROR_OK, "umount %s", mntdir);
|
||||
mnt2_mounted = 0;
|
||||
} else {
|
||||
/* XXX print proper error message */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* hook called after upgrade() or install() has finished setting
|
||||
* up the target disk but immediately before the user is given the
|
||||
* ``disks are now set up'' message.
|
||||
*
|
||||
* On the news68k, we use this opportunity to install the boot blocks.
|
||||
* hook called after install() has finished setting up the target disk
|
||||
* but immediately before the user is given the ``disks are now set up''
|
||||
* message.
|
||||
*/
|
||||
int
|
||||
md_post_newfs(void)
|
||||
{
|
||||
#if 0 /* no bootloader (yet) */
|
||||
const char *bootfile = "/boot";
|
||||
|
||||
printf(msg_string(MSG_dobootblks), diskdev);
|
||||
cp_to_target("/usr/mdec/boot", bootfile);
|
||||
sync();
|
||||
run_program(RUN_DISPLAY, "/usr/sbin/installboot /dev/r%sc %s %s",
|
||||
diskdev, "/usr/mdec/bootxx", bootfile);
|
||||
#endif
|
||||
return 0;
|
||||
if (run_program(RUN_DISPLAY | RUN_PROGRESS,
|
||||
"/sbin/newfs -V2 -O 0 -b %d -f %d /dev/r%s%c",
|
||||
PART_BOOT_BSIZE, PART_BOOT_FSIZE, diskdev, 'a' + PART_BOOT))
|
||||
return 1;
|
||||
return copy_bootloader();
|
||||
}
|
||||
|
||||
int
|
||||
@ -179,12 +210,17 @@ md_cleanup_install(void)
|
||||
#ifndef DEBUG
|
||||
enable_rc_conf();
|
||||
#endif
|
||||
msg_display(MSG_howtoboot);
|
||||
process_menu(MENU_ok, NULL);
|
||||
}
|
||||
|
||||
int
|
||||
md_pre_update(void)
|
||||
{
|
||||
|
||||
if (get_ramsize() <= 32)
|
||||
set_swap(diskdev, bsdlabel);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -192,8 +228,26 @@ md_pre_update(void)
|
||||
int
|
||||
md_update(void)
|
||||
{
|
||||
const char *mntdir = "/mnt2";
|
||||
char bootpath[MAXPATHLEN];
|
||||
struct stat sb;
|
||||
bool hasboot = false;
|
||||
|
||||
md_post_newfs();
|
||||
/*
|
||||
* Check if there is a boot UFS parttion and it has the old bootloader.
|
||||
* We'll update bootloader only if the old one was installed.
|
||||
*/
|
||||
if (!run_program(RUN_SILENT | RUN_ERROR_OK,
|
||||
"mount -r /dev/%s%c %s", diskdev, 'a' + PART_BOOT, mntdir)) {
|
||||
mnt2_mounted = 1;
|
||||
snprintf(bootpath, sizeof(bootpath), "%s/%s", mntdir, "boot");
|
||||
if (stat(bootpath, &sb) == 0 && S_ISREG(sb.st_mode))
|
||||
hasboot = true;
|
||||
run_program(RUN_SILENT | RUN_ERROR_OK, "umount %s", mntdir);
|
||||
mnt2_mounted = 0;
|
||||
if (hasboot)
|
||||
(void)copy_bootloader();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: md.h,v 1.2 2013/05/14 13:08:57 tsutsui Exp $ */
|
||||
/* $NetBSD: md.h,v 1.3 2014/02/19 12:14:40 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
@ -43,8 +43,12 @@
|
||||
#define PART_ROOT PART_A
|
||||
#define PART_SWAP PART_B
|
||||
#define PART_RAW PART_C
|
||||
#define PART_BOOT PART_D
|
||||
#define PART_USR PART_G /* Can be after PART_FIRST_FREE */
|
||||
#define PART_FIRST_FREE PART_D
|
||||
#define PART_FIRST_FREE PART_E
|
||||
|
||||
#define PART_BOOT_FFS
|
||||
#define BOOT_SIZE (8 * 1024 * 1024) /* for a.out kernel and boot */
|
||||
|
||||
#define DEFSWAPRAM 8 /* Assume at least this RAM for swap calc */
|
||||
#define DEFROOTSIZE 64 /* Default root size */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: msg.md.en,v 1.1 2011/07/16 15:52:21 tsutsui Exp $ */
|
||||
/* $NetBSD: msg.md.en,v 1.2 2014/02/19 12:14:40 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
@ -44,12 +44,30 @@ message md_may_remove_boot_medium
|
||||
{
|
||||
}
|
||||
|
||||
message dobootblks
|
||||
{Installing boot blocks on %s....
|
||||
message nobootpartdisklabel
|
||||
{There is no boot UFS partition in the disklabel. The boot partition should
|
||||
be prepared for the LUNA's firmware to load our native bootloader.}
|
||||
|
||||
message copybootloader
|
||||
{Copying bootloader into the 4.3BSD boot partition on %s...
|
||||
}
|
||||
|
||||
message howtoboot
|
||||
{The installation is almost complete. Note the installer doesn't set
|
||||
firmware NVRAM variables to load NetBSD's bootloader by default.
|
||||
|
||||
To boot NetBSD, you need to set boot NVRAM variables 'drv'
|
||||
(or 'id' on LUNA-II), 'par' (partition, should be 'd'), and 'fname'
|
||||
(filename, should be 'boot') by 'k' (Set Boot-file constant) command.
|
||||
|
||||
On LUNA-I, drv 0 is SCSI ID 6 disk, and drv 1 is SCSI ID 5 disk.
|
||||
The firmware can't boot from other SCSI ID disks.
|
||||
On LUNA-II, 'id' is SCSI ID and you can also specify the external SCSI
|
||||
controller number (1) like '1-6'.
|
||||
|
||||
Check 'h' (Help) and 'hk' (Help of 'k' command) commands on the firmware
|
||||
prompt for more details.
|
||||
}
|
||||
|
||||
message set_kernel_1
|
||||
{Kernel (GENERIC)}
|
||||
message set_kernel_2
|
||||
{Kernel (GENERIC_TINY)}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: bsddisklabel.c,v 1.59 2013/11/04 20:07:49 christos Exp $ */
|
||||
/* $NetBSD: bsddisklabel.c,v 1.60 2014/02/19 12:14:40 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
@ -594,7 +594,12 @@ make_bsd_partitions(void)
|
||||
i = (i + dlcylsize * sectorsize - 1) / (dlcylsize * sectorsize);
|
||||
i *= dlcylsize;
|
||||
}
|
||||
#if defined(PART_BOOT_FFS)
|
||||
bsdlabel[PART_BOOT].pi_fstype = FS_BSDFFS;
|
||||
bsdlabel[PART_BOOT].pi_flags = PIF_NEWFS;
|
||||
#else
|
||||
bsdlabel[PART_BOOT].pi_fstype = FS_BOOT;
|
||||
#endif
|
||||
bsdlabel[PART_BOOT].pi_size = i;
|
||||
#ifdef BOOT_HIGH
|
||||
bsdlabel[PART_BOOT].pi_offset = ptend - i;
|
||||
|
Loading…
Reference in New Issue
Block a user