Regarding this thread... I've done a little patch to implement a new command: si_mkautoinstallnetbootfloppy.

This command should replace the si_mkautoinstalldiskette, since this last one can be considered deprecated, because the last kernels+initrds are too big to fit in a single floppy...

The si_mkautoinstallnetbootfloppy creates a bootable floppy using a network-enabled version of GRUB. It should support a lot of ethernet nics (looking at the configure...) and implements the network PXE capabilities using a floppy (so you always need to setup a boot server).

Another way is to use the very cool rom on-line generation (http://rom-o-matic.net/) to generate a floppy boot disk specific for the opportune client's nic (maybe we could add a link in the wiki page...). Anyway, in this case the user must know the specific network card installed in the clients.. so the GRUB approach seems to be easier from the user point of view.

If you think this command could be useful I'll proceed to commit it in the trunk. Let me know... At the moment I'm using it to successfully install my old P3 PC! ;)

Regards,
-Andrea
--- sbin/si_mkautoinstallnetbootfloppy
+++ sbin/si_mkautoinstallnetbootfloppy
0a1,340
+#!/usr/bin/perl -w
+
+#
+# "SystemImager"
+#
+#  Copyright (C) 2005 Andrea Righi <[EMAIL PROTECTED]>
+#  Copyright (C) 1999-2001 Brian Elliott Finley <[EMAIL PROTECTED]>
+#  Copyright (C) 2002 Bald Guy Software <[EMAIL PROTECTED]>
+#
+#   Based on the original si_mkautoinstalldiskette by Brian Elliott Finley
+#   <[EMAIL PROTECTED]>
+#
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation; either version 2 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program; if not, write to the Free Software
+#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+
+use lib "USR_PREFIX/lib/systemimager/perl";
+use File::Copy;
+use Getopt::Long;
+use File::Basename;
+use POSIX qw(uname);
+use SystemImager::Config;
+use SystemImager::Common;
+use SystemImager::Server;
+use vars qw($config $VERSION);
+
+### BEGIN parse the config file ###
+
+my $autoinstall_boot_dir = $config->autoinstall_boot_dir();
+
+if (!$autoinstall_boot_dir) {
+    die "AUTOINSTALL_BOOT_DIR not defined in the config file.";
+}
+### END parse the config file ###
+
+# set shell PATH for system() calls 
+$ENV{PATH} = "/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin";
+
+$VERSION="SYSTEMIMAGER_VERSION_STRING";
+$program_name = "si_mkautoinstallnetbootfloppy";
+$version_info = <<"EOF";
+$program_name (part of SystemImager) v$VERSION
+    
+Copyright (C) 1999-2001 Andrea Righi <[EMAIL PROTECTED]>
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+EOF
+
+$help_info = $version_info . <<"EOF";
+
+Usage: $program_name [OPTION]...
+
+Options: (options can be presented in any order and may be abbreviated)
+ --help
+    Display this output.
+
+ --version
+    Display version and copyright information.
+
+ --quiet
+    Don\'t print any output, just provide an appropriate exit code.
+    (requires --floppy or --out-file)
+
+ --floppy DEVICE
+    The floppy drive device containing the disk to format.  If not 
+    specified, /dev/fd0 is assumed.  If your kernel, initrd, and 
+    local.cfg file won't fit on a standard 1.44 floppy, you may 
+    specify an alternate floppy device (such as /dev/fd0u1680).
+
+    Use alternate devices at your own risk -- they can do physical
+    damage to _really_ old floppy drives in some cases.  But you 
+    probably wanted to get rid of that floppy drive anyway...
+
+    (if you specify -floppy, $program_name will run non-interactively)
+
+ --out-file FILE    
+    Create a 1.44MB floppy image in FILE.
+
+ --kernel FILE      
+    Specify an alternate autoinstall kernel.
+
+ --initrd FILE      
+    Specify an alternate autoinstall ramdisk.
+
+ --append STRING    
+    A string of options that will be passed to the autoinstall
+    kernel.
+
+Download, report bugs, and make suggestions at:
+http://systemimager.org/
+EOF
+
+GetOptions( 
+    "help"          => \$help,
+    "version"       => \$version,
+    "floppy=s"      => \$floppy_device_prefix,
+    "kernel=s"      => \$kernel,
+    "initrd=s"      => \$initrd,
+    "append=s"      => \$append_string,
+    "quiet"         => \$quiet,
+    "out-file=s"    => \$file
+) || die "$help_info";
+
+# if requested, print help information
+if($help) {
+  print "$help_info";
+  exit 0;
+}
+
+# if requested, print version and copyright information
+if($version) {
+  print "$version_info";
+  exit 0;
+}
+
+# i386 is the only supported architecture for autoinstall floppies. -BEF-
+my $arch = (uname())[4];
+$arch =~ s/i.86/i386/;
+if ($arch ne "i386") {
+    die "Autoinstall diskettes are only supported for the i386 architecture.";
+}
+
+# if not run as root, this script will surely fail
+unless($< == 0) { die "Must be run as root!\n"; }
+
+# if floppy device not specified, set value to run in interactive mode
+if ($floppy_device_prefix and $file) {
+    die "--floppy and --file are mutually exclusive";
+}
+
+if($floppy_device_prefix) { 
+    $user_specified_floppy=1;
+} elsif($file) { 
+    $user_specified_file=1;
+}
+
+if (!$append_string) { $append_string = ""; }
+
+# Be sure the user includes --floppy or --out-file when doing --quiet
+if($quiet and !$user_specified_floppy and !$user_specified_file) { 
+    print "FATAL: Must use --floppy or --out-file with --quiet! (use -help for options)\n";
+    exit 1;
+}
+
+# if user did not specify a floppy device, choose the default
+if(!$user_specified_floppy and !$user_specified_file) {
+    $floppy_device_prefix = "/dev/fd0";
+}
+
+# verify that a valid floppy device was specified
+if (! $file) {
+    if (! ($floppy_device_prefix =~ /^\/dev\/fd/)) {
+	    die "ERROR: Invalid --floppy argument.\n $help_info";
+    }
+}
+
+# if appropriate, run interactively
+if (!$user_specified_floppy and !$user_specified_file) {
+    system('clear');
+    print << 'EOF';
+
+This program assumes that you have a 1.44MB floppy drive and that
+it is /dev/fd0.  You can use the --floppy command line option to
+change this value.
+
+If you do use --floppy, this command will run non-interactively!!!
+Use the --help option to see all options.
+
+Insert your floppy diskette now.  This will overwrite all
+information on your diskette.
+
+EOF
+
+    print "Continue? (y/[n]): ";
+    $continue=<STDIN>;
+    chomp $continue;
+    $continue = lc $continue;
+    ($continue eq "y") or die "\nYour diskette has not been modified...\n";
+}
+
+# create floppy device if necessary
+if ($floppy_device_prefix and !$file) {
+    $floppy_device=$floppy_device_prefix;
+    unless (-b $floppy_device) {
+	    die "Couldn't find device file $floppy_device.\n";
+    }
+
+    # format floppy
+    if (!$quiet) { print "Formatting floppy using $floppy_device ...\n"; }
+    if (-x "/usr/bin/superformat") {
+
+        if ($quiet) {
+            system ("superformat $floppy_device hd > /dev/null 2>&1");
+        } else {
+            system ("superformat $floppy_device hd");
+        }
+        unless ($? == 0) { die "Couldn't format $floppy_device.\n"; }
+
+    } elsif (-x "/usr/bin/fdformat") {
+        
+        if ($quiet) {
+            system ("fdformat $floppy_device > /dev/null 2>&1");
+        } else {
+            system ("fdformat $floppy_device");
+        }
+        if($? != 0) { die "Couldn't format $floppy_device.\n"; }
+
+    }
+
+    if (!$quiet) {
+	    print "Creating DOS filesystem on floppy...\n";
+    }
+
+    if ($quiet) {
+	    system("mkdosfs $floppy_device > /dev/null");
+    } else {
+	    system("mkdosfs $floppy_device");
+    }
+
+    unless ($? == 0) { die "Couldn't create dos filesystem on $floppy_device.\n"; }
+    $loop = "";
+}
+
+elsif ($file) {
+    if (-e "$file") {
+        if ($quiet) { 
+            print "FATAL: $file already exists, taking conservative action and exiting.\n";
+            print "Your diskette has not been modified...\n";
+            exit 1;
+        } else {
+            print "$file already exists, overwrite? (y/[n]): ";
+            $continue=<STDIN>;
+            chomp $continue;
+            $continue = lc $continue;
+            ($continue eq "y") or die "\nYour diskette has not been modified...\n";
+        }
+    }
+    system ("dd if=/dev/zero of=$file bs=512 count=2880");
+    if ($? != 0) { die "Couldn't create $file"; }
+
+    $floppy_device=$file;
+    $loop = "-o loop";
+    
+    # create dos filesystem on floppy
+    if (!$quiet) {
+        print "Creating DOS filesystem in $file...\n";
+    }
+    if ($quiet) {
+        system("mkdosfs $floppy_device > /dev/null");
+    } else {
+        system("mkdosfs $floppy_device");
+    }
+    unless ($? == 0) { die "Couldn't create dos filesystem on $floppy_device.\n"; }
+}
+
+# create temporary mount point
+if (!$quiet) { print "Creating temporary mount point...\n"; }
+$mnt_dir="/tmp/.autoinstalldiskette.$$";
+mkdir $mnt_dir, 0770 or die "Couldn't create temporary mount point $mnt_dir.\n";
+
+# mount the freshly created filesystem
+if (!$quiet) { print "Mounting floppy...\n"; }
+$command="mount -t msdos $floppy_device $mnt_dir $loop";
+system($command);
+if($? != 0) { die "Couldn't execute: $command!\n"; }
+
+# copy GRUB files into floppy
+my $grub_dir = "/usr/share/systemimager/grub";
+system("mkdir -p $mnt_dir/boot/grub");
+system("cp -f $grub_dir/stage1 $mnt_dir/boot/grub");
+system("cp -f $grub_dir/stage2 $mnt_dir/boot/grub");
+
+# create GRUB configuration file (get info from syslinux.cfg file)
+my $netboot_file = "/etc/systemimager/pxelinux.cfg/syslinux.cfg";
+unless (-f $netboot_file) {
+    system('umount', $floppy_device);
+    die("Couldn't find netboot file: $netboot_file!\n");
+}
+chomp(my $kernel_params = `cat $netboot_file | sed -ne "s/^APPEND //p" | sed -ne '1p'`);
+unless ($kernel) {
+    chomp($kernel = `cat $netboot_file | sed -ne "s/^KERNEL //p" | sed -ne '1p'`);
+}
+unless ($initrd) {
+    $initrd = (grep(/^initrd=/, split(' ', $kernel_params)))[0];
+    $initrd =~ s/^initrd=//; 
+}
+my $timeout = `cat $netboot_file | sed -ne "s/^TIMEOUT/timeout/p"`;
+open(MENULST, '>', "$mnt_dir/boot/grub/menu.lst");
+my $menu_lst = "
+default 0
+$timeout
+
+title netboot
+bootp
+kernel (nd)/$kernel $kernel_params $append_string
+initrd (nd)/$initrd
+";
+print MENULST $menu_lst;
+close(MENULST);
+
+# unmount floppy
+if (!$quiet) {print "Un-mounting floppy...\n";}
+system('umount', $floppy_device);
+if($? != 0) {
+  die "Couldn't un-mount $floppy_device from $mnt_dir.\n";
+}
+
+# clean temporary mount point
+system("rm -rf $mnt_dir");
+
+# install GRUB into floppy
+`$grub_dir/grub --batch << EOF
+device (fd0) $floppy_device
+install (fd0)/boot/grub/stage1 (fd0) (fd0)/boot/grub/stage2 p (fd0)/boot/grub/menu.lst
+quit
+EOF`;
+
+# print done!
+if (!$quiet) { print "Done!\n";}
+exit 0;
+
+sub get_response {
+    my $garbage_out=$_[0];
+    my $garbage_in=<STDIN>;
+    chomp $garbage_in;
+    unless($garbage_in eq "") { $garbage_out = $garbage_in; }
+    return $garbage_out;
+}
+

