1 TITLE: LFS for small hard drives
3 AUTHOR: James Smaby <jsmaby@virgo.umeche.maine.edu>
6 The recommended LFS partition size is 1GB. By following
7 this hint, that number can be 300MB, and possibly lower.
8 So if you're on a 486, or want to compile LFS in RAM,
12 Much more space is needed to build LFS than is needed for the
13 final system. There used to be a general rule that once you're past
14 glibc, you're all set, but now gcc-3 is a similarly high hurdle.
15 Note that gcc-2.95.3-2, used in LFS-3.3, is smaller, and in some
16 people's opinions, better than gcc-3, and using it might be a good
17 idea for people low on disk space. You'll need about 300MB of disk
18 space available to LFS, less if you use gcc-2 and don't install
19 the locales. The disk space doesn't all have to be physical. You can
20 stick some things on a tmpfs if you have spare RAM, or just really
21 need the space. Indeed, you can build an LFS entirely in RAM if
22 you have more than about 350MB, using:
23 mount tmpfs -t tmpfs -o size=300m $LFS
24 You can also save quite a bit of space if the sources for glibc
25 and glibc are already unpacked and on a cdrom.
27 First off, the default compiler options of "-O2 -g" make large
28 binaries/object files. Assuming you won't need debugging information
29 in the system's executables/libraries, the following environment
30 variables should be set (these are conservative; -march=i686 will
31 help, but might break glibc/gcc/binutils).
33 export CFLAGS="-Os -fomit-frame-pointer -s"
34 export BOOT_CFLAGS="$CFLAGS"
36 For chapter 5, build gcc-3 first, as it's the biggest package.
37 Depending on available space, you may want to delete some of the
39 rm -rf libjava libobjc gcc/ada gcc/f gcc/java gcc/objc
40 Using make bootstrap uses extra space, and if you have a trustworthy
41 compiler on your host, bootstrap is unneeded.
43 After completing chapter 5, make a minimal static by running
45 mkdir -p $LFS/minimal/bin
46 mkdir -p `echo $LFS/static/lib/gcc-lib/*/*/include | sed s/static/minimal/`
47 # Copy over only the files used by building a chapter 6.
48 # These were found using find -anewer
49 cp -a $LFS/static/bin/{ar,as,awk,basename,bash,bzip2,cat,cc,chmod,\
50 chown,cmp,cp,cpp,cut,date,diff,dirname,du,echo,egrep,env,expr,fgrep,\
51 find,fold,gawk,gcc,grep,gunzip,gzip,head,hostname,install,install-info,\
52 ld,ln,ls,make,makeinfo,mkdir,mknod,mount,mv,nl,nm,objdump,od,pwd,\
53 ranlib,readelf,rm,rmdir,sed,sleep,sort,strip,tail,tar,touch,tr,true,\
54 uname,uniq,wc,whoami,xargs,zcat} $LFS/minimal/bin
55 cp -a $LFS/static/lib/gcc-lib/*/*/{cc1,collect2,cpp0,crtbegin.o,crtbeginS.o,\
56 crtbeginT.o,crtend.o,crtendS.o,libgcc.a,specs} $LFS/minimal/lib/*/*/*
57 cp -a $LFS/static/lib/gcc-lib/*/*/include/{float.h,limits.h,stdarg.h,
58 stdbool.h,stddef.h,stdio.h,syslimits.h} $LFS/minimal/lib/*/*/*/include
59 # Strip any unneeded symbols from binaries
60 strip $LFS/minimal/bin/* $LFS/minimal/lib/*/*/*/{cc1,collect2,cpp0}
61 # Strip debugging symbols from object files
62 strip -g $LFS/minimal/lib/*/*/*/*.*
63 # Use bash builtins for some commands
64 echo -e '#!/bin/bash\n echo $@' > $LFS/minimal/bin/echo
65 echo -e '#!/bin/bash\n pwd' > $LFS/minimal/bin/pwd
66 echo -e '#!/bin/bash\n sleep $@' > $LFS/minimal/bin/sleep
67 echo -e '#!/bin/bash\n' > $LFS/minimal/bin/true
68 echo -e '#!/bin/bash\n echo root' > $LFS/minimal/bin/whoami
69 If all goes well, "du -sh $LFS/minimal" should produce 35M. That's all
70 you need of a chapter 5 to build a chapter 6. Replace the old static:
72 mv $LFS/minimal $LFS/static
74 After entering chroot, you lose your environment variables. Reset
77 export CFLAGS="-Os -fomit-frame-pointer -s"
78 export CXXFLAGS="$CFLAGS"
79 export BOOT_CFLAGS="$CFLAGS"
81 On to the first hurdle, glibc. Really the only thing you can do
82 that I've found is add "--enable-omitfp --enable-kernel=2.4.19" to
83 the configure line. After it's built, you should be getting awfully
84 close to 300MB. Relieve a little stress by killing libc_g.a:
86 We don't care about debugging, so this (25MB!) file isn't needed.
87 Now "make install" should have room. Run the following commands
89 strip /{usr/,}{lib/*so,sbin/*,bin/*}
92 bzip2 /usr/share/info/*info*
93 If you really, _really_ need them, you can install the locales, but
94 they eat up precious space.
96 Okay, onto gcc. If you're using gcc-2, then you're fine, and can
97 just go on to do the rest of the LFS. We'll need some tweaking for gcc-3.
98 Note that installing man-pages is preferably done after gcc to save
99 about 6MB for the gcc build. First, delete some of the bigger unneeded
101 rm -rf libjava libobjc gcc/ada gcc/f gcc/java gcc/objc
102 There won't be enough room (to stay under 300MB) to do a bootstrap compile,
103 so just type "make". This has the advantage that it takes quite a bit
104 less time to compile :-) You may need to do some preliminary stripping
106 strip gcc/{cc1,cc1plus}
107 find . -name *.so -exec strip {} \;
109 Things may start getting a little tight when building perl; compressing
110 the man and info pages should be enough to make room:
111 bzip2 -d /usr/share/info/*.bz2
112 bzip2 /usr/share/info/*info*
113 bzip2 /usr/share/man/man?/*.?
115 Now you can get busy stripping down your fresh LFS to make room for
119 Unsubscribe: send email to listar@linuxfromscratch.org
120 and put 'unsubscribe hints' in the subject header of the message