Differences between revisions 27 and 48 (spanning 21 versions)
Revision 27 as of 2013-06-18 20:18:12
Size: 6647
Editor: LukeFaraone
Comment: Advising people to remove copyright files is bad.
Revision 48 as of 2019-05-07 10:44:25
Size: 11648
Editor: GurkanMyczko
Comment: fix typo
Deletions are marked like this. Additions are marked like this.
Line 4: Line 4:
It may be useful to reduce the size of the installation footprint on Embedded systems, or on older computers or laptops with limited drive space, or in cases where a small installation is preferred. It may be useful to reduce the size of the installation footprint on Embedded systems, or on older computers or laptops with limited drive space, or in cases where a small installation is preferred. Minimal systems in general also carry security benefits because fewer packages means that there are fewer security exploits available.
Line 8: Line 8:
== Removing non-critical packages ==

 * Except essential packages {{{aptitude search '!?essential'}}}, you can remove what you don't need.
== Remove non-critical packages ==

 * Except essential packages ({{{aptitude search '?essential'}}}  or {{{dpkg-query -Wf '${Package;-40}${Essential}\n' | grep yes}}}), you can remove what you don't need.
Line 14: Line 14:
 * acpi
 * acpid
 * aptitude
 * at
 * aspell
 * aspell-en
 *
avahi-daemon    * base-config
 *
bash-completion    * bc
 *
bin86    * bind9-host    * ca-certificates
 * console-common
 * console-data
 * console-tools
 * cupsys-client Not needed by cups
 * cupsys-bsd Not needed by cups
 * cupsys-driver-gutenprint Not needed by cups
 * cupsys-pdf Not needed by cups
 * dc
 *
debian-faq    * debian-faq-de    * debian-faq-fr    * debian-faq-it    * debian-faq-zh-cn    * dhcp DHCP Client
 * dhcp3-client DHCP Client
 * dhcp3-common DHCP Client
 * dictionaries
 * dnsutils
 *
doc-debian Debian Project Documentation
 * doc-linux-text Linux How To and FAQ Documents
 * eject Eject compact disks
 * fdutils Floppy Disk Utilities
 * file Determines file type
 * finger
 *
foomatic-filters Not needed by cups
 * gcc-3.3
 *
gettext-base    * groff Additional files to supplement groff-base
 * gnupg
 *
gnu-efi Extensible Firmware Support
 * grub Grand Unified Boot Loader
 * hplip Not needed by cups
 * iamerican
 *
ibritish    * info
 * ispell
 *
laptop-detect Tool to detect whether system is being used on a laptop
 * libavahi-compat-libdnssd1 This is required by cups
 * libc6-amd64 Not recommended for generic 486 machines using generic IA32 architecture
 * libc6-i686 Not recommended for generic 486 machines using generic IA32 architecture
 * libgpmg1    * manpages
 * mtools
 *
mtr-tiny Full screen traceroute
 * mutt
 * nano Free Pico clone
 * netcat
 * net-tools
 *
ncurses-term Additional terminal type definitions
 * openssh-client    * openssh-server    * openssl
 * pidentd
 * ppp Point to Point Protocol
 *
pppconfig A text menu for configuring PPP
 * pppoe PPP over ethernet driver
 * pppoeconf Configures PPP/ADSL connections
 * read-edid Information collection for plug and play monitors
 * reportbug Debian Bug Reporting Tool
 * smclient Not needed by cups
 * ssh
 * tasksel An initial installation tool
 * tcsh C Shell
 * traceroute
 * usbutils
 *
vim-common Alternative vi editor engine
 * vim-tiny An alternative vi editor
 * wamerican    * w3m Terminal Based World Wide Web Browser
 * whois    * zeroinstall-injector  
 * DebianPkg:acpi
 * DebianPkg:acpid
 * DebianPkg:aptitude TUI package manager
 * DebianPkg:at
 * DebianPkg:aspell
 * DebianPkg:aspell-en
 * DebianPkg:
avahi-daemon
 * DebianPkg:
bash-completion
 * DebianPkg:bc Cli calculator
 * DebianPkg:
bin86
 * DebianPkg:
bind9-host
 * DebianPkg:ca-certificates
 * DebianPkg:console-common
 * DebianPkg:console-data
 * DebianPkg:console-tools
 * DebianPkg:dc
 * DebianPkg:
debian-faq
 * DebianPkg:
debian-faq-de
 * DebianPkg:
debian-faq-fr
 * DebianPkg:
debian-faq-it
 * DebianPkg:
debian-faq-zh-cn
 * DebianPkg:
