The following creates a modified boot image. Burn it to a CD, or insert the ISO into a VM to test it. You'll need cpio
and genisoimage
(that's the names of the packages and executables).
The following is in the form of a Makefile, but can be entered interactively. ${IN_ISO}
refers to the original ISO image (I used the -alternative
version, and I'd suggest you do the same), ${OUT_ISO}
to the desired ISO name.
# Extract the ISO image to mount/ and copy it to cdroot/
cdroot:
mkdir -p mount
sudo mount -o loop ${IN_ISO} mount
mkdir cdroot
cd cdroot && tar cf - ../mount --transform 's,^mount/,,' | tar xf -
sudo umount mount && rm -r mount
chmod -R a+rw cdroot
# Copy new files to the disk. Content of those files is posted below
prepare: cdroot
cp isolinux.cfg cdroot/isolinux/isolinux.cfg
test -e ./initrd.orig.gz || cp cdroot/install/initrd.gz ./initrd.orig.gz
mkdir -p initrd
cd initrd && gunzip <../initrd.orig.gz | sudo cpio -i && cd ..
cp preseed.cfg initrd/preseed.cfg
cd initrd && find . | cpio -o --format=newc | gzip -9 > ../cdroot/install/initrd.gz && cd ..
sudo rm -rf initrd
# Create the ISO image. Make sure to use extensions for lower-case filenames
iso: cdroot prepare
genisoimage -o ${OUT_ISO} \
-force-rr -J \
-b isolinux/isolinux.bin -c isolinux/boot.cat \
-no-emul-boot -boot-load-size 4 -boot-info-table \
cdroot
You need some additional files:
isolinux.cfg
configures the boot loader. You want it to just boot, and automatically go through the installation process. It should look like this:
default install
label install
menu label ^Install my custom Ubuntu
kernel /install/vmlinuz
append auto initrd=/install/initrd.gz --
# Leave 2 seconds to abort or debug
prompt 1
timeout 20
That's all the preparations we need before actually configuring the installation. Download the preseed example and name it preseed.cfg. Go through it and edit whatever you want. Important options are:
# Locale
d-i debian-installer/locale string en_US
d-i time/zone string US/Eastern
# Partitioning. The following settings WILL OVERWRITE ANYTHING
# Don't insert the CD into your boss' computer ...
d-i partman-auto/method string regular
d-i partman/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
# To create a normal user account.
d-i passwd/user-fullname string Ubuntu User
d-i passwd/username string ubuntu
d-i passwd/user-password password insecure
d-i passwd/user-password-again password insecure
d-i user-setup/allow-password-weak boolean true
# Package selection. Don't include ubuntu-desktop to significantly reduce the content
tasksel tasksel/first multiselect standard
#d-i preseed/early_command string driver installation commands (stuff needed to boot)
#d-i preseed/late_command string driver installation commands, custom software, etc.
But I'd suggest you don't use the above as an example, but download Ubuntu's example and configure it to your needs with late_command
, you can do anything from shell, including downloading and executing a script that installs and configures your custom software. For example, use this as late_command
:
d-i preseed/late_command string in-target sh -c 'wget https://example.com/my/install.sh && sh install.sh'
Alternatively, you can place install.sh
in the initrd above and execute it directly. Its content could look like this:
#!/bin/sh
aptitude install -y x11-apps any-package-you-want-installed
wget http://proprietary.com/drivers/for/ubuntu.tar.gz -O- | tar xf - && sh drivers/instal.sh
It really depends on how your proprietary driver installation routine works.