I extremely customized Ubuntu to the core to create my own distro. But I don't know how to create an installable iso for it. Does anyone have an idea how?


Two steps:

  1. Package your changes
  2. Include your package in your iso

Designing the package

I expect your package to contain five things:

  1. New configuration files
  2. Scripted customizations to existing configuration files
  3. Scripted commands
  4. Required Dependencies
  5. Convenient Dependencies

New configuration files are easy to install as part of a package. Simply add them to your package. If you've changed a file such as /etc/sudoers or /etc/apt/sources.list, try to put your changes in /etc/sudoers.d/ or /etc/apt/sources.list.d/. Don't deploy your own version of /etc/sudoers expecting it to override the version deployed by sudo. Your package will be in conflict and fail to install.

If you really need to make changes to an existing configuration file, add it to your postinst script. Make an attempt to undo the change in the prerm script. Here are some examples:

echo "    router" >> /etc/hosts
sed 's/PasswordAuthentication yes/PasswordAuthentication no/' -i /etc/ssh/sshd_config

If you need to run any commands (such as useradd or realm) then you should also do that in postinst.

You can also add dependencies to this package. If you've made a change to /etc/ssh/sshd_config, then you probably want to depend on openssh-server which ensures that file is installed before your script works on it. You can find which packages own each file with dpkg -S /path/to/file.

You can also add dependencies on packages you know you want in your custom config. If you like chromium and know you'll want that installed everytime you use this image, then go ahead and add a dependency on chromium to avoid the need to manually apt-get later on.

Making the package

Some tools you can use to make packages include dh_make or cpack.

dh_make will make a template for you so you can add the files you like and then use dpkg-buildpackage to produce the *.deb file. Understanding all of the options is a little daunting and takes time to study and understand, but it's how native debian/ubuntu packages are produced.

cpack uses a CMakeLists.txt file to define the rules. Add files to your package with the install() command and CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA will help you define your postinst. I find cpack was easier to learn, especially for trivial packages.

Once you have a package, boot up a new Ubuntu (maybe use a chroot or vm), then test your package by installing it with dpkg -i. If your system is how you want it, then you've succeeded. Now you can take a basic ubuntu installation and customize it all by installing this single package.

ISO packaging

But I see you want to go further... You don't want to run that one command, you want to get this customization out-of-the-box. You can!

You'll need to generate the installation disc in the same way Debian or Ubuntu does it, but add you're own package to the disk and set it to auto-install.

Simple-CDD is probably the easiest tool to make a debian-based iso. I'm not sure how well it works with Ubuntu though. LiveCD customization sounds like the most likely solution there.

  • Thanks for the answer. I had never heard of simple-cdd before. But I was actually considering Distroshare or Systemback. But both of those don't really work for me. I intend to release a full distro based on ubuntu. It's not that I am lazy but I was looking for a more easy and automated way to create an iso with an installer and stuff. – AnanthaKrishna K Nov 13 '20 at 4:03
  • I think Simple-CDD or LiveCDcustomization are still the answers. – Stewart Nov 13 '20 at 7:23

I like the other answer and there is more than one way to solve this use case.

Have you checked out this: https://help.ubuntu.com/community/LiveCDCustomization ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.