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?
Custom Distributions – How to Create a Customized Ubuntu Server ISO
custom-distributions
Related Solutions
Have you tried Remastersys?
A small excerpt about what you can do with this tool:
Remastersys is a tool that can be used to do 2 things with an existing Klikit or Ubuntu or derivative installation.It can make a full system backup including personal data to a live cd or dvd that you can use anywhere and install. It can make a distributable copy you can share with friends. This will not have any of your personal user data in it.
Cubic (Custom Ubuntu ISO Creator) is a GUI wizard to create a customized Ubuntu Live ISO image.
Cubic permits effortless navigation through the ISO customization steps and features an integrated virtual command line environment to customize the Linux file system. You can create new customization projects or modify existing projects. Important parameters are dynamically populated with intelligent defaults to simplify the customization process.
Installing Cubic
To install Cubic, add the PPA, and install using apt
.
sudo apt-add-repository ppa:cubic-wizard/release
sudo apt install cubic
Using Cubic
Launch Cubic from the dock or application menu.
The Start Page
On the Start Page, select a new empty directory to keep all your project files. You can have multiple customization projects, but you must pick a different directory for each project.
The Project Page
On the Project Page, select an original ISO image to customize. Information on the Project page will be automatically filled out for you. You can accept the recommended defaults. If you chose to change some of the values, the related parameters will automatically be updated as you type.
The Extract Page
The next page will display progress as the original ISO is analyzed, important files are copied, and the compressed Linux file system is extracted.
The Terminal Page
The Terminal Page automatically appears once the Linux file system has been extracted. This is a container environment in which you can make customizations using the command line. Since you are logged in as a root user, you do not need to use sudo
when typing commands. (You can safely ignore the "couldn't connect to zsys" error messages, or if you do not need zsys, you can execute apt remove zsys
to eliminate these messages).
Use command line tools to customize Ubuntu.
Note, on some Ubuntu based distributions, DNS lookups may not work, and you may not be able to use apt
due to a "Name or service not known" error. This is because the link /etc/resolv.conf
points to /run/systemd/resolve/stub-resolv.conf
. But stub-resolv.conf
does not exist.
To resolve this, execute the following command in the Cubic Terminal...
ln -sr /run/systemd/resolve/resolv.conf /run/systemd/resolve/stub-resolv.conf
Or try this approach, proposed by Ark74.
mkdir /run/systemd/resolve/
echo "nameserver 127.0.1.1
search network" | tee /run/systemd/resolve/resolv.conf
ln -sr /run/systemd/resolve/resolv.conf /run/systemd/resolve/stub-resolv.conf
To verify DNS resolution works, execute...
cat /etc/resolv.conf
ping google.com
Here are a few examples of customizing Ubuntu using the command line...
You may use the nano
text editor to edit files. For example, to edit the sources repositories list, type
nano /etc/apt/sources.list
To exit nano
, type Ctrl-X and you will be prompted to save the file. To not save the file, type N. To save the file, type Y, and press Enter to accept the default file name.
After editing the sources list, remember to update the list of available packages using:
apt update
You can use apt
to update sources and install applications. For example, you can install other Linux kernels.
apt install linux-headers-5.8.0-44-generic linux-image-5.8.0-44-generic
You may click the Back button to change some of your the project parameters you entered on the Project Page. If you quit the application, you can always open your project and continue making customizations on the Terminal Page, where you left off.
The Copy Files Page
You can copy files or directories into the current directory by dragging them onto the terminal window, by using the copy button in the header bar, or by using the right-click context menu.
The right-click context menu also allows you to copy-and-paste text in the terminal, or you can use Ctrl-Shift-C and Ctrl-Shift-V shortcuts.
Here is an example to copy additional wallpapers into your customized environment.
cd /usr/share/backgrounds
Then simply drag the new wallpapers onto the Cubic window, and click the Copy button on the Copy Page that appears.
Note that the Cubic GUI currently does not support copying files over the network, but you can use the rcp
or scp
commands from within the terminal environment.
Tip: Be sure to list the new wallpapers in an XML file under /usr/share/gnome-background-properties
, so they will be listed in the Change Background dialog when the user right-clicks on his/her desktop.
When you are done making your changes, click the Next button. Remember, you can always come back to the terminal environment for this project to make additional customizations in the future.
The Prepare Page
On the Prepare Page, Cubic will automatically identify kernels available to boot the custom ISO, and Cubic will create manifest files based on the installed packages. You do not need to do anything on this page.
The Packages Page
The Packages Page automatically appears, listing of all packages installed in your customized Linux system. The packages with a check mark next to them are flagged to be automatically removed by the "Ubiquity live CD installer". If you do not want Ubiquity to remove a package after installing your customized Linux system, simply un-check that package.
If your installer supports both Typical and Minimal installs, you will see two columns with check boxes. When you select a package to be removed for a Typical install, the package will automatically be removed for a Minimal install as well.
If your installer does not support Minimal installs, you will only see one column with check boxes for a Typical install.
Be careful when selecting packages for removal, because additional dependent packages may also be removed, and these will not be indicated in the list. Here is an example where gparted
was selected to not be removed (i.e. un-checked). However, gparted-common
is still flagged to be removed. When the installer encounters this, it will remove gparted-common
and gparted
will automatically be removed because it depends on gparted-common
.
Therefore, it's a good idea to just accept the recommended defaults on this page, unless you know what you are doing.
The Options Page
On the next page, you will see three tabs in the header bar:
- Kernel Tab
- Preseed Tab
- Boot Tab
The Options Page - Kernel Tab
The Kernel Tab lists all the kernels available to boot your new Live ISO, including kernels you have installed to your customized Linux system. You can chose to use one of these as the boot kernel for your new Live ISO. It's a good idea to accept the recommended default on this tab.
(Note: On this page you are not selecting the kernel that is used inside your customized Linux system, nor are you selecting the default kernel that will be installed onto a computer by your new Live ISO; instead, this is the kernel that is used to boostrap your new Live ISO).
The ISO Boot files (listed on the Boot Tab) will automatically be updated with your selected kernel files (vmlinuz and initrd). Cubic will also automatically correct file extension (initrd.lz, initrd.gz, etc.) even if the original ISO had the wrong file extension.
The Options Page - Preseed Tab
The Preseed Tab allows you to optionally create, edit, or delete Preseed files.
The Options Page - Boot Tab
The Boot Tab allows you to optionally update the boot parameters used while booting the customized Live ISO. These files are automatically updated to reflect the correct kernel files (vmlinuz and initrd). It's a good idea to accept the recommended defaults on this tab.
(Note: On this page you are not updating the Grub boot loader files that are used to boot your customized Linux system; instead, this is the Grub boot loader that is used to boostrap your new Live ISO).
The Compression Page
The Compression Page allows you to select the algorithm used to compress your customized Linux file system (lz4, lzo, gzip, zstd, lzma, or xz).
Algorithms listed towards the top left of the chart are faster, use less CPU resources, but produce larger files. Algorithms listed towards the bottom right of the chart are slower, use more CPU resources, but produce smaller files.
For most users, it is OK to proceed with the default algorithm, gzip.
The Generate Page
Click the Next button, and Cubic will automatically package your customizations into a new *.iso
disk image. The progress and results of each step are shown. Note that the "Compress the customized Linux filesystem" step may take a long time, depending on the selected algorithm and your system hardware. (You may want to open System Monitor to track your CPU utilization during this step).
At any time during this process, you can click the Back button to immediately go back to the Terminal Page, and make additional changes or customizations you may have overlooked. There is no practical size limit for the generated ISO.
After generating the new customized disk image, Cubic will also generate an MD5 checksum file that can be used to verify your customized *.iso
file.
The Finish Page
Click the Finish button, and information about the customized disk image will be displayed.
If you want to delete all working project files (in order to save disk space) check the "Delete all project files..." checkbox. Otherwise, you will be able to continue customizing this project in the future.
Click the Close button to exit Cubic.
Finally, use your favorite disk burning program, such as Brasero, to burn a copy of the *.iso
image to CD or DVD, or use a USB image writing tool, such as Startup Disk Creator or mkusb, to create a bootable USB.
Using the MD5 Checksum
If you are distributing your customized Linux, the corresponding MD5 checksum file can be used to verify that it has not been altered. For example, ensure both files are in the same directory, and type the following…
md5sum --check ubuntu-20.04.0-2021.03.04-desktop-amd64.md5
ubuntu-20.04.0-2021.03.04-desktop-amd64.iso: OK
Making Changes
The Project Page for an Existing Project
Launch Cubic, and select an existing project directory on the Start Page. Click the Next button, and you see your Cubic project information. Simply click the Customize button in the header bar to go directly to the Terminal page to continue customizing your project to make additional changes.
The Delete Project Page
You can also delete an existing project by clicking the Delete button in the header bar. All project working files will be deleted and you will not be able to customize or make additional changes to this project. If you do not want the generated *.iso
image and *.md5
files to be deleted uncheck the "Delete..." check box at the bottom of the page.
Best Answer
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:
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:
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-betweendefault install
andlabel 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):
myownoption
is just a label you can use to identify your option.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)
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:
** 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: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:
myownoption
to what you used.Now for changing settings. Using
debconf-get-selections
from thedebconf-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:
An example for openssh:
You can add these options to
custom-iso/preseed/ubuntu-myownoption.seed
.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:And this will update our project with the new packages:
Create the ISO
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
probably needs to be like this:
Ditch the tasksel line of you do not want a LAMP server (ie. Apache, Mysql, Php)