First you download the Live CD ISO. While it is downloading install some software that is needed for rebuilding: sudo apt-get install squashfs-tools dchroot
- Squashfs Install squashfs-tools is a compressed read-only filesystem for Linux.
- dchroot Install dchroot allows users to execute commands or interactive shells in different chroots.
Mount the Live CD:
mkdir /tmp/livecd
sudo mount -o loop ~/Downloads/ubuntu-11.04-desktop-i386.iso /tmp/livecd
If you use another ISO or another location for your download please adjust accordingly.
Create a working area and copy contents over to the working area:
mkdir -p ~/livecd/cd
rsync --exclude=/casper/filesystem.squashfs -a /tmp/livecd/ ~/livecd/cd
mkdir ~/livecd/squashfs ~/livecd/custom
sudo modprobe squashfs
sudo mount -t squashfs -o loop /tmp/livecd/casper/filesystem.squashfs ~/livecd/squashfs/
sudo cp -a ~/livecd/squashfs/* ~/livecd/custom
If you get an error like this while doing modprobe:
sudo modprobe squashfs
WARNING: Deprecated config file /etc/modprobe.conf,
all config files belong into /etc/modprobe.d/
move the modprobe.conf mv /etc/modprobe.conf /etc/modprobe.conf.OLD and try again!
Network access:
sudo cp /etc/resolv.conf /etc/hosts ~/livecd/custom/etc/
Create a pseudo filesystem:
sudo chroot ~/livecd/custom
mount -t proc none /proc/
mount -t sysfs none /sys/
export HOME=/root
You can get a list of all packages with dpkg-query -W --showformat='${Package}\n' | less
You can remove games with apt-get remove --purge gnome-games*
Update your sources withsudoedit /etc/apt/sources.list
. Comment out lines you do not want and uncomment the ones you do want, add in PPAs if you want and then you need to update with apt-get update && apt-get dist-upgrade
Adding packages like thunderbird, Samba, Samba systen config and SSH is done the same way as you would normally install from commandline. So sudo apt-get install thunderbird samba system-config-samba ssh
will add those.
If you've manually downloaded the package from you can install it with sudo dpkg -i {file_name}.deb
You can check Ubuntu Software Center, Synaptic or the packages website for the names if more need to be installed. You might consider adding (wireless) network utilities. You will quickly run over 800 Mb; if you do you either remove more packages to get under 800 or you need to use a DVD when burning. Removing libre office will free up you 33+ Mb if you do not need it.
mkdir -p /etc/skel/Desktop && perl -e 'print("[Desktop Entry]\nVersion=1.0\nName=Ask Ubuntu\nComment=Ask Questions About Ubuntu\nGenericName=Question and Answers\nExec=xdg-open http://askubuntu.com\nTerminal=false\nX-MultipleArgs=false\nType=Application\nIcon=firefox\nCategories=Internet;\n");' > /etc/skel/Desktop/askubuntu.desktop && chmod ugo+x /etc/skel/Desktop/askubuntu.desktop
You can add more of these (skip the mkdir part) by editing the URL to something else. Courtesy of dv3500ea
You can change any gconf option if you know what the path is of that option and the value you want it to be (and the type of the value ofcourse).
enter image description here
Changing the wallpaper is done with the path I pointed arrows to: /desktop/gnome/background/
, it is a string value and it uses "picture_filename" as an option. The value it currently holds on my desktop is '/discworld2/Downloads/fantasticwall_2.jpg'
. The background itself should be copied into /usr/share/backgrounds/
. Make sure to set permissions and owner.
Examples:
To change the wallpaper (change the filename in the 1st command to your own image) to this image and to change the theme to Radiance you can use this information to create commands to set this for your live cd:
gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults --set -t string /desktop/gnome/background/picture_filename /discworld2/Downloads/fantasticwall_2.jpg
gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults --set -t string /desktop/gnome/interface/gtk_theme Radiance
Courtesy of dv3500ea
Enable remote desktop:
gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults --set -t bool /desktop/gnome/remote_access/enabled true
Settings for icons, panels etc are all done by adding a command like this.
Alternatively you can edit /etc/gconf/gconf.xml.defaults/%gconf-tree.xml
(or when you are down save this file for future usage). All the configuration settings done through gconftool-2 are stored in this file.
Change the default timezone used by the live cd
dpkg-reconfigure tzdata
Change locale setting to english (of course change it to what you want)
locale-gen en
update-locale LANG=en LANGUAGE=en LC_ALL=en
Configure configuration files.
If you want to have a custom configuration file for a certain package you can do this in several ways.
The difficult (but most logical) way would be to either find the package, change the configuration file and repackage it or to find the source files, figure out where they store their dummy config file and change that and then rebuild the package. - Of course this only works if the default configuration file is included in the source package. Many packages auto-generate their config files in the {packagename}.postinst script so it would make it rather difficult to get this done.
The easiest way would be to create a script and copy your current config to /etc/skel
so they get added to your desktop (similar to adding firefox shortcuts as explained above) and after installing click the desktop link to set the config file to the place it needs to be. The script could both do the copying and removal of both the script and config file from your desktop after it succesfully installed. This method can be used to update the Samba configuration (put your current config in /etc/skel/
. Put a script in there that has execute permissions and contains a move of said config to /etc/samba/smbd.conf
and all you need to do afterwards is execute the script).
This basically always works since it replaces a post-install manual action with a post-install manually activated script. But it also means it is not part of the custom live cd.
apt-get clean
rm -rf /tmp/*
rm -f /etc/hosts /etc/resolv.conf
umount /proc/
umount /sys/
exit
This removes all the temporary files; not what we created. ~/livecd/
is readonly so a normal rm will not remove these files. You need to mount it with write access (or as I did use the new live cd to boot and mount the home and rm it from there.
Manifest files.
chmod +w ~/livecd/cd/casper/filesystem.manifest
sudo chroot ~/livecd/custom dpkg-query -W --showformat='${Package} ${Version}\n' > ~/livecd/cd/casper/filesystem.manifest
sudo cp ~/livecd/cd/casper/filesystem.manifest ~/livecd/cd/casper/filesystem.manifest-desktop
Regenerate squashfs file.
sudo mksquashfs ~/livecd/custom ~/livecd/cd/casper/filesystem.squashfs
Update md5 sums.
sudo rm ~/livecd/cd/md5sum.txt
sudo -s
(cd ~/livecd/cd && find . -type f -print0 | xargs -0 md5sum > md5sum.txt)
cd ~/livecd/cd
sudo mkisofs -r -V "Ubuntu-Live-kartick87" -b isolinux/isolinux.bin -c isolinux/boot.cat -cache-inodes -J -l -no-emul-boot -boot-load-size 4 -boot-info-table -o ~/Downloads/ubuntu-11.04-desktop-i386.iso .
- Everything was tested with an Ubuntu 11.04 Live CD. Only thing that went wrong was chrooting: I added dchroot to the files you need to install to do this.
- Regarding "should create some firefox shortcuts on desktop", "Should change the default theme to radiance" and "Should change the default ubuntu wallpaper". I edited these in after dv3500ea put it into the comments; I did not test this while creating the 11.04 live cd.