[HowTo] Create Ubuntu Live CD

Ubuntu 10.10 code name Maverick Meerkat has been released on October 10th 2010 you can download it from ubuntu.com for free. But when you are an Ubuntu advance user, you need to add more package or remove some package that you won’t use. Then you can live boot your custom Ubuntu live CD. And it’s not limited to live CD, you can make it as live USB too.

There are some reasons you want to customize Ubuntu live CD:

  1. Make your own Linux / Ubuntu distribution, something like rebranding but based on Ubuntu
  2. Show off a particular application
  3. Localise to a certain language
  4. Remove software packages
  5. Add software packages
  6. Update software packages
  7. Change system defaults (theme, icons, desktop background, panels, browser homepage, etc)

To make custom Ubuntu live CD:

  1. Open your terminal and install squashfs-tools and genisoimage:
    sudo apt-get install squashfs-tools genisoimage
    
  2. Download Ubuntu Desktop CD:
    wget http://releases.ubuntu.com/maverick/ubuntu-10.10-desktop-i386.iso
    
  3. Move it to working directory, call it livecdtemp:
    mkdir ~/livecdtmp
    mv ubuntu-10.10-desktop-i386.iso ~/livecdtmp
    cd ~/livecdtmp
    
  4. Extract the CD .iso contents
    mkdir mnt
    sudo mount -o loop ubuntu-10.10-desktop-i386.iso mnt
    
  5. Extract .iso contents into dir ‘extract-cd’
    mkdir extract-cd
    rsync --exclude=/casper/filesystem.squashfs -a mnt/ extract-cd
    
  6. Extract the SquashFS filesystem to edit folder
    sudo unsquashfs mnt/casper/filesystem.squashfs
    sudo mv squashfs-root edit
    
  7. Give network connection within chroot
    sudo cp /etc/resolv.conf edit/etc/
    sudo cp /etc/hosts edit/etc/
    sudo mount --bind /dev/ edit/dev
    sudo chroot edit
    mount -t proc none /proc
    mount -t sysfs none /sys
    mount -t devpts none /dev/pts
    export HOME=/root
    export LC_ALL=C
    
  8. Customization time!
    To enable apt-get within chroot:

    dbus-uuidgen > /var/lib/dbus/machine-id
    dpkg-divert --local --rename --add /sbin/initctl
    ln -s /bin/true /sbin/initctl
    

    Update your sources.list if necessary:

    vim /etc/apt/sources.list
    

    Update your repository:

    apt-get update
    

    To install new package:

    apt-get install [package-name]
    

    To remove unwanted package:

    aptitude purge package-name
    

    To customize Gnome:
    a. Customize background:
    * add wallpaper file to /usr/share/backgrounds
    * edit /usr/share/gnome-background-properties/ubuntu-wallpapers.xml to point to your wallpaper file
    b. Change font, panels, etc:
    To make any change on the gconf attributes you must add the value that you want in the file /etc/gconf/gconf.xml.defaults/%gconf-tree.xml. Adding a value in that file will change the default values of Gnome or other applications, so you can change fonts, backgrounds, themes, cursors etc. You can use gconftool-2, under the chroot environment to adjust the gconf file:

    gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults --type string --set yourkey "yourvalue"
    

    I haven’t do this much, since the livecd i create is for disaster recovery, so default desktop it’s fine with me. But it’s worth to try.

    Change the default timezone used by the live cd:

    dpkg-reconfigure tzdata
    

    Change local setting:

    locale-gen new_locale
    update-locale LANG=new_locale LANGUAGE=new_locale LC_ALL=new_locale
    
  9. Clean up
    aptitude clean
    rm -rf /tmp/* ~/.bash_history
    rm /etc/resolv.conf
    rm /var/lib/dbus/machine-id
    rm /sbin/initctl
    dpkg-divert --rename --remove /sbin/initctl
    
  10. Regenerate manifest:
    chmod +w extract-cd/casper/filesystem.manifest
    sudo chroot edit dpkg-query -W --showformat='${Package} ${Version}n' > extract-cd/casper/filesystem.manifest
    sudo cp extract-cd/casper/filesystem.manifest extract-cd/casper/filesystem.manifest-desktop
    sudo sed -i '/ubiquity/d' extract-cd/casper/filesystem.manifest-desktop
    sudo sed -i '/casper/d' extract-cd/casper/filesystem.manifest-desktop
    
  11. Compress filesystem:
    sudo rm extract-cd/casper/filesystem.squashfs
    sudo mksquashfs edit extract-cd/casper/filesystem.squashfs -nolzma
    
  12. Remove old md5sum.txt and calculate new md5 sums
    cd extract-cd
    sudo rm md5sum.txt
    find -type f -print0 | sudo xargs -0 md5sum | grep -v isolinux/boot.cat | sudo tee md5sum.txt
    
  13. Create the ISO image:
    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-10.10-desktop-i386-custom.iso .
    
  14. Testing the CD image:
    qemu -cdrom ubuntu-10.10-desktop-i386-custom.iso -boot d -m 512
    
  15. Burn the CD:
    You can use any tools you like, for example Gnomebaker. Or:

    cdrecord dev=/dev/cdrom ubuntu-10.10-desktop-i386-custom.iso
    

    You can make the USB live with Unetbootin.

That’s it. You can create your custom Ubuntu live cd or even rebranded it. Long live Ubuntu!

There is online tools to create custom Ubuntu and Debian live CD it is called Reconstructor. You can see the tutorial from How-To Geek article.

Credits:
LiveCDCustomization Documentation

Comments

  1. Melinda says:

    what
    is
    the
    difference
    between
    this
    and
    REMASTERSYS
    ——————–
    incomplete – missleading

  2. Liko says:

    maaf mas mau tanya
    aku sudah ngikuti step by step
    sampai ke step 11
    ketika kuketik perintah
    sudo mksquashfs edit extract-cd/casper/filesystem.squashfs -nolzma

    kok muncul error
    mksquashfs: invalid option

    SYNTAX:mksquashfs source1 source2 … dest [options] [-e list of exclude
    dirs/files]

    yang salah option sebelah mana?

    • Coba periksa kembali ke step 6 saat folder edit di create.

    • Egadz says:

      I don't speak Bahasa, so I am relying on the translation. I am getting the same error message as Liko, and referring to step 6 when the edit folder was created is not enlightening me.
      For compression options with the latest version of mksquashfs, I can only find -noI, -noD and -noF listed in the man page.

      "mksquashfs: invalid option" when -nolzma is on the right, and when it is on the left, of course it just breaks syntax completely and gives a general error.

      I will assume lzma compression is removed.

  3. Igor says:

    thanks buat tutorialnya.
    cm masih penasaran, gmn cara create ubuntu yang alternate version dengan packages yang ter-up2date seperti LTS release ex: 10.04.2

  4. Hello Ivan.
    How could I delete the livecdtmp folder after the iso has been created?
    I understand that I have to unmount the mnt first but it still won’t let me delete the livecdtmp folder

Give me your feedback

This site uses Akismet to reduce spam. Learn how your comment data is processed.