I'd like to create a customized Ubuntu Server 12.04 ISO but couldn't find a clear approach on how to do it. I see that Ubuntu-builder is a very good app to create a customized Ubuntu Desktop, but what about Ubuntu Server?
Download
Download the Ubuntu server ISO from this location. You have the option to go 32-bit or 64-bit. The file name for the server edition will look similar to this:
ubuntu-13.10-server-i386.iso
ubuntu-13.10-server-amd64.iso
I will assume the 13.10 64-bit version in the following instructions, so adjust the commands to the download you did. Keep a copy of your download so you can create multiple new versions from the original download in case you need to improve your project. I will also assume we use ~/Downloads/
to do all our work.
Initial setup
This will create 2 directories "iso" and "isoNew" inside your Downloads directory, mount the ISO and copy the contents from "iso" over to "isoNew" to start a new project.
Put this in a text file, save it, make it executable and execute it:
# Ubuntu custom server
# rinzwind askubuntu.com
# topic: http://askubuntu.com/questions/409607/how-to-create-a-customized-ubuntu-server-iso/409651#409651
cd ~/Downloads/
mkdir -p iso newIso
sudo mount -o loop ./ubuntu-13.10-server-amd64.iso ./iso
sudo cp -r ./iso/* ./newIso/
sudo cp -r ./iso/.disk/ ./newIso/
sudo umount ./iso/
cd ~/Downloads/newIso/
- It will throw 1 error message:
mount: block device /discworld/Downloads/ubuntu-13.10-server-amd64.iso is write-protected, mounting read-only
Example images on how this will look like:
Executing:
Result:
Adding a Boot Menu Option
The menu options for the installer are stored in isolinux/txt.cfg
and you can create new options in-between default install
and label install
.
This will create a new option called "Install Custom Ubuntu server" and it will add a kickstart file (the kickstart file is used to alter options; explained below):
label myownoption
menu label ^Install Custom Ubuntu Server
kernel /install/vmlinuz
append file=/cdrom/preseed/ubuntu-custom.seed initrd=/install/initrd.gz quiet ks=cdrom:/preseed/ks-custom.cfg --
myownoption
is just a label you can use to identify your option.- "Install Custom Ubuntu Server" is the text that will show up in the boot menu.
- If you want to make your menu option the default one, you only need to change the
default install
todefault myownoption
.
Example:
and editing the file (I used nano but if available use gedit, vim or another editor). Here is my addition to this file where I used "lampserver" as a label and my seed will be named "lampserver" too.
Kickstart (graphically setting up a configuration file)
The Red Hat Kickstart installation method is used primarily (but not exclusively) by the Red Hat Enterprise Linux operating system to automatically perform unattended operating system installation and configuration.
Documentation on preseeding/kickstart for Ubuntu. Ubuntu has limited support for kickstart (and preseeding); one of the missing things is a graphical interface for preseeding. Kickstart does have options for this (see the images) but these do not seem to work on Ubuntu. You can do this manually though (see Preseeding below).
Installation and starting kickstart:
sudo apt-get install system-config-kickstart
ksconfig
** WARNING **
kickstart is bugged in Ubuntu 13.10 and when starting it, it errors out. Here is a fix. Put the patch in the comment into a text file, save it (I named it "patch") and commit it:
After that ksconfig
worked and it will start a configuration editor that allows for you to manipulate a lot of options.
See the Red Hat Linux 7.2: The Official Red Hat Linux Customization Guide for a description for all of the options you can set.
After you are done, save the changes to a ks.cfg
file and copy it over to the ISO we are changing:
sudo cp ks.cfg ~/Downloads/newIso/preseed/ks-custom.cfg
- If you change anything here the installer will SKIP asking for that information if it is considered valid. If you did not change an option the installer will still ask for you to answer.
- You can also download kickstart files and save those in as
ks-custom.cfg
in~/Downloads/newIso/preseed/
.
Example where I inserted my credentials. I started it with sudo ksconfig
from commandline.
And saving it to the project:
Preseeding (manually setting up a configuration file)
Preseeding provides a way to set answers to questions asked during the installation process, without having to manually enter the answers while the installation is running. This makes it possible to fully automate most types of installation and even offers some features not available during normal installations.
Copy the preseed for the normal install over to your own label:
sudo cp newIso/preseed/ubuntu-server.seed newIso/preseed/ubuntu-myownoption.seed
- change the
myownoption
to what you used.
Now for changing settings. Using debconf-get-selections
from the debconf-utils
you can investigate what parameters you can use with specific software.
Example setting this up:
And adding lamp-server to be installed with tasksel:
If you want to add packages "openssh" and "build-essential" you can include this in the seed file:
d-i pkgsel/include string openssh-server build-essential
An example for openssh:
debconf-get-selections | grep openssh
openssh-server ssh/vulnerable_host_keys note
openssh-server ssh/use_old_init_script boolean true
openssh-server ssh/encrypted_host_key_but_no_keygen note
openssh-server ssh/disable_cr_auth boolean falseYou can add these options to
custom-iso/preseed/ubuntu-myownoption.seed
.- Explanation/examples using debconf settings.
- An example preseed file
- Examples regarding: Localization, Network configuration, Network console, Clock and time, partitioning
At the end of the preseed file you can add packages (random examples) like this:
%packages
openssh-server
mysql-server
apache2
Offline installation
In case you add packages and those are NOT in the ISO the installer will download these from the repository. If you do not have an active internet connection this will be problematic so you will need to add all those packages (and dependencies) to your project and burn them to a DVD. Luckily the normal server ISO has a lot of room but beware: CD and/or DVDs do have a limited size.
Download all the DEB packages you need and store them in ~/Downloads/
. These 2 directories are needed on the new ISO:
mkdir -p ~/Downloads/newIso/dists/stable/extras/binary-i386
mkdir -p ~/Downloads/newIso/pool/extras/
sudo cp ~/Downloads/*.deb newIso/pool/extras/
And this will update our project with the new packages:
cd ~/Downloads/newIso
sudo apt-ftparchive packages ./pool/extras/ > dists/stable/extras/binary-i386/Packages
sudo gzip -c ./dists/stable/extras/binary-i386/Packages | tee ./dists/stable/extras/binary-i386/Packages.gz > /dev/null
cd ~/Downloads/
Create the ISO
cd ~/Downloads/
sudo md5sum `find ! -name “md5sum.txt” ! -path “./isolinux/*” -follow -type f` > md5sum.txt
sudo mkisofs -J -l -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -z -iso-level 4 -c isolinux/isolinux.cat -o ./ubuntu-13.10-myowninstall-amd64.iso -joliet-long newIso/
- the 2nd line creates a new checksum and is only needed when adding packages.
- the 3rd makes an ISO from your project that you can burn to a DVD.
Result:
And now you can try the it out by actually burning and installing it. I would advise to use as virtual machine since it will be quicker for testing the initial created ISO (otherwise you keep rebooting).
And after installing VirtualBox I get the following menu:
Bug hunting
Ran into 1 problems while installing: the default was not selected.
Shadin. From your seed file in comment
### Package Selection
tasksel tasksel/first multiselect Custom-Ubuntu-Server
d-i pkgsel/include string openssh-server build-essential
%packages openssh-server postgresql-9.1 postgresql-client-9.1 postgresql-contrib-9.1 libpq-dev postgresql-server-dev-9.1 pgadmin3
probably needs to be like this:
### Package Selection
tasksel tasksel/first multiselect lamp-server
d-i pkgsel/include string openssh-server build-essential postgresql-9.1 postgresql-client-9.1 postgresql-contrib-9.1 libpq-dev postgresql-server-dev-9.1 pgadmin3
Ditch the tasksel line of you do not want a LAMP server (ie. Apache, Mysql, Php)
No comments:
Post a Comment