dhcp DHCP Client
 * DebianPkg:dhcp3-client DHCP Client
 * DebianPkg:dhcp3-common DHCP Client
 * DebianPkg:dictionaries
 * DebianPkg:dnsutils
 * DebianPkg:
doc-debian Debian Project Documentation
 * DebianPkg:doc-linux-text Linux How To and FAQ Documents
 * DebianPkg:eject Eject compact disks
 * DebianPkg:fdutils Floppy Disk Utilities
 * DebianPkg:file Determines file type
 * DebianPkg:finger
 * DebianPkg:
foomatic-filters Not needed by cups
 * DebianPkg:gettext-base
 * DebianPkg:
groff Additional files to supplement groff-base
 * DebianPkg:gnupg GNU privacy guard
 * DebianPkg:
gnu-efi Extensible Firmware Support
 * DebianPkg:grub Grand Unified Boot Loader
 * DebianPkg:hplip Not needed by cups
 * DebianPkg:iamerican
 * DebianPkg:
ibritish
 * DebianPkg:info
 * DebianPkg:ispell
 * DebianPkg:
laptop-detect Tool to detect whether system is being used on a laptop
 * DebianPkg:libavahi-compat-libdnssd1 This is required by cups
 * DebianPkg:libc6-amd64 Not recommended for generic 486 machines using generic IA32 architecture
 * DebianPkg:libc6-i686 Not recommended for generic 486 machines using generic IA32 architecture
 * DebianPkg:libgpmg1
 * DebianPkg:manpages
 * DebianPkg:mtools
 * DebianPkg:
mtr-tiny Full screen traceroute
 * DebianPkg:mutt
 * DebianPkg:nano Terminal text editor
 * DebianPkg:netcat
 * DebianPkg:net-tools
 * DebianPkg:
ncurses-term Additional terminal type definitions
 * DebianPkg:openssh-client
 * DebianPkg:
openssh-server
 * DebianPkg:openssl
 * DebianPkg:pidentd
 * DebianPkg:ppp Point to Point Protocol
 * DebianPkg:
pppconfig A text menu for configuring PPP
 * DebianPkg:pppoe PPP over ethernet driver
 * DebianPkg:pppoeconf Configures PPP/ADSL connections
 * DebianPkg:read-edid Information collection for plug and play monitors
 * DebianPkg:reportbug Debian Bug Reporting Tool
 * DebianPkg:smclient Not needed by cups
 * DebianPkg:ssh
 * DebianPkg:tasksel An initial installation tool
 * DebianPkg:tcsh C Shell
 * DebianPkg:traceroute
 * DebianPkg:unzip
 * DebianPkg:usbutils
 * DebianPkg:
vim-common Alternative vi editor engine
 * DebianPkg:vim-tiny An alternative vi editor
 * DebianPkg:wamerican
 * DebianPkg:
w3m Terminal Based World Wide Web Browser
 * DebianPkg:whois
 * DebianPkg:
zeroinstall-injector
 * DebianPkg:zip
Line 101: Line 97:
busybox (This is currently required by the kernel due to a dependency bug)

=== Replace packages with smaller equivalents ===

 * Replace packages with smaller equivalents :
  * DebPkg:debconf-english (replaces debconf-il8n)
  * DebPkg:levee (replaces nvi and vim-tiny)
  * DebPkg:lpr replaces lpr-ng or CUPS)
  * DebPkg:madplay (replaces mpg123, mpg321 and mp3-decoder)
  * DebPkg:mutt (replaces GUI MailUserAgent: Evolution, Thunderbird)
  * DebPkg:setmixer (replaces aumix)
  * DebPkg:slrn, DebPkg:tin (replaces GUI Usenet NewsReader)
  * DebPkg:irssi (replaces GUI IRC clients)
  * DebPkg:jed, DebPkg:xjed (replaces Emacs)
  * DebPkg:w3m, DebPkg:lynx, DebPkg:links (replaces GUI WebBrowser)
  * DebPkg:dash (replaces bash, this currently breaks)
 * DebianPkg:busybox (This is currently required by the kernel due to a dependency bug)


