From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 24142 invoked from network); 2 Sep 1998 15:02:28 -0000 Received: from mail.redhat.com (199.183.24.239) by mail2.redhat.com with SMTP; 2 Sep 1998 15:02:28 -0000 Received: from altatech.com (altatech.com [198.60.83.58]) by mail.redhat.com (8.8.7/8.8.7) with ESMTP id LAA16219 for ; Wed, 2 Sep 1998 11:03:11 -0400 Received: from alta.altatech.com (alta [198.60.83.200]) by altatech.com (8.8.3/8.8.3) with ESMTP id JAA03314; Wed, 2 Sep 1998 09:02:06 -0600 Received: from ALTA/SpoolDir by alta.altatech.com (Mercury 1.21); 2 Sep 98 08:03:35 MDT Received: from SpoolDir by ALTA (Mercury 1.21); 2 Sep 98 08:03:14 MDT Received: from altatech.com by alta.altatech.com (Mercury 1.21) with ESMTP; 2 Sep 98 08:03:08 MDT Sender: cworley@altatech.com Message-ID: <35ED5D82.248048C7@altatech.com> Date: Wed, 02 Sep 1998 09:00:18 -0600 From: Christian Worley Organization: Alta Technology X-Mailer: Mozilla 4.05 [en] (X11; I; SunOS 5.6 sun4u) MIME-Version: 1.0 To: axp-list@redhat.com, ballen@dirac.phys.uwm.edu, Andreas Haumer , Greg Lindahl , extreme-linux@acl.lanl.gov, beowulf@cesdis1.gsfc.nasa.gov Subject: Another method for changing Milo's reboot arguments from a running AXP system. References: <199806091744.NAA07243@linux03.hlo.dec.com> Content-Type: multipart/mixed; boundary="------------D8AAE03CA0E94A9E0A41D605" This is a multi-part message in MIME format. --------------D8AAE03CA0E94A9E0A41D605 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit I have a new method for changing Milo's boot parameters from a running system. It's a simple program, that needs to be run by root. It's attached. It modifies the "milo reboot block", by searching for it's magic number "MIDOODIM", then modifying the boot parameters. It takes three or four arguments: the boot device by number, the boot file by name, the boot string, and, optionally, if the change is to be permanent in NVRAM. The last argument only works for systems that boot from milo in NVRAM, which we use, since milo doesn't require a keyboard (and AlphaBios and ARC do, at least, you have to acknowledge from the serial port that you know there's no keyboard before these will boot). Other than that, the code should work for all milo's, no matter how they're started, for a one-shot reboot. This is useful for cloning. For example, if you run: ./chgroot 0x200 /vmalta.gz "root=/dev/nfsroot init=/tftpboot/scripts/clonerc " Then reboot, the next invocation of the system will use the "vmalta.gz" kernel off the floppy, use an NFS mounted root file system, and run the "clonerc" script (for re-writting the main disk). If the system is power-cycled before rebooting, then all bets are off! To make the new boot permanent, any additional argument will do (I usually just add "yes" to the end of the command line). I.e., if I want to start booting from the hard disk (which I do at the end of running the "clonerc" script), I run: ./chgroot 0x301 /vmalta.gz root=/dev/hda1 yes Or, to permanently run in bootp/NFS root diskless mode, I run: ./chgroot 0x200 /vmalta.gz "root=/dev/nfsroot init=/tftpboot/scripts/disklessrc" yes Then, reboot the system. This permanent change requires milo to run from NVRAM. Which, if you search the AXP list, Jim and Jay will give you many reasons why you should never do this. Foremost, it won't emulate a scsi bios (so, no scsi devices/controllers allowed). Also, if you're compiling from a glibc, the DEC proprietary VGA bios emulation won't work (RH4.2 systems work OK). But, these are headless and keyboardless nodes, with no scsi devices. ARC and AlphaBios won't autoboot without a keyboard, and SRM has a per-node fee. So, Milo wins. I did have to make some changes to the milo code to get the NVRAM boot arguments code working. Make sure to use the "-DMINI_NVRAM" flag when compiling milo. When you "make milo.rom", you have to add the key "MILO Environment" at the beginning of a 65K block of the rom image. Right after "makerom" in the makefile, I add the line: (dd if=./milo.rom bs=65536 conv=sync;echo "MILO Environment" ) >lx164nt.rom To make sure that worked, I follow that with the line: od -taxL lx164nt.rom | tail I place the "lx164rom.nt" on a floppy (that's the only name AlphaBios will accept), and burn the new image into NVRAM from the AlphaBios option. If I'm already running milo, then I jumper the motherboard to run the failsafe booter, stick in the AlphaBios floppy, then burn in the new Milo. I did have to make a source change to milo to get this working. If I modify the 65K block where "Milo Environment" is placed, then the serial ROM, while check-summing the NVRAM, notices the change and goes straight to the failsafe booter, So, I modify "nvram.c", in the "find_nvram" routine to return the next block number. Instead of: if (strncmp(buffer, id, strlen(id)) == 0) return block; It now returns the next block number: if (strncmp(buffer, id, strlen(id)) == 0) return block + 1; So, two NVRAM blocks are wasted for the environment. The other change to the source is in "milo.c". In the "reboot" routine, Milo needs to look for the flag that the "chgboot" application (source attached) set if the changes are to be permanent. Right after the line that reads (in the "reboot" routine): device_number_to_name(milo_reboot_block->boot_device, bootdev); I add: if (milo_reboot_block->spare2 == 1) { setenv("BOOT_DEV", bootdev); setenv("BOOT_FILE", milo_reboot_block->boot_filename); setenv("BOOT_STRING", milo_reboot_block->boot_string); } This will write the new reboot arguments into NVRAM. Disclaimer: I nor Alta Technology guarantee this to work (except to our customers). If it breaks, keep both pieces. Specifically, the source included modifies kernel memory from a user task; that can be dangerous. Furthermore, re-writing NVRAM can permanently disable your system. Otherwise, enjoy! Chris --- When I die, please cast my ashes upon Bill Gates --for once, let him clean up after me! --------------D8AAE03CA0E94A9E0A41D605 Content-Type: text/plain; charset=us-ascii; name="chgboot.c" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="chgboot.c" #include #include typedef struct { unsigned long signature1; unsigned long flags; unsigned short boot_device; short boot_filesystem; unsigned short memory_size; unsigned short spare2; unsigned char boot_filename[32]; unsigned char boot_string[64]; unsigned long signature2; } Milo_reboot_t; char *midoodim = "MIDOODIM"; main(int argc, char **argv) { Milo_reboot_t rb; long int *rebootblockp = (long int *)midoodim; long int rebootblock = *rebootblockp; long int data; int i; FILE *fd = fopen("/dev/kmem","w+"); fpos_t pos ; for (i=0; fread(&data,8,1,fd) == 1L; i++) { if (data == rebootblock) { pos = i*8; fsetpos(fd,&pos); fread(&rb, sizeof(Milo_reboot_t), 1, fd); rb.boot_device = strtoul(argv[1],NULL,0); strcpy(rb.boot_filename,argv[2]); strcpy(rb.boot_string,argv[3]); if (argc > 4) rb.spare2 = 1; fsetpos(fd,&pos); fwrite(&rb, sizeof(Milo_reboot_t), 1, fd); printf("New device: %x New kernel: %s New Args: %s\n",rb.boot_device,rb.boot_filename,rb.boot_string); return; } } fprintf(stderr,"Boot block not found after %d bytes\n",i); } --------------D8AAE03CA0E94A9E0A41D605--