Can I build a Ubuntu ISO from a manifest?

This answer talks about the ISO manifests - an example is here..

Is it possible to build an ISO from a manifest file, or is the manifest file just dpkg --get-selections put into a text file?

Related, sorta:

  • How do I make my own customized Ubuntu version?

  • How to customize the Ubuntu Live CD?


Solution 1:

The filesystem.manifest is generated with the command:

dpkg-query -W --showformat='${Package} ${Version}\n' > casper/filesystem.manifest

The syntax is thus package_name version, Example :

 xserver-xorg-video-nouveau  1:0.0.16+git20110411+8378443-1

The format of dpkg --get-selections is slightly different, package_name install

Example

xserver-xorg-video-nouveau  install 

So you can use the file, in probably more then one way,

apt-get install -y $(awk '{print $1}' filesystem.manifest)

To be honest, after making a few custom iso over the years, there is a learning curve to how it works. Once you understand a few things, it is not too hard, it is just the requite knowledge is moderately large and there is no single, up to date, source of information.

You use 2 build directories

~/custom - build directory for the iso
~/rootfs - build directory for the root file system.

custom - this directory contains all the files that will go onto the final iso. It contains the root file system, a kernel, an initramfs, and isolinux.

rootfs - this directory contains the live CD file system and you compress this directory (using mksquashfs) and include it on the CD. You either build this with debootstrap (live D from scratch) or extract the file system from the ubuntu-desktop.iso (customize a live CD). See the ubuntu wiki links below for details.

key points

1) Understand mksquashfs - you use mksquashfs to compress the root file system to casper/filesystem.squashfs

sudo mksquashfs /home/bodhi/rootfs custom/casper/filesystem.squashfs

2) Understand isolinux - this makes the iso bootable, as well as your CD (boot) menu. See Arch Linux Wiki syslinux.

You can use grub2 as an alternate to isolinux, but then you will need to understand how grub2 works ;) . Most live CD are still using isolinux.

3) How to make an initramfs. The initramfs is a second file system , used to boot. Often when you are having a problem (custom boot image not working, kernel modules not loading), and you can not understand why looking at your root file system, the answer is very likely in the initramfs.

#extract to a working_directory , I use ~/initrd
cd ~/initrd
lzma -dc -S .lz ../initrd.lz | cpio -imvd --no-absolute-filenames

# Make your edits / adjustments
# Package
cd ~/initrd
find . | cpio --quiet --dereference -o -H newc | lzma -7 > ../custom.initrd.lz

You then move your new initrd.lz to your custom build directory, custom/casper/initrd.lz

4) casper. Casper, and the casper scripts are located in 3 locations,and all 3 can play a role. They are all bash scripts, and at some point you will almost certainly want to look through them.

A. host - /usr/share/initramfs-tools/scripts/casper

B. root file system - custom/usr/share/initramfs-tools/scripts/casper

C. in the initramfs - See the /scripts directory.

See Ubuntu man casper

5) You make customizations to the user interface / applications in /usr/share, /usr/share/gnome* for example, exact locations vary with release, /usr/share/gnome-background-properties/ubuntu-wallpapers.xml is a classic and fairly standard across versions.

6) If you can not make customizations in /usr/share/, use /etc/skel , here /etc/skel/.bashrc is a classic, that file gets copied to ~/.bashrc . You can put various confg files there, for firefox or gnome or what not, but /usr/share is better if at all possible (varies by setting).

7) mkisofs - you use mkisofs to convert your build directory to an iso

cd ~/custom
sudo mkisofs -D -r -V "$IMAGE_NAME" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o ../ubuntu-12.04-custom.iso .

8) Persistence. You can use persistence with many live CD, including the ubuntu-desktop cd and a custom cd, this is implemented by casper.

A. root - casper will mount a partition or file labeled as casper-rw as a cow overlay on / . If you then install a package, or modify a config file, the changes will persist over a reboot.

Use this sparingly. If you update all the packages, it will take a lot of space. I also find that this method is sometimes buggy.

B. Home - casper sill mount a partition or file labeled aas home-rw as a cow overlay on /home.

I prefer this as my firefox bookmarks and private data will be preserved across boots and I find it more reliable.

Persistent home (change to casper-rw for a persistent / )

# this is a 1 Gb file, increase or decrease the count to make it larger or smaller
dd if=/dev/zero of=home-rw bs=1M count=1000

# make a file system
mkfs.ext4 home-rw
mke2fs 1.41.14 (22-Dec-2010)
home-rw is not a block special device.
Proceed anyway? (y,n) y <-- ANSWER 'y' here

#tune the file system to remove reserved blocks and label it 'home-rw'
tune2fs -m 0 -L home-rw home-rw

Put home-rw in / (in the root directory of a partition) or onto a flash drive (not in a sub directory).

When you boot the live CD, hit the F6 key, they Esc, add the option persistent to the boot parameters, in front of the '--'

quiet splash persistent --

The casper boot scripts will then find an mount it automatically.

See Ubuntu wiki Persistence - The ubuntu wiki page only discussed casper-rw, but home-rw is referenced in the casper scripts and works the same way, only the name has been changed.

See This post on the Ubuntu forums for a screen shot walk through (although with different options).

C. You can enable persistence with several of the graphical tools, unetbootin for example. The graphical tools (as far as I know) use casper-rw.

OK, now once you understand all that, these two pages will start to make more sense

Ubuntu wiki live cd from scratch

Ubuntu wiki customize live CD

Google

You will need to google. You will find fragments of advice all over the internet.

Example : How to change Live CD splash screen

Debian Live

Now that you understand all that, use the Debian Live scripts. Do not let the name fool you you, these scripts work just fine on any .deb system, including Mint and Ubuntu.

To install

sudo apt-get install live-build

There is a graphical interface

sudo apt-get install live-magic

live-magic

Understand that the live-magic gui may fail, just as remastersys and other guis fail. In that event, you fall back to the live-build scripts (live-magic will generate a build directory).

It takes a while to learn the live-build scripts and the directory layout/structure

See the Debian Live Manuel Aye, it is long, just work through it one iso at a time.

The advantage of the live-build scripts, once you understand the components of a live CD, the scripts automate 90+ % of the build, and making a change is a simple edit to a config file (usually) or sometimes building a initramfs.

Too long

If that was too long for you, take a deep breath, relax, and work though the information one part at at time. I promise it will start to make some sense and you will find the time is well worth it.

If you start with another tool set, come back to this set of tools and after a few iso you will appreciate this set of instructions ;)

My custom 12.04 build, it supports the gma500, 2d only (no 3d) out of the box (will be making the iso publicly available to the gma 500 crowd in the next few days).

gma 500