A couple of small udebs
Hi guys,
My name is Michael Peek, and I've never contributed a darned thing...
But I'd like to change that. I've written a couple of small udebs that
I find useful. I'm wondering if they would be useful to anyone else.
If you're like me, and I know I am, then you work someplace where you
have no access to the DHCP server, so allowing the installer to aquire
it's networking information from the DHCP server breaks things. You
also have a small multitude of machines with varying hard drive
configurations. And, last but not least, you're lazy and prone to human
error. You don't want to have to type in networking and partitioning
information manually for each machine you install, nor do you want to
have to burn a separate installer CD for each machine. What you really
want, is to be able to put all the information for all your machines on
one installer CD and have the installer figure it out for itself.
And, if you're even more like me, then... well... You're freakin' me
out, man. Stop it.
I've written a package I've called auto-config that produces three
udebs, although only two will probably apply to anything other than sarge:
cfg-netcfg_0.0-5_all.udeb (1822 bytes)
From debian/cfg-netcfg.README:
This module is designed to allow the installer to preseed network
configuration values for a multitude of machines.
To use:
1) Preseed cfg-netcfg/preseed-dir.
Set cfg-netcfg/preseed-dir to a directory on the install media where
cfg-netcfg is to check for network configuration preseed files. For
instance,
if you are using an install CD, and you have created a directory on
your CD
called /preseed/netcfg/, then set your preseed value thusly:
d-i cfg-netcfg/preseed-dir string /cdrom/preseed/netcfg
2) Create the netcfg preseed directory and populate with preseed files.
For each machine for which you want to preseed network configuration
settings,
create a file in your cfg-netcfg directory using the ethernet hardware
address
as the filename, but with ':'s changed to '-'s.
For instance: If given an unknown machine with a blank hard drive...
2a) Boot the machine w/ the Debian installer.
2b) When prompted for network configuration (after the installer has
detected the ethernet card and loaded modules), switch to the 2nd
virtual terminal and type "ifconfig -a". You will see something
like
this (numbers have been changed to protect the guilty):
eth0 Link encap:Ethernet HWaddr 0A:12:F3:3A:13:E9
inet addr:xx.xx.xx.xx Bcast:xx.xx.xx.255
Mask:255.255.255.0
inet6 addr: fe70::212:3fef:fe3b:129e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:433469293 errors:0 dropped:0 overruns:0 frame:0
TX packets:552342645 errors:0 dropped:0 overruns:0
carrier:0
collisions:0 txqueuelen:1000
RX bytes:4186685499 (3.8 GiB) TX bytes:2485150677
(2.3 GiB)
Base address:0xdcc0 Memory:dfee0000-dff00000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:106281703 errors:0 dropped:0 overruns:0 frame:0
TX packets:106281703 errors:0 dropped:0 overruns:0
carrier:0
collisions:0 txqueuelen:0
RX bytes:4107947197 (3.8 GiB) TX bytes:4107947197
(3.8 GiB)
sit0 Link encap:IPv6-in-IPv4
NOARP MTU:1480 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
2c) Locate the hardware address for your ethernet card. In the above
example above the hardware address for the ethernet card is
0A:12:F3:3A:13:E9.
2d) Permute the hardware address by substituting '-'s for ':'s:
0A-12-F3-3A-13-E9.
2e) Create a file by this permuted name under the cfg-netcfg directory
containing your network preseed values. You can leave out the
preseed
value for netcfg/choose_interface, as cfg-netcfg will fill this
value in
for you automatically. An exmaple file might look like this:
d-i netcfg/disable_dhcp boolean true
d-i netcfg/get_ipaddress string xx.xx.xx.xx
d-i netcfg/get_netmask string xx.xx.xx.0
d-i netcfg/get_gateway string xx.xx.xx.1
d-i netcfg/get_nameservers string xx.xx.xx.xx xx.xx.xx.xx
d-i netcfg/confirm_static boolean true
d-i netcfg/get_hostname string myhost
d-i netcfg/get_domain string my.domain.net
d-i netcfg/wireless_wep string
2f) Or, instead of creating a file, create a directory, and populate
it with
as many files as you want. If the directory name matches, then
all the
files within will be read.
3) Activate the cfg-netcfg module.
On your installation media, edit (or create) the .disk/udeb_include
file to
include a line that reads "cfg-netcfg".
If using the Debain/Sarge installer, you may also want to include the
cfg-netcfg-check module as well, to work around a bug in the Debian/Sarge
installer where static network configurations were given the wrong
settings.
4) Sit back and enjoy.
This package prints nothing to the screen, but does log it's output to
syslog:
Aug 7 16:23:44 main-menu[695]: DEBUG: Menu item 'cfg-netcfg' selected
Aug 7 16:23:44 main-menu[695]: DEBUG: configure cfg-netcfg, status: 2
Aug 7 16:23:44 main-menu[695]: DEBUG: configure
ethernet-card-detection, status: 0
Aug 7 16:23:44 main-menu[695]: DEBUG: virtual package
ethernet-card-detection
Aug 7 16:23:44 cfg-netcfg: Searching for network card(s)...
Aug 7 16:23:44 cfg-netcfg: Auto-NetCfg Dir: /cdrom/preseed/netcfg
Aug 7 16:23:44 cfg-netcfg: Found device: eth0 (HWaddr: 00:12:3F:3F:48:3E)
Aug 7 16:23:44 cfg-netcfg: Searching for File or Dir:
/cdrom/preseed/netcfg/00-12-3F-3F-48-3E
Aug 7 16:23:45 cfg-netcfg: Found file
Aug 7 16:23:45 cfg-netcfg: successfully loaded preseed file from
/cdrom/preseed/netcfg/00-12-3F-3F-48-3E
cfg-partman_0.0-5_all.udeb (2200 bytes)
From cfg-partman.README:
This module is designed to allow the installer to preseed hard drive
configuration values for a multitude of machines.
To use:
1) Preseed cfg-partman/preseed-dir.
Set cfg-partman/preseed-dir to a directory on the install media where
cfg-partman is to check for partitioning configuration preseed files. For
instance, if you are using an install CD, and you have created a
directory on
your CD called /preseed/partman/, then set your preseed value thusly:
d-i cfg-partman/preseed-dir string /cdrom/preseed/partman
2) Create the partman preseed directory and populate with preseed files.
For each machine for which you want to preseed network configuration
settings,
create a file in your cfg-partman directory for that machine. You may
use a
permutation of the ethernet hardware address (change ':'s to '-'s, see
cfg-netcfg.README for details), IP address, hostname.domainname, or just
hostname, or the size of the drives.
For instance, if you have a machine with the following attributes:
Eth0 HWAddr: 0A:12:F3:3A:13:E9
IP address: 12.34.56.78
Hostname: myhost
Hostname+Domain: myhost.my.domain
Hard drive(s): disk0 = 80GB, disk1 = 160GB
Then you may create a file using any of the following file names:
0A-12-F3-3A-13-E9
12.34.56.78
myhost
myhost.my.domain
disk0-80000.disk1-160000
Each of these names will be considered valid for the example machine given
above. Names are considered according to the following order:
1) Hardware address
2) IP address
3) Host name
4) Host+Domain name
5) Number of disk (starting with 0) and size of (in MB) of disks
(optionally a '.' and another disk/size combo).
Once a matching file is found no further matching is attempted.
Inside this file, preseed your drive configuration. As an example:
d-i partman-auto/disk string /dev/discs/disc0/disc
d-i partman-auto/expert_recipe string root-swap :: 40000
10000 40000 ext3 $primary{ } $bootable{ } method{ format } format{ }
use_filesystem{ } filesystem{ ext3 } mountpoint{ / } . 500 10000
1000000000 ext3 method{ format } format{ } use_filesystem{ }
filesystem{ ext3 } mountpoint{ /export/home/a } . 64 512 300%
linux-swap method{ swap } format{ } .
d-i partman/confirm_write_new_label boolean true
d-i partman/choose_partition select Finish partitioning
and write changes to disk
d-i partman/confirm boolean true
NOTE: You may also create default files:
disk0-generic
disk0-generic.disk1-generic
disk0-generic.disk1-generic.disk2-generic
Etc., etc. If no other preseed files match the install machine, one
of these
will be used instead.
If no matching files are found then no preseeding is done, meaning
that you
will be presented with a chance to manually partition your disks.
3) Activate the cfg-partman module.
On your installation media, edit (or create) the .disk/udeb_include
file to
include a line that reads "cfg-partman".
4) Sit back and enjoy.
This package prints nothing to the screen, but does log it's output to
syslog:
Aug 7 16:23:57 main-menu[695]: DEBUG: Menu item 'cfg-partman' selected
Aug 7 16:23:57 main-menu[695]: DEBUG: configure cfg-partman, status: 2
Aug 7 16:23:57 main-menu[695]: DEBUG: configure harddrive-detection,
status: 0
Aug 7 16:23:57 main-menu[695]: DEBUG: virtual package harddrive-detection
Aug 7 16:23:57 cfg-partman: Searching for network card(s)...
Aug 7 16:23:57 cfg-partman: Auto-Partman Dir: /cdrom/preseed/partman
Aug 7 16:23:57 cfg-partman: Found device: eth0 (HWaddr:
00:12:3F:3F:48:3E)
Aug 7 16:23:57 cfg-partman: Searching for File or Dir:
/cdrom/preseed/partman/00-12-3F-3F-48-3E
Aug 7 16:23:59 cfg-partman: No such file or directory found
Aug 7 16:23:59 cfg-partman: Searching for File or Dir:
/cdrom/preseed/partman/<xx.xx.xx.xx>
Aug 7 16:23:59 cfg-partman: No such file or directory found
Aug 7 16:23:59 cfg-partman: Searching for File or Dir:
/cdrom/preseed/partman/<hostname>.<domainname>
Aug 7 16:23:59 cfg-partman: No such file or directory found
Aug 7 16:23:59 cfg-partman: Searching for File or Dir:
/cdrom/preseed/partman/<hostname>
Aug 7 16:23:59 cfg-partman: No such file or directory found
Aug 7 16:23:59 cfg-partman: Searching for hard drives...
Aug 7 16:23:59 cfg-partman: fdisk
Aug 7 16:23:59 cfg-partman: | |
Aug 7 16:23:59 cfg-partman: | | The number of cylinders for this disk
is set to 19452.
Aug 7 16:23:59 cfg-partman: | | There is nothing wrong with that, but
this is larger than 1024,
Aug 7 16:23:59 cfg-partman: | | and could in certain setups cause
problems with:
Aug 7 16:23:59 cfg-partman: | | 1) software that runs at boot time
(e.g., old versions of LILO)
Aug 7 16:23:59 cfg-partman: | | 2) booting and partitioning software
from other OSs
Aug 7 16:23:59 cfg-partman: | | (e.g., DOS FDISK, OS/2 FDISK)
Aug 7 16:23:59 cfg-partman: | |
Aug 7 16:23:59 cfg-partman: | | Command (m for help):
Aug 7 16:23:59 cfg-partman: | | Disk /dev/discs/disc0/disc: 160.0 GB,
160000000000 bytes
Aug 7 16:23:59 cfg-partman: | | 255 heads, 63 sectors/track, 19452
cylinders
Aug 7 16:23:59 cfg-partman: | | Units = cylinders of 16065 * 512 =
8225280 bytes
Aug 7 16:23:59 cfg-partman: | |
Aug 7 16:23:59 cfg-partman: | | Device Boot
Start End Blocks Id System
Aug 7 16:23:59 cfg-partman: | | /dev/discs/disc0/part1 *
1 4863 39062016 83 Linux
Aug 7 16:23:59 cfg-partman: | | /dev/discs/disc0/part2
4864 19452 117186142+ 5 Extended
Aug 7 16:23:59 cfg-partman: | | /dev/discs/disc0/part5
4864 19122 114535386 83 Linux
Aug 7 16:23:59 cfg-partman: | | /dev/discs/disc0/part6
19123 19452 2650693+ 82 Linux swap / Solaris
Aug 7 16:23:59 cfg-partman: | |
Aug 7 16:23:59 cfg-partman: | | Command (m for help):
Aug 7 16:23:59 cfg-partman: Found disk: disc0, capacity: 160000 MB
Aug 7 16:23:59 cfg-partman: Searching for File or Dir:
/cdrom/preseed/partman/disc0-160000
Aug 7 16:23:59 cfg-partman: No such file or directory found
Aug 7 16:23:59 cfg-partman: Searching for File or Dir:
/cdrom/preseed/partman/disc0-generic
Aug 7 16:23:59 cfg-partman: Found file
Aug 7 16:24:00 cfg-partman: successfully loaded preseed file from
/cdrom/preseed/partman/disc0-generic
cfg-netcfg-check_0.0-5_all.udeb (3018 bytes)
From cfg-netcfg-check.README:
This module is designed to compensate for a bug in the Debian/Sarge
installer
that causes preseeded values for static network configurations to be
misconfigured. This module works with the cfg-netcfg module to check
and, if
necessary, fix the network settings netcfg has set up. Specifically, when
using static network configutations, the Sarge installer will
misconfigure DNS
servers, but this module checks more than just the DNS server settings.
This last one is the one that likely will not apply to etch, since I
think this bug has been fixed.
Obviously, the first two packages could be used to preseed much more
than just network and partitioning. They could be used to preseed --
well -- probably almost anything and any installer package that hasn't
actually been run yet. ...Maybe. I haven't tested that idea
thoroughly, but they seem to work for my needs.
If anyone thinks this sort of thing might be useful, let me know. I'm
not a developer, but I thought I might be able to hand this over to
someone who knows more than I.
Michael Peek
Reply to: