Note: Almost all content here will eventually be revised and merged into the live-manual. Please do not add new content to the wiki, but contribute to the manual directly. |
This page explains how to make a small live image. The resulting image won't be a general purpose Debian, but it's useful if you want to quickly boot and use one single tool.
Contents
Forewords
Make sure you use the latest live-helper version (see DebianLive/Backports).
Through out this page, we use the arbitrary-named environment variable $LOCALOPTS, which can contain your local options, expecially the proxy settings, like :
LOCALOPTS=" --mirror-binary http://ftp.fr.debian.org/debian/ --mirror-chroot http://ftp.fr.debian.org/debian/ --mirror-bootstrap http://ftp.fr.debian.org/debian/ --mirror-binary-security http://security.eu.debian.org/ --mirror-chroot-security http://security.eu.debian.org"
or
#If you have a local proxy at 192.168.0.10:9999 (apt-proxy is easy to setup). LOCALOPTS=" --mirror-bootstrap http://192.168.0.10:9999/debian/ --mirror-chroot http://192.168.0.10:9999/debian/ --mirror-binary http://192.168.0.10:9999/debian/ --mirror-chroot-security http://security.eu.debian.org/ --mirror-binary-security http://security.eu.debian.org"
Main hints
The hints listed here are officially included in live-helper.
--bootstrap-flavour minimal
A typical minimal flavour of DebianLive is 93MiB (on i386 ; Debian/etch 2008-05 ; ISO ;binary_etch,minimal-flavour--93MB.packages.txt).
lh_config --bootstrap-flavour minimal --apt apt --distribution etch --union-filesystem unionfs $LOCALOPTS lh_build
You need to pass the option --apt apt, otherwise lh_build will fail with :
/usr/bin/env: aptitude: No such file or directory
--linux-flavours
If you don't specify --linux-flavours, you may end-up with multiple kernel flavours on the image (486, 686 ...)
lh_config --bootstrap-flavour minimal --apt apt --linux-flavours 486 --distribution etch --union-filesystem unionfs $LOCALOPTS lh_build
This can save up to 30MiB.
--hooks minimal / stripped
The option --hooks minimal or stripped can be used in conjunction with --bootstrap-flavour to remove further stuffs :
- Remove package (like apt-utils,aptitude,man-db,manpages,info,ssl,wget,dselect)
- Clean apt and mandb's cache
stripped will actually Delete some files from the installed system.
Review the files in /usr/share/live-helper/hooks/ for more information.
lh_config --bootstrap-flavour minimal --packages-lists "minimal" --apt apt --linux-flavours 486 --distribution etch --union-filesystem unionfs $LOCALOPTS lh_build
(--packages-lists "minimal" is synonym to --hooks minimal see mail).
This stripped image is 56MiB (on i386 ; Debian/etch 2008-05 ; ISO ;binary,flavour-minimal,486,hooks-minimal.packages.txt).
--binary-indices disabled
Removing binary-indices (i.e. /var/lib/apt/lists/*) saves 6MiB on Etch @i386 (with just main and security enabled).
Purging /var/lib/apt/lists implies that anybody willing to install a package within DebianLive will have to run apt-get update first. (which one should, anyway! ).
lh_config --bootstrap-flavour minimal --packages-lists "minimal" --apt apt --binary-indices disabled --linux-flavours 486 --distribution etch --union-filesystem unionfs $LOCALOPTS lh_build
--debootstrap cdebootstrap
This option doesn't help shrinking the image size anymore (as of live-helper 1.0~a46-2).
The option --debootstrap cdebootstrap will instruct lh_build to use cdebootstrap instead of debootstrap. which used to be much more aggressive on package selection. We need to explicit list some package that wouldn't be installed otherwise. (Note : It's difficult to switching to cdebootstrap without removing aptitude).
lh_config --bootstrap cdebootstrap --bootstrap-flavour minimal --packages "bsdmainutils procps klogd netbase iputils-ping sysklogd ifupdown update-inetd tcpd dhcp3-client whiptail" --apt-recommends disabled --apt apt --tasksel none --linux-flavours 486 --distribution etch --union-filesystem unionfs $LOCALOPTS
Note to non US-keyboard users : you probably want to add the package console-common to the list (which will pull console-tools or kbd ).
--memtest disabled
You can save hundreds of KiB by removing memtest :
lh_config --memtest "disabled" [....] lh_build
--apt-recommends
You can fine-tune installed packages by preventing apt-get(8) from installing recommended dependencies.
lh_config --apt-recommends disabled [....] lh_build
Exclude packages
You can also explicitly ask not to include some packages :
lh_config [...] export LH_BOOTSTRAP_EXCLUDE="$LH_BOOTSTRAP_EXCLUDE vim-tiny,nano,ed" lh_build
This is mainly useful if you use a list (like minimal) with debootstrap, but you want to prune some of the software listed in those lists.(/usr/share/live-helper/lists/)
Extra hints
The hints listed here are not officially included/supported by live-helper.
No locales
If you don't need locales and UTF-8, you can save a lot of space. (actually the "stripped" hook deletes the files in /usr/share/locales/ anyway).
1. Tell lh_config that you want to install the package debconf-english 2. Use the variable LH_BOOTSTRAP_EXCLUDE to prevent the installation of locales and debconf-english-i18n 3. Create a script (01-removelocales.sh) to remove locales in case it's got installed :
lh_config --packages debconf-english --bootappend-live "nolocales" [YOUR_OTHER_OPTIONS_HERE] cat <<CHROOTLOCALHOOKS01 > config/chroot_local-hooks/01-removelocales.sh #!/bin/sh # Remove locales # (this could remove other applications. add "-y" if your are confident) apt-get remove locales --purge echo "don t fail on abort (set ERRORLEVEL to zero)" > /dev/null CHROOTLOCALHOOKS01 chmod +x "config/chroot_local-hooks/01-removelocales.sh" export LH_BOOTSTRAP_EXCLUDE="$LH_BOOTSTRAP_EXCLUDE locales,debconf-english-i18n" lh_build
then
remmeber to pass "nolocales" at bootprompt with --bootappend-live "nolocales" (which requires lenny's live-helper rather that etch's casper).
- Removing locales can save about 10MiB.
Squeeze
Recent versions of live-helper/live-config do not support 'nolocales' any more. The locale will default to 'en_US.UTF-8'.
Remove kernel from within squashfs file
The kernel is shipped twice on the final CD :
binary/live/vmlinuz1 (we need to keep this one)
chroot/boot/vmlinuz-2.6.22-2-686 (we don't need this one)
The easiest way is to tell squashfs not to include the /boot folder :
lh_config [YOUR_OTHER_OPTIONS_HERE] export MKSQUASHFS_OPTIONS="-e boot" lh_build
Delete arbitrary files
Some files are often "less" needed, let's delete some of them (YMMV).
lh_config [YOUR_OTHER_OPTIONS_HERE] cat <<CHROOTLOCALHOOKS02 > config/chroot_local-hooks/02-purge-some-modules.sh #!/bin/sh # delete the modules we won't need (YMMV) rm -Rf /lib/modules/*/kernel/drivers/isdn rm -Rf /lib/modules/*/kernel/drivers/media rm -Rf /lib/modules/*/kernel/drivers/net/wireless CHROOTLOCALHOOKS02 chmod +x "config/chroot_local-hooks/02-purge-some-modules.sh" lh_build
remove networking tools
You can add/remove the networking tools (YMMV). List or don't list the following packages --packages="netbase iputils-ping sysklogd update-inetd tcpd dhcp3-client"
Beyond
some ideas to save more space
- remove whiptail and reconfigure debconf :"debconf/frontend: Readline" .
- switch from bash to dash (-1.9MiB + 213KiB)
- replace vim-tiny with levee
- remove locales dependencies (liblocales-gettext-perl ; libtext*) (-400KiB)
- remove eject (-279KiB)
- remove bsdmainutils (-623KiB)
- remove networking (-1.6MiB)
- apt,gpg,debian-archive-keyring,libstdc++ (-10MiB)
- remove files that are actually in initramfs (initramfs-tools; busybox ; cpio )
- remove individual files (/lib/security/pam/?? /usr/share/consolefonts/? etc.)
Bad ideas :
Removing security with --security disabled --mirror-binary-security none --mirror-bootstrap-security is a bad idea. 1. The resulting system would be insecure. 2. The image will sometime fails to build, due to missing dependencies.
All in one script
i.e strip every thing off
The following scripts builds a 36Mib (on i386 ; Debian/Etch ; ISO ; etch-live-stripped-packages.txt)
The various hints used are listed below.
# Copyright 2007 Franklin Piat ; License GPL + LGPL #Some local options [ ! -d /srv/mini-live-helper ] && mkdir -p /srv/mini-live-helper cd /srv/mini-live-helper || exit 1 LOCALOPTS=" --mirror-binary http://ftp.fr.debian.org/debian/ --mirror-bootstrap http://ftp.fr.debian.org/debian/" LOCALOPTS=" --mirror-bootstrap http://192.168.0.10:9999/debian/ --mirror-chroot http://192.168.0.10:9999/debian/ --mirror-binary http://192.168.0.10:9999/debian/ --mirror-chroot-security http://security.eu.debian.org/ --mirror-binary-security http://security.eu.debian.org" #Let's configure live-helper lh_config --bootstrap-flavour minimal --packages-lists "stripped" --apt apt --apt-recommends disabled --tasksel none --binary-indices disabled --distribution etch --linux-flavours 686 --union-filesystem unionfs --packages "console-common console-tools klogd netbase iputils-ping sysklogd update-inetd tcpd dhcp3-client debconf-english" --memtest disabled --bootappend-live "nolocales" $LOCALOPTS #let's create some scripts cat <<CHROOTLOCALHOOKS01 > config/chroot_local-hooks/01-removelocales.sh #!/bin/sh # Remove locales # (this could remove other applications. add "-y" if your are confident) apt-get remove locales --purge apt-get remove dselect -y --purge echo "don t fail on abort (set ERRORLEVEL to zero)" > /dev/null CHROOTLOCALHOOKS01 chmod +x "config/chroot_local-hooks/01-removelocales.sh" cat <<CHROOTLOCALHOOKS02 > config/chroot_local-hooks/02-purge-some-modules.sh #!/bin/sh # delete the modules we won't need (YMMMV) rm -Rf /lib/modules/*/kernel/drivers/isdn rm -Rf /lib/modules/*/kernel/drivers/media rm -Rf /lib/modules/*/kernel/drivers/net/wireless CHROOTLOCALHOOKS02 chmod +x "config/chroot_local-hooks/02-purge-some-modules.sh" # We could exclude some unused stuffs. #export LH_BOOTSTRAP_EXCLUDE="vim-tiny,nano,ed" # exclude some stuffs from the squashfs root export MKSQUASHFS_OPTIONS="-e boot" nice ionice -c2 lh_build --debug
- There's a bug : "stripped" hook should remove dselect already !
