以下内容将创建修改后的启动映像。将其刻录到CD,或将ISO插入VM以对其进行测试。您将需要cpio
和genisoimage
(这是软件包和可执行文件的名称)。
以下是Makefile的形式,但可以交互输入。${IN_ISO}
指的是原始ISO映像(我使用的是该-alternative
版本,建议您也这样做),并${OUT_ISO}
指向所需的ISO名称。
# 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
您需要一些其他文件:
isolinux.cfg
配置引导加载程序。您只希望它启动,然后自动完成安装过程。它看起来应该像这样:
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
这就是我们在实际配置安装之前所需的所有准备工作。下载前面的示例,并将其命名为preseed.cfg。仔细阅读并编辑任何内容。重要选项是:
# 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.
但我建议您不要以上述示例为例,而是下载Ubuntu的示例并使用进行配置late_command
,您可以从shell进行任何操作,包括下载并执行安装和配置自定义软件的脚本。例如,将此用作late_command
:
d-i preseed/late_command string in-target sh -c 'wget https://example.com/my/install.sh && sh install.sh'
或者,您可以放置install.sh
在上面的initrd中,然后直接执行它。其内容可能如下所示:
#!/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
这实际上取决于您专有的驱动程序安装例程的工作方式。