How to use Cubic to create a custom Ubuntu live CD image?

Solution 1:

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 Cubic Start Page

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 Cubic Project Page

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 Cubic Extract Page

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.

The Cubic Terminal Page

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.

The Cubic Terminal Page with Nano

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 Cubic Terminal Page with Example Commands

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.

The Cubic Terminal Copy Files Page

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.

The Cubic Terminal Listing Copied files

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 Cubic Prepare 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 Cubic Packages Page

The Options Page

On the next page, you will see three tabs in the header bar:

  1. Kernel Tab
  2. Preseed Tab
  3. 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 Cubic Options Page Kernel Tab

The Options Page - Preseed Tab

The Preseed Tab allows you to optionally create, edit, or delete Preseed files.

The Cubic Options Page Preseed Tab

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 Cubic Options Page Boot Tab

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 Cubic Compression Page

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 Cubic Generate Page

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.

The Cubic Finish Page

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 Cubic Project Page Showing an Existing Project

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.

The Cubic Delete Project Page

Solution 2:

Installation:

  1. sudo apt-add-repository ppa:cubic-wizard/release
  2. sudo apt-get update
  3. sudo apt-get install cubic

Creating an ISO image:

enter image description here

enter image description here

enter image description here

enter image description here

Solution 3:

Just adding to the great answer in the top.

In order for resolv.conf to work for me (at the time of writting) on 17.10 and 18.04 I'm using the following:

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

Hope it helps others.