Use tklpatch to create an ISO from an existing (Turnkey-based) VM

Conor Fox's picture

For a few monthes I've been using a VM based on the Turnkey PostgresQL appliance.  I've made a bunch of mods (package installs, conf file changes etc)

Now I'd like to create an ISO that others can use to install my modified appliance.  I'm trying to do so using the tklpatch scripts, which I chose for a couple of reasons:

-- I'd like to be able to create patches in the future

-- I'm new to the process of creating ISOs, and to related topics like chroot and mksquashfs.  Tklpatch  seems like a nice way to see how these steps fit together.


The only trouble is that the tklpatch workflow seems to assume that you start with an ISO and end up with a modified ISO.

By contrast, I want to simply:

(1) Mount the filesystem from my appliance on some other machine (a Turnkey core VM)

(2) On that VM, use tklpatch-prepare-cdroot and tklpatch-geniso to create an ISO from the mounted appliance

However step (2) relies on the original ISO to prepare the cdroot.  Is there a way to avoid the need for an original ISO (eg by creating the squahed FS by hand?).  Or should I instead start with some Turnkey ISO, and uses its squashed FS in combination with the rootfs from my appliance?

Conor Fox's picture

I think I've just about solved this problem.  I started by following my own suggestion of starting with "some Turnkey ISO" and using it to bootstrap the rest of the workflow.  This worked I think (I haven't yet tested the resulting ISO) but with hindsight it seems to me to be pretty easy to create the cdroot structure without needing a bootstrap ISO. Will try this tomorrow and post again.

Btw thanks for TKL guys, its great!

Conor Fox's picture

I feel a little stupid now. 

tklpatch-prepare-cdroot only requires an empty cdroot directory (and a rootfs).  Theres no need for any "bootstrap ISO" or any such nonsense.

What confused me was the fact that tklpatch-extract-iso creates a cdroot and copies a file to it. 

However tklpatch-prepare-cdroot overwrites this file with the equivalent file from rootfs.

So all I need to do is:

# mkdir foo.cdroot

# tklpatch-prepare-cdroot foo.cdroot path/to/rootfs
... wait

# tklpatch-geniso foo.cdroot

Might be worth modifying tklpatch-prepare-cdroot so that it creates the supplied cdroot dir (foo.cdroot in my example) if it doesn't already exist ?

Liraz Siri's picture

Sorry for the late response. The core team is deep into a development cycle working on new features so we haven't been able to give the community as much attention as it deserves.

You know for some reason we never even considered this particular usage scenario: building an ISO from a VM.

You're right regarding the contents of the cdroot being populated from the filesystem so we don't actually need to use the ISO's cdroot as a template. I'll ask Alon if maybe we should remove the cdroot as an argument entirely and just create it on the fly...

Alon Swartz's picture

I have just released tklpatch v0.92 (github, package archive). The new version includes several enhancements, the main one being support for configuration hooks. Along the way I made the change to tklpatch-prepare-chroot for the cdroot-dir to be optional (note the order of arguments has changed).

If cdroot-dir is not specified, a minimal isolinux.cfg will be created on the fly to automatically boot the system, otherwise the kernel, initrd and other boot options need to be specified manually.

Building an ISO from a VM is a cool idea, and hopefully with this update it will be a little easier. Keep us posted, I'd love to hear what you come up with...

As always, feedback is welcome!
deepti's picture

modifying vmdk file of linuxcnc-wheezy.iso

In chrooting following error comes

apt-get  install  linux-image-generic
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package linux-image-generic

sudo tklpatch-prepare-cdroot turnkey-core.rootfs/
# preparing cdroot
cp: cannot stat ‘turnkey-core.rootfs//usr/lib/ISOLINUX/isolinux.bin’: No such file or directory

 What is the above mentioned error and how can i resolve it .

Jeremy Davis's picture

I recall we hit a similar issue when we first started development of v14.0 (based on Jessie). I don't really recall any of the details now but I suspect we patched the issue in the latest version of tklpatch.

So my guess is either you have the newer version and it's not backwards compatible. Or you need the newer version. TBH though I'm only guessing...

Post new comment