Add ipv6 hint
[linux_from_scratch_hints.git] / OLD / bootcd.txt
blobec48aa7e37148b428ad2b4eb42fcd45492b99fdb
1 TITLE:          Boot-CD
2 LFS VERSION:    All
3 AUTHOR:         Nicholas Dille <webmaster@rakshas.de>
5 SYNOPSIS:
6         How to create a bootcd from a working LFS system
8 HINT:
9 ver 1.4
10 25/07/2001
12 Contents
13 --------
15     0. Preface
16     1. Why create a boot cd
17     2. Kernel customization
18     3. LFS system preparation
19         3.1 Introduction
20         3.2 Linking /tmp and /var to harddisk
21              3.2.1 Handling of /tmp
22              3.2.2 Handling of /var
23         3.3 Linking /tmp and /var to ramdisk
24              3.3.1 Handling of /tmp
25              3.3.2 Handling of /var
26         3.4 Boot script(s)
27     4. Installation script
28     5. Creating a boot disk
29     6. Burning
30     7. Listings
31         7.1  /
32         7.2  /etc/init.d
33         7.3  /etc/rc0.d
34         7.4  /etc/rc1.d
35         7.5  /etc/rc2.d
36         7.6  /etc/rc3.d
37         7.7  /etc/rc4.d
38         7.8  /etc/rc5.d
39         7.9  /etc/rc6.d
40         7.10 /etc/rcS.d
41         7.11 /etc/inittab
42     8. History
45 1. Why create a boot cd
46    ---------------------
48     Although I'm not that long with LFS I already read several threads on lfs-
49     discuss about people having problems compiling certain parts of an LFS sys-
50     tem due to beta version of gcc or other important packages shipped with
51     their favorite distribution.
52     In addition I don't like the idea of installing a "commercial" distribution
53     in order to install a customized LFS system. That ain't right ;-)
55     So I figured that we should be able to create a bootable cd with some kind
56     of linux system on it which will provide a proper environment for the in-
57     stallation.
59     And what fits better than LFS itself? (I'll leave that one to you ...)
61     It also gives some clues about automatically starting the installation
62     which then is left to you to hack/figure out. But we should probably start
63     using alfs (to give them testers?).
65     So that's what it's all about.
68 2. Kernel customization
69    ---------------------
71     Since we are about to boot from a cd and use the cd image as root partition
72     we certainly need ISO9660 support compiled in. This part is absolutly vi-
73     tal!
74     When trying to mount the root partition the kernel does not have access to
75     any kind of modules (since they are on the root partition which is to be
76     mounted) so it has to rely on compiled-in support.
78     After the system has booted up we also want to partition our harddrive.
79     Therefore you should include any filesystems you might need during instal-
80     lation.
82     [So far I have not tested including those additional filesystems as module
83      but I guess that should work just fine]
86 3. LFS system preparation
87    -----------------------
89 3.1 Introduction
90     -------------
92     The major problem which arises when having a read-only root partition is
93     that some part of the system may be relying on writable access in certain
94     directories.
96     Let us have a quick look at the content of $LFS of a typical system:
98         drwxr-xr-x   2 root     root         1603 Oct 15 22:16 bin
99         drwxr-xr-x   4 root     root         4096 Dec  5 00:12 boot
100         drwxr-xr-x   8 root     root        44096 Feb 11 10:02 dev
101         drwxr-xr-x  45 root     root         5334 Feb 11 11:02 etc
102         drwxr-xr-x  13 root     root          250 Jan  9 00:39 home
103         drwxr-xr-x   5 root     root         1869 Jan  4 23:58 lib
104         drwxr-xr-x   5 root     root           95 Aug 27 22:12 mnt
105         dr-xr-xr-x  54 root     root            0 Feb 11 11:02 proc
106         drwx--x--x  20 root     root          679 Jan 30 17:27 root
107         drwxr-xr-x   5 root     root         5068 Jan  4 23:58 sbin
108         drwxrwxrwt   5 root     root          200 Feb 11 10:03 tmp
109         drwxr-xr-x  27 root     root          663 Dec 13 17:34 usr
110         drwxr-xr-x  26 root     root          541 Sep  5 23:53 var
112     The following directories should not cause any problems:
113         bin, boot, etc, lib, root, sbin, usr
114     [Need explanation why no problem?]
115     The content of those directories should be static and seldomly changed.
117     Mount points for other filesystems won't cause a problem because you can
118     mount a filesystem with writable access on a mount point in a read-only
119     filesystem. I guess the kernel keeps those mappings in memory and not in
120     the inodes.
121     That means we can cancel out problems caused by: dev, home, mnt, proc.
123     This leaves us with tmp and var.
126 3.2 Linking /tmp and /var to harddisk
127     ----------------------------------
129     So far I've always preferred this version since I intend to build a boot cd
130     that will be usable on almost every system including those with very little
131     ram.
134 3.2.1 Handling of /tmp
135       -----------------
137     As implied by the name /tmp is used for storing temporary data. Unfortuna-
138     tely this is not under our control whether this directory is used and,
139     therefore, needs some special handling.
141     Since there is no standardized structure for this place we can simply link
142     it to the tmp directory on the partition which we will use for instal-
143     lation.
145     For example, if you intend to compile you system in /lfs (which will then
146     be $LFS during the installation) you need to include a symlink for /tmp on
147     the CD pointing to /lfs/tmp.
148     If you decide for the symlink version of handling /tmp you will need to de-
149     cide which directory you will install in before burning the CD!
152 3.2.2 Handling of /var
153       -----------------
155     /var usually contains runtime or state stuff and may also be changed [is
156     that right? clumsily expressed?].
158     Since /var may contain mail spool directories, pid files and has a prede-
159     fined directory structure, we can't just link it onto our install partition
160     since that could be causing collisions with programs run in our chroot en-
161     vironment or perhaps even earlier.
163     Therefore we should tar /var and put it in / which you will do by executing
164     the following command in your CD root directory:
166         tar cfz var/ var.tar.gz
168     After bootup after we mounted our installation partition (let's say in
169     /lfs), we create a directory "whatever" and untar /var in "whatever".
171     The original /var should be a symlink to this directory, eg
172         var -> /lfs/whatever/var
175 3.3 Linking /tmp and /var to ramdisk
176     ---------------------------------
178     First of all we need to create the ramdisk which I did with the following
179     commands:
181         dd if=/dev/zero of=/dev/rd/0 bs=1k count=4096
182         mke2fs -m 0 /dev/rd/0
183         mount /dev/rd/0 /rd
185     Please feel reminded that you need to change the device name to the proper
186     name on your system. This was created using devfs!
188     The next two sub-chapters have hardly changed since /tmp and /var are
189     simply linked to /rd/tmp and /rd/var
192 3.3.1 Handling of /tmp
193       -----------------
195     Create a link in your root directory to point /tmp to /rd/tmp/.
197     During bootup you need to create the directory /rd/tmp/ for the link /tmp
198     to not point to nirvana.
201 3.3.2 Handling of /var
202       -----------------
204     Create a link in your root directory to point /var to /rd/var/.
205     You'll also need to create a tarball of your original /var and place it in
206     / which I described in 3.2.2.
208     During bootup you will need to unpack the tarball of /var in /rd.
211 3.4 Boot scripts
212     -------------
214     I stripped /etc/init.d and /etc/rc?.d off everything that is not absolutly
215     vital.
216     The only task left is loading a keymap.
218     Please refer to the directory listing (chapter 5) at the end of the docu-
219     ment.
222 4. Installation script
223    --------------------
225     This part is certainly up to you. You might want to include aLFS or some
226     compilation system which you have written yourself. Perhaps you will even
227     leave out this part and manually install the packages.
228     But anyway you will have to put the packages on the CD to have them handy
229     when you need them.
231     To give you an idea what my CD does: I put a script in /etc/init.d/install
232     which will be started from inittab during boot. This will ask the user some
233     important stuff, i.e. which partition to install on.
234     It will then startup the compilation.
236     You might even want to boot to a bash and leave out any kind of automatic
237     installation. This will happen if you pass an additional kernel parameter
238     from the bootloader "init=/bin/bash".
241 5. Creating a boot floppy
242    -----------------------
244     Although some of you might be tempted to ask whether I will now describe
245     the process to create a boot disk using grub I will not start an argument
246     about this. This is a question of belief ;-)
248     First you need to get grub from http://www.gnu.org and install it on your
249     system with the following commands:
251             ./configure --prefix=/usr &&
252             make &&
253             make install
255         a) You then create an ext2 filesystem on a disk.
256             (Please use an empty disk or be sure that you understand that you
257             will loose all your data on this disk. So much for the disclaimer)
259         b) Mount this disk to your favorite disk-mount-directory
260             (lets call it $FLOPPY)
262         c) Create /boot and /boot/grub on your floppy:
264                 mkdir -p $FLOPPY/boot/grub
266         d) Copy the grub boot loader onto the disk:
268                 cp /usr/share/grub/i386-pc/stage* $FLOPPY/boot/grub
270         e) Put your kernel in $FLOPPY/boot and call it "linux"
272         f) Start the grub shell by executing "grub"
274         g) Install grub on your boot disk (still in the grub shell):
276                 install (fd0)/boot/grub/stage1 (fd0) (fd0)/boot/grub/stage2
278         h) Now you need to create the file $FLOPPY/boot/grub/menu.lst with the
279             following content:
281                 default 0
282                 timeout 2
284                 title        template
285                 root (fd0)
286                 kernel (fd0)/boot/linux devfs=mount root=/dev/cdroms/cdrom0
288             If you do not use devfs, please remove "devfs=mount" from the last
289             line in menu.lst and replace "/dev/cdroms/cdrom0" with the name of
290             your cdrom device.
292     If you want to keep the resulting bootable cd as generic as possible you
293     do not need to worry about the cdrom device name since you will be able to
294     edit the menu entries of grub at boot time to reflect the underlying
295     system.
297     You are now ready to burn your LFS installation onto a CD which will be
298     able to boot using the cdrom.
301 6. Burning
302    --------
304     After creating a proper boot floppy with your custom kernel (see 2) put the
305     image in /boot.
306     To do this execute the following command in the root directory of your lfs
307     system:
309         dd if=/dev/floppy/0 of=boot/image bs=1024
311     The guys of you who are not using devfs will need to substitute
312     /dev/floppy/0 with /dev/fd0.
314     To burn the whole stuff on cd I used the following command:
316         mkisofs -rlDJLV "LFS" /lfscd -b boot/image -c boot/catalog \
317             | cdrecord -v -eject dev=/dev/cdroms/cdrom0 speed=4 -data -
319     Things to check:
321         a) Don't use -f. It causes symlinks to be ignored.
323         b) substitute dev=... with your cdrom device
326 7. Listing
327    --------
329 7.1  /
330      --
332         drwxr-xr-x   2 root  root    35 Feb  9 21:10 alfs
333         drwxr-xr-x   2 root  root  1250 Feb  9 20:10 bin
334         drwxr-xr-x   3 root  root   295 Feb 10 14:05 boot
335         drwxr-xr-x   3 root  root    54 Feb  9 17:33 dev
336         drwxr-xr-x  12 root  root   795 Feb 12 13:48 etc
337         drwxr-xr-x   2 root  root    35 Feb  9 17:33 home
338         drwxr-xr-x   3 root  root  2494 Feb  9 20:52 lib
339         drwxr-xr-x   2 root  root    35 Feb  9 17:33 mnt
340         drwxr-xr-x   2 root  root    35 Feb  9 17:33 proc
341         drwxr-x---   2 root  root    64 Feb  9 18:13 root
342         drwxr-xr-x   2 root  root  1272 Feb  9 20:10 sbin
343         lrwxrwxrwx   1 root  root     8 Feb 10 21:57 tmp -> alfs/tmp
344         drwxr-xr-x  14 root  root   346 Feb  9 20:10 usr
345         lrwxrwxrwx   1 root  root    14 Feb 10 21:57 var -> alfs/00-rw/var
346         -rw-r--r--   1 root  root  1043 Feb 10 21:56 var.tar.gz
349 7.2  /etc/init.d
350      ------------
352     This directory contains a new script "install" which goes through the in-
353     stallation procedure and should be specific for your setup.
355         -rwxr-xr--   1 root  root  1734 Jan 26 02:05 checkfs
356         -rwxr-xr--   1 root  root  1118 Jan 26 02:05 ethnet
357         -rwxr-xr--   1 root  root   867 Feb  2 02:46 fcron
358         -rwxr-xr--   1 root  root  4940 Jan 26 02:05 functions
359         -rwxr-xr--   1 root  root    83 Jan 26 02:05 halt
360         -rwxr-xr-x   1 root  root   988 Feb 12 13:51 install
361         -rwxr-xr--   1 root  root   200 Jan 26 02:05 loadkeys
362         -rwxr-xr--   1 root  root   725 Jan 26 02:05 localnet
363         -rwxr-xr--   1 root  root   355 Jan 26 02:05 mountfs
364         -rwxr-xr--   1 root  root  4219 Jan 26 02:05 rc
365         -rwxr-xr--   1 root  root   235 Jan 26 02:05 rcS
366         -rwxr-xr--   1 root  root   123 Jan 26 02:05 reboot
367         -rwxr-xr--   1 root  root   276 Jan 26 02:05 sendsignals
368         -rwxr-xr--   1 root  root   338 Jan 26 02:05 setclock
369         -rwxr-xr--   1 root  root  1062 Jan 26 02:05 sysklogd
370         -rwxr-xr--   1 root  root   696 Jan 26 02:05 template
371         -rwxr-xr--   1 root  root   234 Jan 26 02:05 umountfs
374 7.3  /etc/rc0.d
375      -----------
377         lrwxrwxrwx   1 root  root  21 Feb 12 13:44 S80sendsignals
378                                                     -> ../init.d/sendsignals
379         lrwxrwxrwx   1 root  root  14 Feb 12 13:44 S99halt -> ../init.d/halt
382 7.4  /etc/rc1.d
383      -----------
385     [empty]
388 7.5  /etc/rc2.d
389      -----------
391     [empty]
394 7.6  /etc/rc3.d
395      -----------
397     [empty]
400 7.7  /etc/rc4.d
401      -----------
403     [empty]
406 7.8  /etc/rc5.d
407      -----------
409     [empty]
412 7.9  /etc/rc6.d
413      -----------
415         lrwxrwxrwx 1 root  root   21 Feb 12 13:44 S80sendsignals
416                                                    -> ../init.d/sendsignals
417         lrwxrwxrwx 1 root  root   16 Feb 12 13:44 S99reboot -> ../init.d/reboot
419 7.10 /etc/rcS.d
420      -----------
422         lrwxrwxrwx 1 root  root   18 Jan 26 02:11 S30loadkeys
423                                                    -> ../init.d/loadkeys
426 7.11 /etc/inittab
427      -------------
429     Please note that I replaced the definition for an agetty on vc/1 with the
430     install script /etc/init.d/install which will only be run once (keyword
431     "once").
432     I also removed 4 of the 5 remaining agetty definitions since this installa-
433     tion will run automatically.
435         # Begin /etc/inittab
437         id:3:initdefault:
439         si::sysinit:/etc/init.d/rcS
441         l0:0:wait:/etc/init.d/rc 0
442         l1:S1:wait:/etc/init.d/rc 1
443         l2:2:wait:/etc/init.d/rc 2
444         l3:3:wait:/etc/init.d/rc 3
445         l4:4:wait:/etc/init.d/rc 4
446         l5:5:wait:/etc/init.d/rc 5
447         l6:6:wait:/etc/init.d/rc 6
449         ft:06:respawn:/sbin/sulogin
451         ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now
453         su:S1:respawn:/sbin/sulogin
454         1:2345:respawn:/sbin/agetty vc/1 9600
455         2:2345:respawn:/sbin/agetty vc/2 9600
457         # End /etc/inittab
460 8. History
461    --------
463     2001-07-25  released version 1.4:
464                 According to Gerard's suggestion I added a few lines describing
465                 how to get the boot image off the floppy and place it in the
466                 lfs tree for the boot cd.
467                 Corrections: - The most important was a fix to the instruction
468                                of creating a boot disk where i misspelled the
469                                command to install grub on the floppy.
470                              - I deleted/changed some instructions leftover
471                                from my original CD in 4 and 7.11
472                 Additions: - Added some further description to 3.2.1, 3.2.2
474     2001-06-22  released version 1.3:
475                 I added instructions to create a grub based boot disk.
477     2001-03-10  released version 1.2:
478                 After I got several mail from people asking for a new version
479                 of this howto with some hints how to create the cd with ram-
480                 disk support.
482     2001-02-12  released version 1.0