--- make.d/grub.rul
+++ make.d/grub.rul
0a1,32
+#
+#	2005-12-04 Andrea Righi
+#   	- GRUB netboot-enabled
+#
+
+
+GRUB_VERSION        := 0.97
+GRUB_DIR		    := grub-$(GRUB_VERSION)
+GRUB_TARBALL	    := grub-$(GRUB_VERSION).tar.gz
+GRUB_URL		    := ftp://systemimager.org/$(GRUB_TARBALL)
+GRUB_BINARY	        := $(SRC_DIR)/$(GRUB_DIR)/grub/grub
+
+PHONY += grub
+grub:  $(GRUB_BINARY)
+$(GRUB_BINARY): $(SRC_DIR)/$(GRUB_TARBALL)
+	rm -rf $(SRC_DIR)/$(GRUB_DIR)
+	cd $(SRC_DIR) && tar -xvzf $(GRUB_TARBALL)
+	cd $(SRC_DIR)/$(GRUB_DIR) && \
+		./configure --enable-3c509 --enable-3c529 --enable-3c595 --enable-3c90x --enable-cs89x0 --enable-davicom --enable-depca --enable-eepro --enable-eepro100 --enable-epic100 --enable-3c507 --enable-exos205 --enable-ni5210 --enable-lance --enable-ne2100 --enable-ni6510 --enable-natsemi --enable-ni5010 --enable-3c503 --enable-ne --enable-ns8390 --enable-wd --enable-otulip --enable-rtl8139 --enable-sis900 --enable-sk-g16 --enable-smc9000 --enable-tiara --enable-tulip --enable-via-rhine --enable-w89c840 --enable-diskless
+	$(MAKE) -C $(SRC_DIR)/$(GRUB_DIR)
+
+$(SRC_DIR)/$(GRUB_TARBALL):
+	[ -d $(SRC_DIR) ] || mkdir -p $(SRC_DIR)
+	$(GETSOURCE) $(GRUB_URL) $(SRC_DIR)
+
+ALL_SOURCE += $(SRC_DIR)/$(GRUB_TARBALL)
+
+PHONY += grub_clean
+grub_clean:
+	rm -rf $(SRC_DIR)/$(GRUB_DIR)
+
+# /* vi: set noet ts=4: */

