Log in

No account? Create an account
Ubuntu Custom CD: a quick and dirty way - 豬頭'blog [entries|archive|friends|userinfo]

[ website | 豬頭基 ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

[Links:| o0o blog myspace deviantart PromoDJ KTK project ]

Ubuntu Custom CD: a quick and dirty way [Mar. 25th, 2013|03:52 pm]

A few notes on my practical experience of building custom ubuntu disks. I work here with Ubuntu Precise (12.04). But any other Ubuntu distro should be ok, unless the bug I mention below is fixed, then you can stick with the official guide. Anyways, lets start:

First, useful resources used:

https://help.ubuntu.com/community/InstallCDCustomization - this is the main tutorial I followed. However a few things didn't work for me, so here are my workarounds.

If you follow the guide you will run into the error: can't install base-files while bootstrapping the installer. The practical testing demonstrated that there is some problem with generated Packages (sequence?), so with wrong sequence you'll have base-files and base-passwd to fail dependency on libc6. I believe this bug is similar to http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=601670 and I have not been able to figure out how to generate a proper Packages sequence. Instead, I simply modify the checksums/sizes for updated ubuntu-keyring in Packages and have everything else in 'extra' folder. This way you don't need to worry about sequences althu this is a bit of manual work. The good thing is - you only have to do it once, to add your pgp key to ubuntu-keyring, and won't have to do it again, unless you'd have the key.

So here are my steps of doing custom Ubuntu disk:

step 1: generate your gpg key pair and create new version of ubuntu-keyring package (you will have .deb and .udeb files). (covered very well here https://help.ubuntu.com/community/InstallCDCustomization)
step 2: mount and copy content of official ubuntu image. (also covered here https://help.ubuntu.com/community/InstallCDCustomization, so won't be repeated)
step 3:

Copy over your ubuntu-keyring packages into proper location, replacing old files:

cp ubuntu-keyring_2011.11.21.1_all.deb c-image/pool/main/u/ubuntu-keyring/ubuntu-keyring_2011.11.21.1_all.deb

cp ubuntu-keyring-udeb_2011.11.21.1_all.udeb cd-image/pool/main/u/ubuntu-keyring/ubuntu-keyring-udeb_2011.11.21.1_all.udeb

generate packages file, so you could cut-n-paste the right bits:

apt-ftparchive packages cd-image/dists/precise/main/ > /tmp/newPackages

note that if you try to replace current Packages.gz with newPackages file, your installation will fail because of wrong sequence. if you don't replace the Packages file, which contains checksums for ubuntu-keyring packages, your installation will fail due to 'corrupt cd media' error.

step 4:

cd into cd-image/dists//main

cd binary-amd64 (or i386)
gunzip Packages (and you can leave this unpacked. if you wish)

now edit the file and replace the entry for ubuntu-keyring*.deb with the one from /tmp/newPackages. you can leave everything in place and just replace size, md5sum, sha1, sha128, sha256, ..

once done, save the file.

cd -
cd debian-installer

gunzip Packages

and replace the entry for ubuntu-keyring-udev* fule with the one from /tmp/newPackages.

save and you're good.

step5: create your own preseed file (again, the official guide works very well on this)

step6: create cd-image/pool/extra folder and copy your files into cd-image/pool/extra

create apt-ftparchive folder. create release.conf file in it. create apt-ftparchive-extras.conf file. Here are mine:

cat apt-ftparchive/apt-ftparchive-extras.conf
Dir {
ArchiveDir "/opt/cd-image/";

TreeDefault {
Directory "pool/";

BinDirectory "pool/extras" {
Packages "dists/precise/extras/binary-amd64/Packages";

Default {
Packages {
Extensions ".deb";
Compress ". gzip";

Contents {
Compress "gzip";


and release.conf:

cat apt-ftparchive/release.conf
APT::FTPArchive::Release::Origin "Ubuntu";
APT::FTPArchive::Release::Label "Ubuntu";
APT::FTPArchive::Release::Suite "precise";
APT::FTPArchive::Release::Version "12.04";
APT::FTPArchive::Release::Codename "precise";
APT::FTPArchive::Release::Architectures "amd64";
APT::FTPArchive::Release::Components "main restricted extras universe";
APT::FTPArchive::Release::Description "Ubuntu 12.04 LTS custom";



run this script:


pushd $BUILD
apt-ftparchive -c $APTCONF generate /opt/apt-ftparchive/apt-ftparchive-extras.conf
apt-ftparchive -c $APTCONF release $BUILD/dists/$DISTNAME > $BUILD/dists/$DISTNAME/Release

gpg --default-key $KEY --output $BUILD/dists/$DISTNAME/Release.gpg -ba $BUILD/dists/$DISTNAME/Release
find . -type f -print0 | xargs -0 md5sum > md5sum.txt


you can build your iso now:

mkisofs -r -V "Custom" \
-cache-inodes \
-J -l -b isolinux/isolinux.bin \
-c isolinux/boot.cat -no-emul-boot \
-boot-load-size 4 -boot-info-table \

you should have proper bootable custom.iso in the current folder by now. Enjoy!