{{{
# Remove non-critical packages (don't remove busybox -> don't sure if this ist still a problem on debian 7)
# ~i -> list all installed packages
# !~M -> don't list automatic installed packages
# !~prequired -> don't list packages with priority required
# !~pimportant -> don't list packages with priority important
# !~R~prequired -> don't list dependency packages of required packages
# !~R~pimportant -> don't list dependency packages of important packages
# !~R~R~prequired -> don't list dependency packages of dependency packages of required packages -.- (two levels should be enough. Have not found a recursive option)
# !~R~R~pimportant -> ... required packages
# !busybox -> don't list busybox
# !grub -> don't list grub (we need a boot manager. If LILO or something else is used change this)
# !initramfs-tools -> don't list initramfs-tools (else the kernel is gone)

apt-get purge $(aptitude search '~i!~M!~prequired!~pimportant!~R~prequired!~R~R~prequired!~R~pimportant!~R~R~pimportant!busybox!grub!initramfs-tools' | awk '{print $2}')
apt-get purge aptitude
apt-get autoremove
apt-get clean
}}}

== Reconfigure apt so that it does not install additional packages ==

Add the following entries to the /etc/apt/apt.conf configuration file:

APT::Install-Recommends "0" ;
APT::Install-Suggests "0" ;

== Replace packages with smaller equivalents ==

 * Replace packages with smaller equivalents :
  * DebianPkg:debconf-english (replaces debconf-il8n)
  * DebianPkg:levee (replaces nvi and vim-tiny)
  * DebianPkg:lpr replaces lpr-ng or CUPS)
  * DebianPkg:madplay (replaces mpg123, mpg321 and mp3-decoder)
  * DebianPkg:mutt (replaces GUI !MailUserAgent: Evolution, Thunderbird)
  * DebianPkg:alsa-utils (replaces DebianPkg:pavucontrol)
  * DebianPkg:slrn, DebianPkg:tin (replaces GUI Usenet !NewsReader)
  * DebianPkg:irssi (replaces GUI IRC clients)
  * DebianPkg:jed, DebianPkg:xjed (replaces Emacs)
  * DebianPkg:w3m, DebianPkg:lynx, DebianPkg:links (replaces GUI !WebBrowser)
  * DebianPkg:dash (replaces bash, this currently breaks)

== Remove unwanted files at install time ==

Unwanted files, like most of the files from the following sections, can be removed at install time by using dpkg filters, see [[DebianMan:1/dpkg|dpkg(1)]] --path-exclude and --path-include options.

== Remove unnecessary packages in general ==

DebianPkg:Apt has an inbuilt feature to remove files that are no longer required by your system. Run the following command to remove unnecessary packages:

{{{
# apt autoremove
}}}

Unfortunately, apt does not always manage to find and purge all unused files. This can be a problem particularly when a program has been installed outside of apt (such as with `make install`). Therefore, the best solution to removing unnecessary packages is to not install them in the first place.

DebianPkg:deborphan is a useful package for finding any other unnecessary packages in the system. To find such packages run:

{{{
deborphan --guess-all
}}}

Be careful when removing suggested packages, as they may have package dependencies that may still required by your system.

Packages can be deleted manually if needed be and you know what you are doing. Just be sure to know exactly what is being removed by checking the packages information:

{{{
apt show <package name>
}}}

