Patch with new features for boot-floppies
Attached a patch that adds some features to the boot-floppies. These
patches were used for a long time in the TelemetryBox distribution (see
http://telemetrybox.org). For the next release I would like to reduce the
special patches I maintain as much as possible. The stuff here is
a port to the current cvs boot-floppies.
Features:
1. Hardware autodetection implemented with a simple short script that
correlates kernel information in /proc and module information in
/lib/modules to figure out which modules to load.
2. Fully unattended install. Selection of unattended install will do
partitioning/formatting/driver config etc using defaults and allows
newbies to get up and running.
3. One pass Installations are possible. The CD contents are copied to the
installation medium during the setup phase and are installed later when
the system comes up for the first time from the HD.
4. Autopartitioning
A new option that will simply wipe out the first harddisk and then setup a
partitioning scheme and format partitions.
Minor modifications to the debian-cd and baseconfig packages are
needed to get the full functionality to work.
The patch adds some flags that can be specified on boot as parameters to
the install process. The flags can be set during CD generation. Those
flags are:
batch -> unattended install. No interaction at all.
copycd -> copy the package contents on the CD in /dists to the installation medium.
copycd is particularly useful with credit card size CDs which can have
around 40 Meg of .deb packages. I have been using this for some time and
distributed these CC size debian CDs on conferences.
driver=tulip
-> force loading of a special device driver
install=xxx
-> Make the system install a particular package/task as a part
of the installation process. This makes the install skip tasksel/dselect.
With these modifications the debian installer will be able to be used for
the easy deployment of operating system and applications on a CD. Regular
office personnel will be able to handle an install.
How much of this could go into the regular boot floppy package?
I will be reworking and testing these patches in the next days.
It was suggested to use a new for of modconf (modconf2) for autodetection
in the past. I have tried modconf2 but it would probably be difficult to
make it work right and integrate it into the current boot-floppies
package. The following script is much easier to integrate:
pcidetect script:
-------------------------------------------------------------------------------------
#!//bin/sh
# Pci Driver loading and detection for the currently running kernel
# Christoph Lameter, October 15, 2001
VERBOSE=0
MODPROBE=0
loaddriver() {
echo $1
if [ $MODPROBE -eq 1 ]; then
modprobe $1
fi
}
driver() {
VER=`uname -r`
LINE=`grep "0x0000${2:0:4} 0x0000${2:4:4}" /lib/modules/$VER/modules.pcimap`
if [ $? == 0 ]; then
loaddriver $LINE
else
if [ $VERBOSE -eq 1 ]; then
echo "No driver for PCI ID=$2"
fi
fi
}
p() {
while read X; do
driver $X
done
}
while getopts "mv", opt ; do
case $opt in
'v')
VERBOSE=1
;;
'm')
MODPROBE=1
;;
*)
exit 1
;;
esac
done
p </proc/bus/pci/devices
-------------------------------------------------------------------------------------
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/dbootstrap/baseconfig.c,v
retrieving revision 1.82
diff -u -r1.82 baseconfig.c
--- utilities/dbootstrap/baseconfig.c 2001/10/16 14:50:58 1.82
+++ utilities/dbootstrap/baseconfig.c 2001/10/17 23:15:42
@@ -552,8 +552,23 @@
#endif
execlog("depmod -a", LOG_INFO);
+
+ if (bootargs.drivers) {
+ snprintf(prtbuf,sizeof(prtbuf),"/target/usr/sbin/modconf"
+ " --exclude-section pcmcia"
+ " --target /target"
+ " --run-shell cdromsymlink"
+ " --load-before %s",bootargs.drivers);
+ fullscreen_execlog(prtbuf);
+ }
- fullscreen_execlog("/target/usr/sbin/modconf"
+ if (bootargs.batch) {
+/* execlog("pcidetect -m -v",LOG_INFO); */
+ extern int pciDetectDone;
+ execlog("pcidetect >>/target/etc/modules",LOG_INFO);
+ pciDetectDone=1;
+ } else
+ fullscreen_execlog("/target/usr/sbin/modconf"
" --exclude-section pcmcia"
" --target /target"
" --run-shell cdromsymlink"
Index: utilities/dbootstrap/bootconfig.c
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/dbootstrap/bootconfig.c,v
retrieving revision 1.150
diff -u -r1.150 bootconfig.c
--- utilities/dbootstrap/bootconfig.c 2001/10/16 03:52:31 1.150
+++ utilities/dbootstrap/bootconfig.c 2001/10/17 23:15:48
@@ -2204,7 +2204,7 @@
device[idx] = '\0';
partition = strdup(boot + idx);
snprintf(prtbuf, sizeof(prtbuf), _("If you want the Debian system to boot automatically from the hard disk when you turn your system on, answer \"Yes\" to the following question.\nIf you have another operating system that you'd prefer to be the one that boots automatically, answer \"No\".\nBoot the Debian system on %s as the default?"), boot);
- if (yesNoBox(prtbuf,_("Make Linux the Default Boot Partition?")) == DLG_YES) {
+ if (autopartitioning || yesNoBox(prtbuf,_("Make Linux the Default Boot Partition?")) == DLG_YES) {
INFOMSG("making linux partition '%s' the default for device '%s'",
partition, device);
snprintf(prtbuf, sizeof(prtbuf), BC_BOOT_DFLT, device, partition);
@@ -2286,9 +2286,12 @@
opt[1].string = _("Install LILO in the root partition's boot sector.");
snprintf(prtbuf, sizeof(prtbuf), _("LILO can be installed either into the master boot record (MBR), or into the %s boot block. If installed into the MBR, LILO will take control of the boot process. If you choose not to install LILO into the MBR, you will have the opportunity later on to install an alternative MBR program (for bootstrapping LILO).\n"),
Boot->name);
- if ( (res = menuBox(prtbuf, _("Where should the LILO boot loader be installed?"), opt, 2, 1) == -1 ))
+ if (autopartitioning)
+ res=1;
+ else {
+ if ( (res = menuBox(prtbuf, _("Where should the LILO boot loader be installed?"), opt, 2, 1) == -1 ))
return 0;
-
+ }
boot = opt[res].tag;
installed_mbr = (res == 0);
}
Index: utilities/dbootstrap/choose_medium.c
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/dbootstrap/choose_medium.c,v
retrieving revision 1.112
diff -u -r1.112 choose_medium.c
--- utilities/dbootstrap/choose_medium.c 2001/09/08 15:36:48 1.112
+++ utilities/dbootstrap/choose_medium.c 2001/10/17 23:15:53
@@ -735,7 +735,7 @@
umount(CM_MOUNTPOINT_DIR);
- problemBox(_("Please place the first Debian CD-ROM in the CD-ROM drive."),
+ if (!is_cdrom_image()) problemBox(_("Please place the first Debian CD-ROM in the CD-ROM drive."),
_("Please insert the CD-ROM"));
if (execlog("mount -t iso9660 -o nojoliet -r /dev/cdrom " CM_MOUNTPOINT_DIR, LOG_INFO)) {
Index: utilities/dbootstrap/dbootstrap.h
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/dbootstrap/dbootstrap.h,v
retrieving revision 1.90
diff -u -r1.90 dbootstrap.h
--- utilities/dbootstrap/dbootstrap.h 2001/10/16 14:50:58 1.90
+++ utilities/dbootstrap/dbootstrap.h 2001/10/17 23:15:53
@@ -149,6 +149,10 @@
int isdebug;
int isverbose;
int isquiet;
+ int batch;
+ int copycd;
+ char *drivers;
+ char *install;
} bootargs;
enum extract_type {
@@ -168,7 +172,7 @@
char *InstallationRootDevice,*Archive_Dir;
struct fdisk_partition *Boot;
struct fdisk_partition *Root;
-int noSwap, notCreatedBootFloppy, notInstalledLILO;
+int noSwap, notCreatedBootFloppy, notInstalledLILO,autopartitioning;
static const char * fs_type_tab[];
Index: utilities/dbootstrap/extract_base.c
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/dbootstrap/extract_base.c,v
retrieving revision 1.58
diff -u -r1.58 extract_base.c
--- utilities/dbootstrap/extract_base.c 2001/10/16 05:31:15 1.58
+++ utilities/dbootstrap/extract_base.c 2001/10/17 23:15:54
@@ -434,6 +434,10 @@
execlog(prtbuf, LOG_INFO);
configure_base () ;
+ if (bootargs.copycd) {
+ pleaseWaitBox("Packages from CD are being copied to the Harddisk");
+ execlog("cp -a /instmnt/dists /target", LOG_INFO);
+ }
sync();
return 0;
Index: utilities/dbootstrap/main.c
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/dbootstrap/main.c,v
retrieving revision 1.126
diff -u -r1.126 main.c
--- utilities/dbootstrap/main.c 2001/10/05 02:00:00 1.126
+++ utilities/dbootstrap/main.c 2001/10/17 23:15:55
@@ -172,6 +172,10 @@
{ "verbose", 1, &bootargs.isverbose}, /* chatty mode */
{ "quiet", 1, &bootargs.isquiet }, /* quiet mode */
{ "cdrom", 1, &bootargs.cdrom }, /* cdrom install */
+ { "install=", 0, &bootargs.install }, /* install task/package. Bypass tasksel stage */
+ { "drivers=", 0, &bootargs.drivers }, /* Load indicated drivers */
+ { "batch", 1, &bootargs.batch }, /* Unattended install */
+ { "copycd", 1, &bootargs.copycd }, /* Copy packages on CD to HD and select HD as install source */
{ NULL, 0, NULL }
};
@@ -721,7 +725,7 @@
boxInit();
#ifdef USE_LANGUAGE_CHOOSER
- if ((lang = boxChooseLanguageVariant (available_languages ())) != NULL)
+ if (!bootargs.isquiet && !bootargs.batch && (lang = boxChooseLanguageVariant (available_languages ())) != NULL)
{
char *msgcat = (char *)malloc (PATH_MAX);
@@ -817,7 +821,7 @@
notCreatedBootFloppy = 1;
notInstalledLILO = 1;
Archive_Dir=NULL;
-
+ autopartitioning=0;
InstallationRootDevice=block_device("/");
if (!InstallationRootDevice) {
/* something's borked, cannot determine where / comes from */
Index: utilities/dbootstrap/main_menu.c
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/dbootstrap/main_menu.c,v
retrieving revision 1.76
diff -u -r1.76 main_menu.c
--- utilities/dbootstrap/main_menu.c 2001/10/16 14:50:58 1.76
+++ utilities/dbootstrap/main_menu.c 2001/10/17 23:15:57
@@ -10,6 +10,8 @@
#include "util.h"
static int failedBaseInstall = 0;
+int pciDetectDone = 0;
+int autoPartitionDone =0;
int true (void) {
return 0;
@@ -97,6 +99,8 @@
#endif
#endif //!_TESTING_
+int batch_install(void) { bootargs.batch=1;return 0; }
+
int main_menu_extract_base ()
{
return failedBaseInstall = debootstrap_extract_base ();
@@ -123,15 +127,16 @@
#define OPT_Previous1 1005
#define OPT_CONFIGURE_KEY 1006
#define OPT_PARTITION_DISK 1007
-#define OPT_INITIALIZE_SWAP 1008
-#define OPT_ACTIVATE_SWAP 1009
-#define OPT_DO_WITHOUT_SWAP 1010
-#define OPT_INITIALIZE_LINUX 1011
-#define OPT_MOUNT_LINUX 1012
-#define OPT_UMOUNT_LINUX 1013
-#define OPT_INSTALL_OS 1014
-#define OPT_INSTALL_BASE 1015
-#define OPT_CONFIGURE_MODULES 1016
+#define OPT_BATCH_INSTALL 1008
+#define OPT_INITIALIZE_SWAP 1009
+#define OPT_ACTIVATE_SWAP 1010
+#define OPT_DO_WITHOUT_SWAP 1011
+#define OPT_INITIALIZE_LINUX 1012
+#define OPT_MOUNT_LINUX 1013
+#define OPT_UMOUNT_LINUX 1014
+#define OPT_INSTALL_OS 1015
+#define OPT_INSTALL_BASE 1016
+#define OPT_CONFIGURE_MODULES 1017
#define OPT_CONFIGURE_NET 1018
#define OPT_DISK_BOOT 1019
#define OPT_FLOPPY_BOOT 1020
@@ -148,7 +153,7 @@
#define OPT_PROBLEM_REPORT 1031
#define OPT_FOREIGN_MODULES 1032
#define OPT_ATTACH_DISK 1033
-#define NITEMS 31
+#define NITEMS 32
int data, ilist[NITEMS], items, i, rs;
struct d_choices choices[NITEMS];
struct { char *string; int key; } entries[] = {
@@ -162,6 +167,7 @@
#if (#cpu(i386))
{_("Preload modules from a floppy"), OPT_LOAD_MODULES_FROM_A_FD_AFTER_BOOT},
#endif
+ {_("Unattended installation (Wiping out all contents of first disk)"), OPT_BATCH_INSTALL},
{_("Partition a Hard Disk"), OPT_PARTITION_DISK},
{_("Initialize and Activate a Swap Partition"), OPT_INITIALIZE_SWAP},
{_("Activate a Previously-Initialized Swap Partition"), OPT_ACTIVATE_SWAP},
@@ -322,8 +328,12 @@
goto done_keyboard;
#endif
}
-
+ if (bootargs.batch && !autoPartitionDone) {
+ partition_disk();
+ autoPartitionDone=1;
+ continue;
+ }
next_action = configure_keyboard_m;
bufT = _("You must indicate what sort of keyboard you have so that keys operate as expected. Select \"Next\" from the menu to configure your keyboard.");
bufN = _("Configure the Keyboard");
@@ -438,6 +448,8 @@
next_action = partition_disk;
bufT = _("No Linux partitions were detected. At least one Linux partition is required to hold the root filesystem. Selecting \"Next\" will start the partitioning program. Use that to create \"Linux native\" partitions on your local disk.");
bufN = _("Partition a Hard Disk");
+ alternate_action = batch_install;
+ bufA = _("Unattended installation (wiping out the contents of the first disk)");
}
else if ((swapon_partitions == NULL) && (noSwap == 0)) {
/*
@@ -500,6 +512,11 @@
/*
* The modules have not been configured.
*/
+ if (bootargs.batch && !pciDetectDone) {
+ configure_drivers();
+ pciDetectDone=1;
+ goto done_keyboard;
+ }
next_action = configure_drivers;
bufN = _("Configure Device Driver Modules");
#if !(#cpu(alpha) || #cpu(m68k) || #cpu(hppa) || #cpu(mips) || #cpu(mipsel))
@@ -546,6 +563,10 @@
/*
* The network has not been configured and made active.
*/
+ if (bootargs.batch) {
+ configure_network();
+ goto done_keyboard;
+ }
next_action = configure_network;
if (is_network_up(0))
bufT = _("Your network is active, but it has not been configured for the system to remember. If your system is configuring itself via hardware (i.e., your system can setup its network before Linux boots through DHCP or BOOTP), you should still setup the configuration so that the network can be brought up and down after booting. If you configured the network yourself, then you also need to perform this step.");
@@ -600,6 +621,12 @@
&& (strcmp(Arch2, "Mac") != 0)
#endif
) {
+ /* If the user did autopartitioning (does not care about HD boot setup) then simply use defaults */
+ if (autoPartitionDone) {
+ make_bootable();
+ reboot_system();
+ goto done_keyboard;
+ }
/*
* Reboot, chroot, or create a boot floppy.
*/
@@ -719,7 +746,7 @@
items++;
}
- rs = menuBox (bufT, _("Debian GNU/Linux Installation Main Menu"), choices, items, 0);
+ rs = menuBox (bufT, _("TelemetryBox Debian GNU/Linux Installation Main Menu"), choices, items, 0);
data = ilist[rs];
#ifndef _TESTING_
Index: utilities/dbootstrap/net-fetch.c
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/dbootstrap/net-fetch.c,v
retrieving revision 1.50
diff -u -r1.50 net-fetch.c
--- utilities/dbootstrap/net-fetch.c 2001/10/16 05:42:58 1.50
+++ utilities/dbootstrap/net-fetch.c 2001/10/17 23:15:58
@@ -339,11 +339,11 @@
// http://http.us.debian.org/debian/dists/potato/main/disks-$arch/current/
nf_state.method = strdup("http");
- nf_state.server.hostname = strdup("http.us.debian.org");
+ nf_state.server.hostname = strdup("ftp.telemetrybox.org");
nf_state.server.port = 80;
nf_state.proxy.hostname = strdup("none");
nf_state.proxy.port = 8080;
- snprintf(prtbuf, sizeof(prtbuf) - 1, "debian/" ARCHIVE_LOCATION "/", ARCHNAME);
+ snprintf(prtbuf, sizeof(prtbuf) - 1, "tbox/local/" ARCHNAME);
nf_state.path = strdup(prtbuf);
#if defined (_TESTING_)
Index: utilities/dbootstrap/netconfig.c
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/dbootstrap/netconfig.c,v
retrieving revision 1.63
diff -u -r1.63 netconfig.c
--- utilities/dbootstrap/netconfig.c 2001/10/16 14:50:58 1.63
+++ utilities/dbootstrap/netconfig.c 2001/10/17 23:16:00
@@ -272,12 +272,12 @@
if(host)
def = host;
else
- def = strdup("debian");
+ def = strdup("telemetrybox");
snprintf(prtbuf, PRTBUFSIZE,
_("Every Debian system has a name - even if it is not on a network. This name is called its \"hostname\". You should now specify a hostname for your new system.\n\nIf your system is going to be on a network, you should talk to the administrator of the network before you choose a hostname. If not, you may choose any name you like.\n\nThe hostname must not contain dots or underscores, and you must not append the domain name here.\n\nIf you can't think of a hostname for your new system, you may press <ENTER> to use the default hostname of \"%s\".\nPlease enter your Host name"), def);
- host = inputBox(prtbuf, _("Choose the Host name"), def);
+ if (bootargs.batch) host = strdup(def); host = inputBox(prtbuf, _("Choose the Host name"), def);
free(def);
def = NULL;
@@ -974,7 +974,7 @@
snprintf(prtbuf, PRTBUFSIZE,
_("Configuration for %s (%s)\n\nDo you want to use DHCP or BOOTP to automatically configure this interface? You'll need a DHCP or BOOTP server in the local network for this to work."),
netinterface, get_ifdsc(netinterface));
- if (yesNoBox(prtbuf, _("Automatic Network Configuration")) == DLG_NO) {
+ if (!bootargs.batch && yesNoBox(prtbuf, _("Automatic Network Configuration")) == DLG_NO) {
ret = configure_static_network();
} else {
pleaseWaitBox(_("Trying to get network configuration using DHCP/BOOTP...\n\nThis may take a few minutes, be patient."));
Index: utilities/dbootstrap/partition_config.c
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/dbootstrap/partition_config.c,v
retrieving revision 1.105
diff -u -r1.105 partition_config.c
--- utilities/dbootstrap/partition_config.c 2001/10/16 15:29:34 1.105
+++ utilities/dbootstrap/partition_config.c 2001/10/17 23:16:03
@@ -198,6 +198,9 @@
}
free (swaps);
}
+ if (bootargs.batch) {
+ myfdisk="/sbin/cfdisk";
+ } else
if (NAME_ISEXE("/sbin/parted", &statbuf)) { /* check whether we have parted */
if(twoButtonBox( _("This set of boot floppies has various programs for partitioning "
"of the harddisk. However, to partition with other programs than "
@@ -223,6 +226,46 @@
myfdisk="/sbin/cfdisk";
}
+ /* prompt for autopartitioning */
+ if (bootargs.batch || yesNoBox(
+ _("Autopartitioning will setup a default partition scheme on your harddisk and format all necessary partitions without any user interaction.\n\nALL EXISTING FILES WILL BE LOST\n\nIf you do not choose autopartitioning then you will be prompted for partitioning and formatting.\nDo you want to autopartition?"),
+ _("Autopartitioning?")))
+ {
+ char *dname=strdup(d->name);
+ char *boot,*swap,*root;
+ extern int autoPartitionDone;
+ /* invoke fdisk with specific arguments */
+ boxSuspend();
+ printf(CLEAR);
+#define FORMAT_STRING "d\n1\nd\n2\nd\n3\nd\n4\nn\np\n1\n\n+20M\na\n1\nn\np\n2\n\n+200M\nt\n2\n82\nn\np\n3\n\n\nw\n"
+ sprintf(prtbuf,"echo -e '%s' | fdisk %s >/dev/null",FORMAT_STRING,dname);
+ status=system(prtbuf);
+ fdisk_reread();
+ d=fdisk_find_disk(dname);
+ if (d==NULL)
+ { problemBox("Owww... Cannot find disk after fdisk run",_("Weirdness"));
+ exit(1);
+ }
+ boot=part_name(d,1);
+ swap=part_name(d,2);
+ root=part_name(d,3);
+ /* format swap */
+ sprintf(prtbuf,"mkswap %s",swap);status=system(prtbuf);
+ /* Activate swap */
+ swapon(swap,0);
+ /* format ext2 partitions */
+ sprintf(prtbuf,"mkfs.ext2 -j %s",root);status=system(prtbuf);
+ sprintf(prtbuf,"mount -t ext3 %s /target",root);status=system(prtbuf);
+ Root=fdisk_find_partition_by_name(root);
+ check_pending_config();
+ status=system("mkdir /target/boot");
+ sprintf(prtbuf,"mkfs.ext2 -j %s",boot);status=system(prtbuf);
+ sprintf(prtbuf,"mount -t ext3 %s /target/boot",boot);status=system(prtbuf);
+ autoPartitionDone=1;
+ boxResume();
+ return 0;
+ }
+
#if #cpu(i386)
if (! bootargs.isquiet)
wideMessageBox(_(
Index: utilities/dbootstrap/util.c
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/dbootstrap/util.c,v
retrieving revision 1.56
diff -u -r1.56 util.c
--- utilities/dbootstrap/util.c 2001/09/11 01:28:54 1.56
+++ utilities/dbootstrap/util.c 2001/10/17 23:16:05
@@ -664,6 +664,12 @@
write_userconfig("DEBUG", "true");
if ( bootargs.cdrom )
write_userconfig("CDROM", "true");
+ if (bootargs.install)
+ write_userconfig("INSTALL",bootargs.install);
+ if (bootargs.copycd)
+ write_userconfig("COPYCD","true");
+ if (bootargs.batch)
+ write_userconfig("BATCH","true");
#ifdef USE_LANGUAGE_CHOOSER
if ( lang != NULL )
Index: utilities/libfdisk/fdisk.c
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/libfdisk/fdisk.c,v
retrieving revision 1.66
diff -u -r1.66 fdisk.c
--- utilities/libfdisk/fdisk.c 2001/09/10 12:39:11 1.66
+++ utilities/libfdisk/fdisk.c 2001/10/17 23:16:07
@@ -600,7 +600,7 @@
/* part_name: return partition device name from disk and partition number */
-static char *part_name(struct fdisk_disk *disk, unsigned int part)
+char *part_name(struct fdisk_disk *disk, unsigned int part)
{
FILE *f;
char *pname = NULL, *dname = disk->name + 5;
Index: utilities/libfdisk/fdisk.h
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/libfdisk/fdisk.h,v
retrieving revision 1.28
diff -u -r1.28 fdisk.h
--- utilities/libfdisk/fdisk.h 2001/09/10 12:39:12 1.28
+++ utilities/libfdisk/fdisk.h 2001/10/17 23:16:08
@@ -79,6 +79,8 @@
int
fdisk_fstype_of(unsigned int ptype);
+char *part_name(struct fdisk_disk *disk, unsigned int part);
+
char *
fdisk_fstype_name_of(unsigned int ptype);
Reply to: