|
Linux /
RemasteringAUbuntuLiveCDStage 1: Get old Live CD into editable formatThe directory structure you are going to end up with after this stage: Working (current) folder
- old.iso – iso image of previous Live CD 1. Copy mk-iso.sh and expand-iso.sh scripts into current folder. 2. Create an iso image of the live cd you are going to work from dd if=/dev/cdrom of=old.iso. (If the cd-rom is currently mounted, unmount it first with the command sudo umount /dev/cdrom ). If this doesn’t work, you probably have errors on the CD. Try one of the graphical !tools such as GnomeBaker? that has more error handling capability. You don’t have to do this step if you already have an iso or if you wish to copy the files straight from the cd. If you do copy the files from the cd you’ll need to change the source for the rsync commands though (to eg. /media/cdrom0). The following commands of Stage 1 are done within expand-iso.sh script (./expand-iso.sh) 3. Create directories to work with – cd, mnt, squash, and source using mkdir commands: mkdir cd, mkdir mnt, mkdir squash, and mkdir source. 4. Mount the iso image sudo mount old.iso mnt -o loop Note that the expand-iso.sh shell script will ask you which iso image you want; it doesn't have to be old.iso. 5. Rsync the live cd contents to the cd directory you made. rsync -a mnt/ cd/ 6. Mount squashed filesystem sudo mount -t squashfs -o loop mnt/casper/filesystem.squashfs squash 7. Copy all the stuff from the mounted squash filesystem to the source directory. sudo cp -a squash/* source/ 8. Unmount squash and mnt: sudo umount squash and sudo umount mnt Stage 2: Adding and removing packages9. Copy the resolv.conf (contains DNS server info) and sources.list (contains the repository info) from your machine to the CD root so you can access internet repositories: sudo cp /etc/resolv.conf source/etc/resolv.conf sudo cp /etc/apt/sources.list source/etc/apt/sources.list (only if your current machine is the correct version of Ubuntu) If you need a new sources list you can get one from http://www.ubuntu-nl.org/source-o-matic/. The NZ sources tend to be unreliable but the Australian ones work fine. 10. Change root to the source directory sudo chroot source/ 11. Then export HOME=/root (sets the new home folder) and export LC_ALL=C (sets the internationalisation locale – should be C if you want to compile anything i.e. uses C ANSI standards for multiple locales). You can now add and remove packages using the following commands: - apt-get remove --purge <packagename> where <packagename> is the actual name of the package you wish to get rid of. You can remove several packages at once e.g. apt-get remove --purge evolution evolution-data-server evolution-exchange - dpkg-query -W --showformat='${Installed-Size} ${Package}\n' | grep -i <package> to work out the actual package names (where <package> is actually a string identifying which package you’re interested in. - dpkg-query -W --showformat='${Installed-Size} ${Package}\n' | sort -nr |more will show the packages in order of size. - apt-get update will update the package list. Do this before adding any new packages. - apt-get install <packagename> where <packagename> is the name of the package you wish to install. Again you can add several packages at once. Note that if you’re going to compile things you’ll need to do apt-get install build-essential to get the main libraries that aren’t installed by default with Ubuntu. 12. Remove unnecessary temp files with apt-get clean, apt-get autoclean and rm -rf /tmp/* 13. Remove the resolv.conf as you don't want your network settings to remain in the live cd. rm /etc/resolv.conf 14. Exit the chroot environment exit Stage 3: Creating the CD image15. sudo vim cd/README.diskdefines and change the disk name if you wish (Basic vim commands are i to insert, esc :w! to write and :q to quit) All commands below are done within mk-iso.sh script (sudo ./mk-iso.sh) 16. chmod +w cd/casper/filesystem.manifest sets up the CD manifest to be writable. 17. sudo chroot source dpkg-query -W --showformat '${Package} ${Version}\n' > cd/casper/filesystem.manifest creates a new manifest for the installed packages on the LiveCD? desktop. 18. sudo cp cd/casper/filesystem.manifest cd/casper/filesystem.manifest-desktop copies the Live CD manifest to also be the manifest for the installed system. 19. sudo sed -ie /ubiquity/d cd/casper/filesystem.manifest-desktop deletes any lines with ubiquity in it (ubiquity is one of the Ubuntu packages that does the actual repartitioning and installing from LiveCD? onto HDD). Also need to do the same with casper, libdebian-installer4, os-prober, ubuntu-live, and user-setup. Note that there are easier ways of doing this rather than one command per package but this sets it out clearer if you ever want to edit the script. 20. sudo rm cd/casper/filesystem.squashfs deletes the old squashed file system. 21. sudo mksquashfs source cd/casper/filesystem.squashfs takes a long time but squashes the entire source folder into the filesystem.squashfs file. Note: to use the mksquashfs command you need to install squashfs-tools (sudo apt-get install squashfs-tools) 22. rm cd/md5sum.txt remove the old md5hash 23. cd cd && find . -type f -print0 |xargs -0 md5sum > md5sum.txt create the new md5 hash and move into cd folder to do so 24. sudo mkisofs -r -V "<Name>" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o ../<isoname> . (NB: the . is necessary). This creates the iso file. The mk-iso.sh script actually sets the volume name and ISO name to be the same prefix (ubuntu-7.04.x – x is the user supplied version number). The options are: - r – create Rock Ridge format - V – set volume ID (<Name> is anything you like) - cache-inodes – needed to detect hard links (similar to Windows shortcuts). - J – Joliet directory information - l – allow full long (31 character) filenames for ISO9660? names. - b – set El Torito boot image to cd/isolinux/isolinux.bin from original cd. - c – set El Torito boot catalog to cd/isolinux/boot.cat from original cd. - no-emul-boot – boot image is ‘no emulation’ image. - boot-load-size 4 – sets the number of load segments - boot-info-table – patch boot image with info table. - o – output file set to be in parent folder (<isoname> is obviously anything you like) - . – generate iso from current folder. 25. Write the CD and you’re finished. Boot up your live cd to test it. |