Create Your Own Linux Distro with Ubuntu Imager

Ever wanted to create your own Linux distro but were at a loss where to start? It is easier than you think. Distroshare Ubuntu Imager creates an installable Live ISO from an installed Ubuntu or derivative distribution.

Why would you make your own distro?

With so many Ubuntu derivatives available that cater to almost everyone’s needs, the above question sounds reasonable. Yet you might not be happy with what is on offer. You might have installed and configured your environment to such an extent, creating custom tools and setups, that it would be difficult to recreate. Or you just want to share this special environment with others, such as if you set up a work environment with similarly configured machines. You might have a specific combination of hardware that makes it challenging to make Ubuntu run correctly. You might just want to show off your custom system; after all, Linux is all about variety.

Distroshare.com, the creators of the Distroshare Ubuntu Imager, is a website that was founded to allow you to share your custom Ubuntu distribution with others, and they make the process incredibly simple.

The script

There used to be a tool called remastersys that allowed for easy Live CD creation from your installed system. However, the development of the project has been discontinued for some very unfortunate reasons. Even if you still have a copy, it might not be working as expected for newer Ubuntu systems. While Ubuntu has a very detailed tutorial on how to create live CDs manually, the process is long, elaborate and difficult.

Fortunately, the people at distroshare.com were kind enough to automate the process, putting it all into a bash script that does the bulk of the work. With minimal configuration, anyone would be able to create a live environment with as little effort as editing a text file and running a shell script.

The Distroshare Ubuntu Imager script is hosted on GitHub. To get it, type

Configuration

Once you have the zip unpacked, you can change to the script’s directory

cd/extract/path/distroshare-ubuntu-imager-master

For example:

cd/home/maketecheasier/distroshare-ubuntu-imager-master

Of the several files found here, the interesting ones are “distroshare-ubuntu-imager.config” and “distroshare-ubuntu-imager.sh.”

You will start by editing the former.

nano ./distroshare-ubuntu-imager.config

The contents of the file are mostly self-explanatory, and the options are well-commented.

The first line determines whether the GTK or Qt fronted should be installed for Ubiquity – the installer that allows you to install your live system later.

GTK="YES"

Change this line for Qt (If you run KDE) to GTK="NO" or even GTK="LEAVEMEALONEWITHTHAT"'

The next line will be the working directory. This is where your ISO will be placed. In this case it is just the user’s home directory. You can change it to anything you like (but make sure it is an existing directory on your system).

WORK="/home/maketecheasier"

The patch line can be ignored (or rather left as is), but the Display manager must be taken care of. The default setting is for LightDM which is the display manager used by vanilla Ubuntu.

DM="LIGHTDM"

If you run any derivative, you should change the line according to your setup. (As a hint, Gnome uses “GDM” and KDE uses “KDM”, so most derivatives based on these systems will likely use these display managers. A popular derivative system, LinuxMint uses “MDM.”)

If “EFI Support” is needed, change the below line to “YES”:

EFI="NO"

By default, the script will use whatever kernel the system is running on. By modifying the

KERNEL_VERSION=$(uname -r)

line to

KERNEL_VERSION="your-custom-kernel-version-here"

you can specify which kernel to use, be it an older or newer one or even one you’ve compiled yourself. Only change this if you know what you are doing. Leaving it at the default setting should be fine for most.

You can specify kernel parameters for the LiveCD

KERNEL_PARAMS=""

or for the system you’d install from the live CD.

UBIQUITY_KERNEL_PARAMS=""

Lastly, you can specify additional packages to be installed. It could be useful if you want to keep the live image as small as possible, but make sure plenty of additional software gets installed with it. List them with spaces between package names.

EXTRA_PKGS="ubiquity-slideshow-ubuntu"

The last line allows you to insert a URL for your own release notes, if any.

RELEASE_NOTES_URL="https://www.distroshare.com/"

Running the script

You need to run the script itself as root.

sudo ./distroshare-ubuntu-imager.sh

The script will do a number of things. After reading the configuration details you’ve just specified, it will create the necessary directories, install some additional software it needs (specifically xorriso squashfs-tools dmraid lvm2 and samba-common), determine which version of GRUB needs to be installed and take care of the installation, and install Ubiquity (and its dependencies). After that, it cleans up temporary files, removes ubiquity from your system, compresses the new file system it has just created with squashfs, creates an md5 checksum and grub entries for the new system, and puts it all into an ISO file.

By the time the script finishes (it will take a while), you should have a nice working ISO live image. It could not be easier.

Booting the ISO

The ISO image created can be burned onto a CD, mounted to a virtual machine, or run directly from grub as shown here. You can also copy it to a USB drive with dd.

ddif=live-cd.iso of=/dev/sdX bs=1M

where /dev/sdX is the path to your USB drive.

Conclusion

Distroshare Ubuntu Imager is an easy-to-configure bash script that replaces the sadly missed Remastersys, allowing you to create your custom Ubuntu spins with ease. After editing the configuration file and running the scripts, make sure you show off your work on distroshare.com for everyone to see and use.

Unfortunately I’m only the messenger (I mean, I do not maintain this project, I only wrote about it), so even though I thought about it, I also realised that my programming skills are just too rusty.

The thing about remastersys is, the original developer asks some $50 to release the source code. This must turn many ppl away, for sure. (Quite understandable though, he quit with bitter feelings and he might be right to want to get something out of it).

But now that you say, it would probably not be that difficult to make a GUI for this, with something like Python+Kivi. Maybe if I’ll have A LOT of time on my hands… once. :)

Never mind, this week some developers have released the Remastersys replacement (GUI) and it also icludes more feautures. Pinguy Builder is its name just in case you wnat to write about it. Thanks for replying, regards.

Unfortunately I cannot confirm that. Theoretically it probably should, although 16.04 has had significant changes, which might as well break things. Apparently the latest version of Ubuntu imager was released a little over a year ago, with the last commit on their GitHub project dated 9 September 2015.

I guess the only way to know for sure would be to try. Just make an image and try to boot it…

Everything went well until I tried to install the ISO in a VirtutalBox VM. Message was Installer Crashed, and something about creating a Bug Report. No bug report was created that I could see or find. So this is what I did: Create the ISO based on my Desktop which was Linux Mint 17.3 Xfce. Create a VM and linked the ISO. Live install screen came up. Proceeded with the setup. Then the install copied the files. Then boom – Installer Crashed. Any ideas what I should do now?

Thanks P.S. This looks really good as I have done remastersys, Clonezilla and Mondo in the past but this method is really fast. Just need to get it to work now.

Not sure if this is because some Linux Mint specific issue. Ubuntu Imager is meant for vanilla Ubuntu flavours AFAIK (I might be wrong there, it has been a long time since I’ve use it), and Mint is known to add some of its own modifications to the Ubuntu base, although it should not change it structurally, so theoretically it should work.

17.3 is supposedly based on Ubutnu 14.l04 right? Well Ubuntu imager’s last version was released just last year, so that should be no problem at all…

What happens if you try making another image, probably with slightly different options?

It actually all worked out good for me, I used pinguy which was posted here and that worked right out of the box. The I went with Ubuntu 16.04 mini.iso and build my own system in VirtualBox, used pinguy and burned the ISO to a USB flash drive and installed the system I created on a Laptop. Ultimately that is what I was after. Thank you.

Nice one. Good to know Pinguy is still in development, and working as expected. If I’m not wrong I did eventually write an article about that here as well, but it might have only been a plan. Been a while. :)