Thursday, May 03, 2007
Trimming down etch to ~100 MB
The basic recepie:
- sudo debootstrap etch etch/ ftp://ftp.ee.debian.org/debian
- sudo chroot etch
- apt-get install localepurge
- apt-get --purge remove dselect aptitude dhcp3-client dhcp3-common info man-db manpages dmidecode laptop-detect
- apt-get install grub initrd-tools linux-image-686 ssh python-minimal
- mkdir /boot/grub; update-grub
- apt-get clean
- APT cache:
6.4M /var/cache/apt/pkgcache.bin
6.4M /var/cache/apt/srcpkgcache.bin
19M /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_etch_main_binary-i386_Packages
3.6M /var/lib/dpkg/info
internationalization:
6.9M /usr/share/i18n
4.9M /usr/lib/gconv
documentation:
8.2M /usr/share/doc
4.7M /usr/share/man
zoneinfo:
5.6M /usr/share/zoneinfo
kernel modules:
44M lib/modules/2.6.18-4-686/kernel - time for cleanup:
- vi /etc/apt/sources.list, comment everything out. This will temporarily disable apt
- apt-get update
- rm /usr/share/i18n/{charmaps,locales}/*
- rm -rf /usr/lib/gconv # or at least
for i in IBM INIS EBCDIC MAC ISO- ISO_ KOI JOHAB CP BIG5 EUC ECMA ARM ASM GEOR GOST GREEK LATIN NATS GB SJIS; do rm /usr/lib/gconv/${i}*; done - rm -rf /usr/share/{doc,man}/*
- boot into the system and check what modules are actually in use with lsmod, remove the modules you don't need (e.g. who needs sound in a router? or even better, build your own kernel):
rm -rf /lib/modules/2.6.18-4-686/kernel/sound
rm -rf /lib/modules/2.6.18-4-686/kernel/drivers/isdn
rm -rf /lib/modules/2.6.18-4-686/kernel/drivers/net/wireless
rm -rf /lib/modules/2.6.18-4-686/kernel/drivers/media
rm -rf /lib/modules/2.6.18-4-686/kernel/drivers/scsi/pcmcia
version=2.6.18-4-686
depmod -a -F /boot/System.map-$version $version
update-initramfs -u # to check that nothing is broken
# other redundant modules:
/lib/modules/2.6.18-4-686/kernel/net/{ax25,ipx,x25,ipv6,appletalk,atm,bluetooth,decnet,econet,irda}
/lib/modules/2.6.18-4-686/kernel/fs/{reiserfs,smbfs,qnx4,xfs,befs,bfs,affs,afs,coda,cifs,freevxfs,hfs,hfsplus,hpfs,ocfs2,nfs,nfs_common,nfsd,ncpfs,ufs,udf}
# remove modules that you don't need from (spacehogs):
# /lib/modules/2.6.18-4-686/kernel/drivers/net
# /lib/modules/2.6.18-4-686/kernel/drivers/scsi
rm /lib/modules/2.6.18-4-686/kernel/drivers/scsi/sata*.ko
rm -rf /lib/modules/2.6.18-4-686/kernel/drivers/scsi/aic7xxx* - we are down to 97M now:
97M / - configure timezone, hosts, hostname, network interfaces, fstab, name resolver:
- tzconfig
- echo '127.0.0.1 localhost' > /etc/hosts # see http://www.howtoforge.com/perfect_setup_debian_etch_p3 for IPv6
- echo 'my.hostname' > /etc/hostname
- vi /etc/network/interfaces
iface lo inet loopback
... - vi /etc/fstab
#
proc /proc proc defaults 0 0
/dev/hda2 none swap sw 0 0/dev/hda1 / ext3 defaults,errors=remount-ro 0 1 - vi /etc/resolv.conf
nameserver x.x.x.x - set root password or add an ordinary user and install sudo
passwd - disable IPv6 if you don't need it
- boot target with Knoppix, tomsrtbt or whatever other rescue tools you have
- create a parition for the new system, mkfs, mount and cd to target root
- transfer the filesystem:
nc -lp 5555 | tar xf - # in target system
cd etch; sudo tar cf - . | nc target 5555 - In target: chroot .; grub-install /dev/hda OR if you are unable to run grub from the target, create a grub floppy:
- dd if=/boot/grub/stage1 of=/dev/fd0 bs=512
dd if=/boot/grub/stage2 of=/dev/fd0 bs=512 seek=1 - in grub shell:
root (hd0,0)
kernel /vmlinuz root=/dev/hda1 ro
initrd /initrd.img
boot - when booted into target, run grub install
if proc is not mounted, grub will complain Could Not Find Device For /boot,
mount proc /proc
cp /proc/mounts /etc/mtab
grub-install /dev/hda - ready, reboot target
- update-locale LC_ALL=C LANG=C
- setup /etc/iftab
- update-alternatives --set editor /usr/bin/vim.tiny
- apt-get install sudo; visudo
# or user ALL=(ALL) NOPASSWD: ALL
%admin ALL=(ALL) ALL