When removing packages, make sure to [[https://wiki.debian.org/DontBreakDebian#Don.27t_blindly_remove_software|not break Debian!]]
Line 126: Line 179:
Note: See the dpkg filters.
Line 128: Line 183:
  With appropriate privileges, it is possible to remove the foreign man pages as follows: With appropriate privileges, it is possible to remove the foreign man pages as follows:
Line 134: Line 189:
  Note: There is also a purgelocales package that will remove the man pages, but that destroys the package management and package building system.

== Reconfigure apt so that it does not install additional packages ==

Add the following entries to the /etc/apt/apt.conf configuration file:

APT::Install-Recommends "0" ;
APT::Install-Suggests "0" ;


== Rebuilding packages using the Tiny C Compiler ==

Note: See the dpkg filters.
Line 148: Line 194:
== Remove unnecessary cups dependencies ==

  During installation of DebPkg:cupsys, the Debian installer may attempt to drag in unnecessary package dependencies. The cupsys daemon can function without these optional components, and they can be deselected from installation:
  * DebPkg:cupsys-client
  * DebPkg:cupsys-bsd
  * DebPkg:cupsys-driver-gutenprint
  * DebPkg:cupsys-pdf
  * DebPkg:foomatic-filters
  * DebPkg:hplip
  * DebPkg:smclient

== SBuild a smaller kernel using fewer options ==

== Build a smaller kernel using fewer options ==
Line 166: Line 202:

create `/etc/initramfs-tools/conf.d/compress` with the content
{{{
COMPRESS=xz
}}}
Line 184: Line 225:
 * /lib/xtables/libip6t_DNAT.so
 * /lib/xtables/libip6t_DNPT.so
 * /lib/xtables/libip6t_MASQUERADE.so
 * /lib/xtables/libip6t_NETMAP.so
 * /lib/xtables/libip6t_REDIRECT.so
 * /lib/xtables/libip6t_SNAT.so
 * /lib/xtables/libip6t_SNPT.so
Line 189: Line 237:
/!\ The gain is extremely minor, and there's no much point in doing this.
Line 193: Line 243:

= See Also =
 * [[DebianLive/HowTo/SmallSizeImage]]
== Use busybox built-ins instead of full packages ==
You can use the tiny busybox tools instead of installing full packages. Run ''busybox'' to see which applets are available. ''man busybox'' gives you details on each applets and which parameters are supported. e.g. ''busybox df'' starts the df applet from busybox.

=== Add busybox less to the Debian Alternatives System as pager ===
[[DebianAlternatives|Debian Alternatives System]] doesn't link to two words like "busybox less". If you just create a symbolic link in /usr/local/bin (''ln -s /bin/busybox /usr/local/bin/less'') then every time you call less, busybox less will be started since ''echo $PATH''
 /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
The solution is to create a shell script named busybox.less that calls "busybox less $@".
{{{
cd /usr/local/bin
echo /bin/busybox less \$\@ >busybox.less
chmod +x busybox.less
echo 'export PAGER="pager" >>/etc/profile
#pager without -s because busybox less doesn't support -s (--squeeze-blank-lines), default is "pager -s"
update-alternatives --install /usr/bin/pager pager /usr/local/bin/busybox.less 40 \
          --slave /usr/share/man/man1/pager.1.gz pager.1.gz /usr/share/man/man1/busybox.1.gz
update-alternatives --config pager #activate "busybox less" manually
}}}


== Rebuilding packages using the Tiny C Compiler ==
Rebuilding packages using the Tiny C Compiler does not reduce size of packages. [[http://www.landley.net/hg/tinycc/raw-file/bf5b2827a4a4/www/differences.html|Differences between tcc and gcc]]

== Compress binaries/libraries using UPX ==
If they don't reside on btrfs with transparent filesystem compresssion on.
Do this with care, some systems are not supported by UPX, and some binaries break.
See: https://packages.debian.org/upx-ucl

Reducing the size of the Debian Installation Footprint

It may be useful to reduce the size of the installation footprint on Embedded systems, or on older computers or laptops with limited drive space, or in cases where a small installation is preferred. Minimal systems in general also carry security benefits because fewer packages means that there are fewer security exploits available.

Remove non-critical packages

  • Except essential packages (aptitude search '?essential' or dpkg-query -Wf '${Package;-40}${Essential}\n' | grep yes), you can remove what you don't need.

The following packages are non-critical and can be removed:

The following packages cannot be removed, even though marked as optional:

  • busybox (This is currently required by the kernel due to a dependency bug)

# Remove non-critical packages (don't remove busybox -> don't sure if this ist still a problem on debian 7)
# ~i -> list all installed packages
# !~M -> don't list automatic installed packages
# !~prequired -> don't list packages with priority required
# !~pimportant -> don't list packages with priority important
# !~R~prequired -> don't list dependency packages of required packages
# !~R~pimportant -> don't list dependency packages of important packages
# !~R~R~prequired -> don't list dependency packages of dependency packages of required packages -.- (two levels should be enough. Have not found a recursive option)
# !~R~R~pimportant -> ... required packages
# !busybox -> don't list busybox
# !grub -> don't list grub (we need a boot manager. If LILO or something else is used change this)
# !initramfs-tools -> don't list initramfs-tools (else the kernel is gone)

apt-get purge $(aptitude search '~i!~M!~prequired!~pimportant!~R~prequired!~R~R~prequired!~R~pimportant!~R~R~pimportant!busybox!grub!initramfs-tools' | awk '{print $2}')
apt-get purge aptitude
apt-get autoremove
apt-get clean

Reconfigure apt so that it does not install additional packages

Add the following entries to the /etc/apt/apt.conf configuration file:

APT::Install-Recommends "0" ; APT::Install-Suggests "0" ;

Replace packages with smaller equivalents

  • Replace packages with smaller equivalents :

Remove unwanted files at install time

Unwanted files, like most of the files from the following sections, can be removed at install time by using dpkg filters, see dpkg(1) --path-exclude and --path-include options.

Remove unnecessary packages in general

Apt has an inbuilt feature to remove files that are no longer required by your system. Run the following command to remove unnecessary packages:

# apt autoremove

Unfortunately, apt does not always manage to find and purge all unused files. This can be a problem particularly when a program has been installed outside of apt (such as with make install). Therefore, the best solution to removing unnecessary packages is to not install them in the first place.

deborphan is a useful package for finding any other unnecessary packages in the system. To find such packages run:

deborphan --guess-all

Be careful when removing suggested packages, as they may have package dependencies that may still required by your system.

Packages can be deleted manually if needed be and you know what you are doing. Just be sure to know exactly what is being removed by checking the packages information:

apt show <package name>

When removing packages, make sure to not break Debian!

Remove unnecessary locale files

The introduction of LanguagePacks (tdebs) may also help in reducing the size of the installation footprint.

  • It is recommended that the number of locale configurations installed is kept to a minimum. By limiting the number of locale files built you can save 90% of the space taken up by storing these systems on your system and saves the compilation time for building the locale settings for each package. A side effect or reducing the number of locale options is that the compilation of the glibc library gets a lot faster.

  • ToDo: complete this section

Note: See the dpkg filters.

Remove foreign language man files

With appropriate privileges, it is possible to remove the foreign man pages as follows:

rm -rf /usr/share/man/??
rm -rf /usr/share/man/??_*

Note: See the dpkg filters.

Remove unnecessary kernel modules

Build a smaller kernel using fewer options

Reduce the size of the X installation footprint

  • You can remove the packages xserver-xorg-video-* that you don't use. you should still keep xserver-xorg-video-vesa.

Reduce the size of the initramfs

create /etc/initramfs-tools/conf.d/compress with the content

COMPRESS=xz

Remove unnecessary ipv6 files

If you are using only [ipv4] internally, then the following [ipv6] files can be removed:

  • /lib/xtables/libip6t_ah.so
  • /lib/xtables/libip6t_dst.so
  • /lib/xtables/libip6t_eui64.so
  • /lib/xtables/libip6t_frag.so
  • /lib/xtables/libip6t_hbh.so
  • /lib/xtables/libip6t_hl.so
  • /lib/xtables/libip6t_HL.so
  • /lib/xtables/libip6t_icmp6.so
  • /lib/xtables/libip6t_ipv6header.so
  • /lib/xtables/libip6t_LOG.so
  • /lib/xtables/libip6t_mh.so
  • /lib/xtables/libip6t_REJECT.so
  • /lib/xtables/libip6t_rt.so
  • /lib/xtables/libip6t_DNAT.so
  • /lib/xtables/libip6t_DNPT.so
  • /lib/xtables/libip6t_MASQUERADE.so
  • /lib/xtables/libip6t_NETMAP.so
  • /lib/xtables/libip6t_REDIRECT.so
  • /lib/xtables/libip6t_SNAT.so
  • /lib/xtables/libip6t_SNPT.so

Remove /etc/alternatives

If your applications have been mapped using traditional methods, then it is possible to remove the /etc/alternatives directory.

/!\ The gain is extremely minor, and there's no much point in doing this.

Replace the getty processes with the ngetty single process daemon

The getty processes can be replaced by the ngetty single process daemon to reduce virtual memory utilization:

Use busybox built-ins instead of full packages

You can use the tiny busybox tools instead of installing full packages. Run busybox to see which applets are available. man busybox gives you details on each applets and which parameters are supported. e.g. busybox df starts the df applet from busybox.

Add busybox less to the Debian Alternatives System as pager

Debian Alternatives System doesn't link to two words like "busybox less". If you just create a symbolic link in /usr/local/bin (ln -s /bin/busybox /usr/local/bin/less) then every time you call less, busybox less will be started since echo $PATH

  • /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

The solution is to create a shell script named busybox.less that calls "busybox less $@".

cd /usr/local/bin
echo /bin/busybox less \$\@ >busybox.less
chmod +x busybox.less
echo 'export PAGER="pager" >>/etc/profile
#pager without -s because busybox less doesn't support -s (--squeeze-blank-lines), default is "pager -s"
update-alternatives --install /usr/bin/pager pager /usr/local/bin/busybox.less 40 \
          --slave /usr/share/man/man1/pager.1.gz pager.1.gz /usr/share/man/man1/busybox.1.gz
update-alternatives --config pager #activate "busybox less" manually

Rebuilding packages using the Tiny C Compiler

Rebuilding packages using the Tiny C Compiler does not reduce size of packages. Differences between tcc and gcc

Compress binaries/libraries using UPX

If they don't reside on btrfs with transparent filesystem compresssion on. Do this with care, some systems are not supported by UPX, and some binaries break. See: https://packages.debian.org/upx-ucl