# How to remaster a ubuntu 8.04 live-cd with a custom kernel. This # most likely works with 7.10 as well. # -- Ben Greear # This can _almost_ be cut-and-pasted into the prompt exactly # as is, but it's likely I glossed over a few steps or commands # Suggestions are welcome. --Ben # BUILD_KERNEL # These URLS may be useful to some, but they are mostly providing slightly # diffent info on slightly different goals. # Building kernel .debs # See: http://www.falkotimme.com/howtos/debian_kernel2.6_compile/ # Building new ubuntu installer: # http://dsplabs.utt.ro/~juve/blog/index.cgi/01147559232 # Related notes: # http://wiki.debian.org/DebianInstaller/Modify/CustomKernel # http://ubuntuforums.org/archive/index.php/t-48128.html # # Get a standard ubuntu kernel, patch it, and build debs. # # This assumes you are using 'lanforge' for your private build id. Obviously # you will want to change this for your own project. # Become root sudo su - # Get some development packages apt-get install kernel-package ncurses-dev fakeroot wget bzip2 # Make us a private dir to play in mkdir /usr/src/ben cd /usr/src/ben apt-get source linux-image-2.6.24-16-generic cd linux-2.6.24/debian/binary-custom.d # Read the README, and then proceed to add entries for a custom kernel build mkdir lanforge cd lanforge #cp /boot/config-2.6.24-16-generic config.i386 if [ ! -f /mnt/ghome/greearb ] then mount /mnt/ghome fi cp /mnt/ghome/greearb/btbits/btbits/kernel/kernel26-24_deb.cfg config.i386 # Make changes to the config, in my case: # CONFIG_REDIRDEV=m # CONFIG_HZ_250 is not set # CONFIG_SUPPORT_SEND_BAD_CRC=y # CONFIG_HZ=1000 # CONFIG_HZ_1000=y # CONFIG_NR_CPUS=16 # DEBUG_INFO=n vi config.i386 mkdir patchset cp /mnt/ghome/greear/btbits/btbits/kernel/candela_2.6.24.patch patchset/0001-ct24_deb.patch touch rules echo custom_flavors == lanforge > vars cd ../../.. # Add us to the control file cat << EOF >> debian/control Package: linux-image-2.6.24-16-lanforge Architecture: i386 Section: base Priority: optional Pre-Depends: dpkg (>= 1.10.24) Provides: linux-image, linux-image-2.6, fuse-module, kvm-api-4, ivtv-modules Depends: initramfs-tools (>= 0.36ubuntu6), coreutils | fileutils (>= 4.0), module-init-tools (>= 3.3-pre11-4ubuntu3) Conflicts: hotplug (<< 0.0.20040105-1) Recommends: lilo (>= 19.1) | grub Suggests: fdutils, linux-doc-2.6.24 | linux-source-2.6.24 Description: Linux kernel image with LANforge patches for version 2.6.24 on i386 This package contains the Linux kernel image for version 2.6.24 on i386. The Candela Technologies LANforge patchset has been applied. . Also includes the corresponding System.map file, the modules built by the packager, and scripts that try to ensure that the system is not left in an unbootable state after an update. . Supports Alternate x86 (486 and better) processors. Package: linux-headers-2.6.24-16-lanforge Architecture: i386 Section: devel Priority: optional Depends: coreutils | fileutils (>= 4.0), linux-headers-2.6.24-16, ${shlibs:Depends} Provides: linux-headers, linux-headers-2.6 Description: Linux kernel headers for version 2.6.24 on i386 This package provides kernel header files for version 2.6.24 on i386. The Candela Technologies LANforge patchset has been applied. . This is for sites that want the latest kernel headers. Please read /usr/share/doc/linux-headers-2.6.24-16/debian.README.gz for details. EOF # Need to change generic-di to lanforge-di in debian/control # so that the udebs will be built correctly. if [ ! -f debian/control.orig ] then cp debian/control debian/control.orig fi sed -e 's/generic-di/lanforge-di/g' debian/control.orig > debian/control.1 sed -e 's/XB-Kernel-Version: 2.6.24-16-generic/XB-Kernel-Version: 2.6.24-16-lanforge/g'\ debian/control.1 > debian/control # Set up kernel-versions correctly cat << EOF > debian/d-i/kernel-versions # arch version flavour installedname suffix bdep i386 2.6.24-16 lanforge 2.6.24-16-lanforge - EOF cp debian/d-i/kernel-versions ./ # NOTE: If you modify a file after the kernel build has completed, # the kernel will NOT be recompiled until you: # rm debian/stamps/stamp-custom-build-lanforge # rm -fr debian/linux-image-2.6.24-16-lanforge linux-headers-2.6.24-16-lanforge # build the kernel packages DEB_BUILD_OPTIONS=parallel=2 sudo fakeroot debian/rules custom-binary-lanforge cp ../linux-image-2.6.24*lanforge_2.6.24*_i386.deb \ /mnt/d2/pub/candela_cdrom.5.0.7/debs/dists/candela/multiverse/binary-i386/ cp ../linux-headers-2.6.24*lanforge_2.6.24*_i386.deb \ /mnt/d2/pub/candela_cdrom.5.0.7/debs/dists/candela/multiverse/binary-i386/ cd /mnt/d2/pub/candela_cdrom.5.0.7/debs dpkg-scanpackages . /dev/null | gzip -9c > dists/candela/multiverse/binary-i386/Packages.gz cd - # Build a custom module KERNEL_BASE_DEB=/usr/src/ben/linux-2.6.24/debian/build/custom-build-lanforge cd /mnt/ghome/greearb/btbits/btbits/kernel/wanlink make -C ${KERNEL_BASE_DEB} SUBDIRS=$PWD modules mv wanlink.ko wanlink_deb_24.ko rm wanlink.o *.mod.o .wanlink* wanlink.mod.c; rm -fr .tmp_version* cd - sudo apt-get update # Install the new kernel on the host os sudo apt-get install linux-image-2.6.24-16-lanforge sudo apt-get install linux-headers-2.6.24-16-lanforge # Get and build the ubuntu modules (squashfs, among others) # http://ubuntuforums.org/showthread.php?t=553800 cd .. apt-get source linux-ubuntu-modules-2.6.24 cd linux-ubuntu-modules*24 # Set up kernel-versions correctly cat << EOF > debian/d-i/kernel-versions # arch version flavour installedname suffix bdep i386 2.6.24-16 lanforge 2.6.24-16-lanforge - EOF cat << EOF > debian/custom_fixup_control #!/bin/bash sed -e 's/generic-di/lanforge-di/g' control > control.1 sed -e 's/XB-Kernel-Version: 2.6.24-16-generic/XB-Kernel-Version: 2.6.24-16-lanforge/g' control.1 > control.2 sed -e 's/2.6.24-16-generic/2.6.24-16-lanforge/g' control.2 > control #sed -e 's/2.6.24-16-386/2.6.24-16-lanforge/g' control.3 > control EOF chmod a+x debian/custom_fixup_control # Add fixup rule to call the fixup script echo -e \\t\(cd debian\; ./custom_fixup_control\) >> debian/rules fakeroot debian/rules binary-arch arch=i386 flavours=lanforge cp ../linux-ubuntu-modules-2.6.24-16-lanforge_2.6.24-16.22_i386.deb \ /mnt/d2/pub/candela_cdrom.5.0.7/debs/dists/candela/multiverse/binary-i386/ cp ../linux-headers-lum-2.6.24-16-lanforge_2.6.24-16.22_i386.deb \ /mnt/d2/pub/candela_cdrom.5.0.7/debs/dists/candela/multiverse/binary-i386/ cd /mnt/d2/pub/candela_cdrom.5.0.7/debs dpkg-scanpackages . /dev/null | gzip -9c > dists/candela/multiverse/binary-i386/Packages.gz cd - apt-get update apt-get install linux-ubuntu-modules-2.6.24-16-lanforge apt-get install linux-headers-lum-2.6.24-16-lanforge # SKIP this if you just want a live cd. The installer is used for # 'regular' install images. if false then # Skip this if you don't need udebs (you don't need them for a live cd) # DEB_BUILD_OPTIONS=parallel=2 sudo fakeroot debian/rules do-binary-udebs # Move our kernel debs into a target directory for easy installing with apt-get # cp ../*.deb /mnt/d2/pub/candela_cdrom.5.0.7/debs/dists/candela/multiverse/binary-i386/ # Building the debian-installer initrd (udebs, not useful for live-cd) sudo apt-get install kernel-wedge sudo apt-get build-dep debian-installer cd .. sudo apt-get source debian-installer sudo cp *.udeb debian-installer-*ubuntu*/build/localudebs cd debian-installer-*ubuntu*/build # Update to our 2.6.23.17-586 sudo vi config/i386.cfg sudo make build_cdrom_isolinux fi # OR, Build a live-cd kernel and initrd from kernel.org source package. KVER=2.6.23.17 LFVER=5.0.7 wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-$KVER.tar.bz2 tar -xvjf linux-$KVER.tar.bz2 cd linux-$KVER copy .config from proper place to .config copy candela patch locally patch -p1 < candela_2.6.23.patch export CONCURRENCY_LEVEL=2 make-kpkg clean fakeroot make-kpkg --initrd --append-to-version=-586 \ --revision=lanforge.$LFVER kernel_image kernel_headers cp ../linux-image-2.6.23.17-586_lanforge.5.0.7_i386.deb \ /mnt/d2/pub/candela_cdrom.5.0.7/debs/dists/candela/multiverse/binary-i386/ cd /mnt/d2/pub/candela_cdrom.5.0.7/debs dpkg-scanpackages . /dev/null | gzip -9c > dists/candela/multiverse/binary-i386/Packages.gz sudo apt-get update # Install the new kernel on the host os sudo apt-get install linux-image-2.6.24-16-lanforge # # Rebuild live-cd based off of existing live-cd image # # Mostly just follow notes on this page: # http://www.debuntu.org/how-to-customize-your-ubuntu-live-cd-p2 #Also remove openoffice, totem, rhythmbox, sound-juicer, old linux kernel #(after update) # Should be able to copy & paste this on an Ubuntu machine to # get desired results. #UVER=7.10 export UVER=8.04 cd sudo apt-get install squashfs-tools mkdir /tmp/livecd sudo mount -o loop ~/Desktop/ubuntu-$UVER-desktop-i386.iso /tmp/livecd mkdir ~/livecd mkdir ~/livecd/cd rsync --exclude=/casper/filesystem.squashfs -a /tmp/livecd/ ~/livecd/cd mkdir ~/livecd/squashfs mkdir ~/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 sudo cp /etc/resolv.conf /etc/hosts ~/livecd/custom/etc/ # Enter the chroot sudo chroot ~/livecd/custom mount -t proc none /proc/ mount -t sysfs none /sys/ export HOME=/root # start up dbus, the hal needs it as part of it's install/upgrade procedure /etc/init.d/dbus start # Purge things we don't need. echo Y|apt-get remove --purge gnome-games* echo Y|apt-get remove --purge `dpkg-query -W --showformat='${Package}\n' | grep language-pack | egrep -v '\-en'` echo Y|apt-get remove --purge `dpkg-query -W --showformat='${Package}\n' | grep openoffice` echo Y|apt-get remove totem echo Y|apt-get remove totem-common echo Y|apt-get remove rhythmbox echo Y|apt-get remove sound-juicer echo Y|apt-get remove evolution echo Y|apt-get remove evolution-common echo Y|apt-get remove ekiga echo Y|apt-get remove example-content echo Y|apt-get remove tomboy echo Y|apt-get remove bogofilter echo Y|apt-get remove bogofilter-bdb echo Y|apt-get remove cdparanoia echo Y|apt-get remove dcraw echo Y|apt-get remove diveintopython echo Y|apt-get remove espeak echo Y|apt-get remove espeak-data echo Y|apt-get remove evolution-data-server echo Y|apt-get remove f-spot echo Y|apt-get remove fortune-mod echo Y|apt-get remove gnome-games-data echo Y|apt-get remove ttf-arabeyes echo Y|apt-get remove ttf-arphic-uming echo Y|apt-get remove ttf-indic-fonts-core echo Y|apt-get remove ttf-kochi-gothic echo Y|apt-get remove ttf-kochi-mincho echo Y|apt-get remove ttf-lao echo Y|apt-get remove ttf-malayalam-fonts echo Y|apt-get remove ttf-thai-tlwg echo Y|apt-get remove ttf-unfonts-core apt-get autoremove apt-get update echo Y|apt-get install portmap nfs-common nfs-kernel-server mkdir /mnt/d2 mount 192.168.100.3:/mnt/d2 /mnt/d2 echo deb file:/mnt/d2/pub/candela_cdrom.5.0.7/debs candela multiverse >> /etc/apt/sources.list echo deb http://archive.ubuntu.com/ubuntu gutsy universe multiverse >> /etc/apt/sources.list apt-get update echo Y|apt-get dist-upgrade echo Y|apt-get install tshark wireshark traceroute dhcp bridge-utils ssh # Install LANforge # No need to manually add-user now, as the lanforge-gui deb does that for us. #adduser lanforge apt-get install lanforge-gui apt-get install lanforge-server apt-get install lanforge-xorp apt-get install linux-image-2.6.24-16-lanforge apt-get install linux-headers-lum-2.6.24-16-lanforge apt-get install linux-ubuntu-modules-2.6.24-16-lanforge # Set up the installer icon on the desktop cp /usr/share/applications/ubiquity-gtkui.desktop /home/lanforge/Desktop/ cp /usr/share/applications/gnome-terminal.desktop /home/lanforge/Desktop/ # Set root password sudo passwd root # Enable root to pop up X windows # Change DisallowTCP=true to =false vi /etc/gdm/gdm.conf # Disable network-manager...it conflicts with LANforge echo "auto lo" > /etc/network/interfaces echo "iface lo inet loopback" >> /etc/network/interfaces echo >> /etc/network/interfaces echo "auto eth0 inet dhcp" >> /etc/network/interfaces vi /etc/xdg/autostart/nm-applet.desktop # Set auto-start to false # Add lanforge to /etc/sudoers vi /etc/sudoers # Let LANforge know it's in a live-cd environment echo "Ubuntu LIVE CD" > /home/lanforge/lanforge_live.txt # Remove old kernel # Clean up chroot /etc/init.d/dbus start apt-get autoremove apt-get clean rm -fr /tmp/* umount /mnt/d2 umount nfsd umount /proc umount /sys umount /proc umount /sys umount tmpfs rm -f /etc/hosts /etc/resolv.conf # Exit from chroot exit export UVER=8.04 # Get ready to make the ISO 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 # Copy new kernel into isolinux dir for the live cd # This would copy a stock ubuntu kernel correctly..but not a custom built one. sudo cp ~/livecd/custom/initrd.img ~/livecd/cd/casper/initrd.gz sudo cp ~/livecd/custom/vmlinuz ~/livecd/cd/casper/vmlinuz # This is for building non-live CDs, and assumes you have built the debian-installer # and supporting udeb initrd. #sudo cp /usr/src/ben/debian-installer-20070308ubuntu39/build/dest/cdrom/vmlinuz \ # ~/livecd/cd/casper/ #sudo cp /usr/src/ben/debian-installer-20070308ubuntu39/build/dest/cdrom/initrd.gz \ # ~/livecd/cd/casper/ # Make the squashfs file system sudo rm ~/livecd/cd/casper/filesystem.squashfs sudo mksquashfs ~/livecd/custom ~/livecd/cd/casper/filesystem.squashfs # Edit ~/livecd/cd/README.diskdefines sudo vi ~/livecd/cd/README.diskdefines sudo rm ~/livecd/cd/md5sum.txt sudo -s (cd ~/livecd/cd && find . -type f -print0 | xargs -0 md5sum > md5sum.txt) export UVER=8.04 cd ~/livecd/cd sudo mkisofs -r -V "Ubuntu-Live-LANforge" -b isolinux/isolinux.bin -c isolinux/boot.cat \ -cache-inodes -J -l -no-emul-boot -boot-load-size 4 -boot-info-table \ -o ~/Desktop/Ubuntu-Live-$UVER-LANforge.iso . cp ~/Desktop/Ubuntu-Live-$UVER-LANforge.iso /mnt/d2/pub/candela_cdrom.5.0.7/ exit