--- Makefile	(revision 3275)
+++ Makefile	(working copy)
@@ -182,11 +182,12 @@
 INITRD_DIR = $(TOPDIR)/initrd_source
 
 BOOT_BIN_DEST     = $(USR)/share/systemimager/boot/$(ARCH)/$(FLAVOR)
+GRUB_INSTDIR      = $(USR)/share/systemimager/grub
 
 PXE_CONF_SRC      = etc/pxelinux.cfg
 PXE_CONF_DEST     = $(ETC)/systemimager/pxelinux.cfg
 
-BINARIES := si_mkautoinstallcd si_mkautoinstalldiskette si_mkbootmedia
+BINARIES := si_mkautoinstallcd si_mkautoinstalldiskette si_mkautoinstallnetbootfloppy si_mkbootmedia
 SBINARIES := si_addclients si_cpimage si_getimage si_mkdhcpserver si_mkdhcpstatic si_mkautoinstallscript si_mkbootserver si_mvimage si_pushupdate si_rmimage si_mkrsyncd_conf si_mkclientnetboot si_netbootmond si_imagemanip si_mkbootpackage si_monitor si_monitortk
 CLIENT_SBINARIES  := si_updateclient si_prepareclient
 COMMON_BINARIES   = si_lsimage
@@ -310,6 +311,13 @@
 
 	$(SI_INSTALL) -d -m 755 $(FLAMETHROWER_STATE_DIR)
 
+	# netboot-enabled GRUB stuff    
+	$(SI_INSTALL) -d -m 755 $(GRUB_INSTDIR)
+	$(SI_INSTALL) -m 755 $(SRC_DIR)/$(GRUB_DIR)/grub/grub $(GRUB_INSTDIR)
+	$(SI_INSTALL) -m 755 $(SRC_DIR)/$(GRUB_DIR)/stage1/stage1 $(GRUB_INSTDIR)
+	$(SI_INSTALL) -m 755 $(SRC_DIR)/$(GRUB_DIR)/stage2/stage2 $(GRUB_INSTDIR)
+
+
 # install client-only files
 .PHONY:	install_client
 install_client: install_client_man install_client_libs
@@ -493,6 +501,7 @@
 				$(OPENSSH_BINARIES) \
 				$(OPENSSH_CONF_FILES) \
 				$(LVM_BINARY) \
+				$(GRUB_BINARY) \
 				$(SRC_DIR)/modules_build-stamp
 	#
 	# Put binaries in the boel_binaries_tarball...

Reply via email to