source: postlfs/config/bootdisk.xml@ 0290a023

10.0 10.1 11.0 11.1 6.0 6.1 6.2 6.2.0 6.2.0-rc1 6.2.0-rc2 6.3 6.3-rc1 6.3-rc2 6.3-rc3 7.10 7.4 7.5 7.6 7.6-blfs 7.6-systemd 7.7 7.8 7.9 8.0 8.1 8.2 8.3 8.4 9.0 9.1 basic bdubbs/svn elogind gnome kde5-13430 kde5-14269 kde5-14686 krejzi/svn lazarus nosym perl-modules qt5new systemd-11177 systemd-13485 trunk upgradedb xry111/intltool xry111/test-20220226
Last change on this file since 0290a023 was 0290a023, checked in by Randy McMurchy <randy@…>, 17 years ago

Indexed configuration files and bootscripts in the 'After LFS Configuration Issues' section

git-svn-id: svn:// af4574ff-66df-0310-9fd7-8a98e5e911e0

  • Property mode set to 100644
File size: 32.3 KB
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
3 "" [
4 <!ENTITY % general-entities SYSTEM "../../general.ent">
5 %general-entities;
8<sect1 id="postlfs-config-bootdisk" xreflabel="Creating a Custom Book Disk">
13<?dbhtml filename="bootdisk.html"?>
14<title>Creating a Custom Boot Disk</title>
17<title>Decent Rescue Boot Disk Needs</title>
18<para>This section is really about creating a <emphasis>rescue</emphasis>
19diskette. As the name <emphasis>rescue</emphasis> implies, the host
20system has a problem, often lost partition information or corrupted file
21systems, that prevents it from booting and/or operating normally. For
22this reason, you <emphasis>must not</emphasis> depend on resources from
23the host being "rescued". To presume that any given partition or hard
24drive <emphasis>will</emphasis> be available is a risky presumption.</para>
26<para>Heeding the warning, the rescue disk created here has no
27dependency on the host system's resources, other than basic bootability
28and hardware soundness. At a minimum, the most common sorts of failures
29requiring a rescue boot disk should be addressed by the contents of the
30boot disk. This would include the common loss of partitioning (master
31boot record is lost or corrupted), file system corruption, and the need
32to allow creation and editing of files that may have been lost or
33corrupted, possibly as an effect of the other two problems.</para>
35<para>Additional utilities should be available to search for text or
36files, copy, move and remove files, and many other normal operations
37that might be expected to be needed when reconstructing.</para>
41<title>This Minimal Decent Rescue Disk</title>
43<para>The intent here is to create a "rescue boot disk" that will support
44the common operations listed above. These functions are provided by
45including selected executables from <application><ulink
47</ulink></application> and <application><ulink
49A basic editor and rudimentary disk partitioning utility may also be
50optionally included.</para>
52<para>This, however, is not the limit. A minimal disk is described
53here, but you can add anything you can fit on the floppy. Furthermore,
54if one floppy is not enough to meet your needs, you can make a
55multi-diskette rescue set that means, essentially, the sky is the limit.
56This is discussed below. The number of other possible variations are
57just too numerous to mention here.</para>
61<title>Build the Rescue Boot Disk</title>
65<para>You should have known-good floppy diskettes available. Some
66people prefer to use the <command>fdformat</command> command to prepare
67these because it also does a verification. See the man page for more
68details. Another good idea is to always prepare duplicates of the
69rescue diskette. Media does deteriorate.</para>
71<para>These instructions presume a base <acronym>LFS</acronym> install
72using ext2/ext3 file systems.</para>
74<para>You need to have loopback device support enabled in your host's
75kernel to use this procedure.</para>
77<para>You should make a custom kernel that includes only those features
78needed to rescue your system, so it will have the least size. No
79sense in building in support for things like <application>XFree86</application>,
80<application>DRI</application>, etc, as most rescues are performed from the
81command prompt. Along the same lines, if you have <xref linkend="gcc2"/>, it
82is known to produce smaller kernels. So you might want to use that
83compiler for this kernel. If you do so, don't overlook any loadable
84modules (which are not addressed here) you might need - they need to be
85compiled with the same compiler used to make the kernel.</para>
87<para>The rescue image must include support for the file system of your
88choice (we presume ext2/3 here), ramdisk and initial ramdisk (initrd).
89Disable everything that you can in the kernel configuration. You should
90keep support for the proc file system and tempfs file system enabled
91because of their general utility. The proc file system is needed for
92the <command>mount</command> to report properly.</para>
94<para>If you install <emphasis>only</emphasis> the minimal set of
95components shown in this document, you will need a kernel that is 643 or
96fewer blocks in size. If you want the optional programs - a very basic
97editor, like <command>ed</command>, and rudimentary disk partitioning, like
98<command>sfdisk</command> - the kernel will need to be 595 or fewer blocks in
99size. This should not be a major problem unless your needs are fairly
100esoteric. On the system used to develop this version of the procedures, using
101only ext2 file systems and not using networking or <acronym>CD</acronym>s for
102recovery, the kernel image is only 481 blocks. And there may be more to gain - it has not been closely examined for additional gains.</para>
104<para>This kernel image will be called "rescueimage" hereinafter. You
105can actually name your image anything you like and just use its name
106instead in any commands that include "rescueimage".</para>
108<para>If you can not get your rescueimage down to the size needed to allow
109all you need on the ramdisk image, don't fret. You can always build a
110two diskette set, one boot and one root diskette. The kernel will prompt
111you to insert the root file system diskette. This will allow room for a
112compressed ramdisk image of 1440 blocks and a rescueimage of the same
115<para>The rescueimage size limits given above are likely to vary as
116local system-specific configurations change. Use them only as a
117guideline and not as gospel. The size of rescueimage as shown by
118<command>ls -sk</command> is only an approximation because of some
119"overhead". On the system used to develop this version of these
120procedures, that command shows 488 blocks but the actual number of
121blocks written is only 480 and a fraction, which means that 481 blocks
122are actually used.</para>
126<title>Rescue Disk Build Process</title>
128<para>The basic process will be:</para>
130<listitem><para>make a mount point for a file system</para></listitem>
131<listitem><para>make an empty file to hold the file system</para></listitem>
132<listitem><para>bind the empty file to a loopback device</para></listitem>
133<listitem><para>make a 4MB file system</para></listitem>
134<listitem><para>mount the file system</para></listitem>
135<listitem><para>add components to the file system</para></listitem>
136<listitem><para>make the compressed initrd</para></listitem>
137<listitem><para>join rescueimage and initrd onto a diskette</para></listitem>
140<para>The initial ramdisk will be automatically loaded at boot time if
141setup is done correctly.</para>
143<para><emphasis>Make a mount point and an empty file to hold a file
146<screen><userinput><command>mkdir -p /mnt/loop1
147dd if=/dev/zero of=/tmp/rfloppy bs=1k count=4096</command></userinput></screen>
149<para><emphasis>Command explanations</emphasis></para>
151<para><command>dd</command>: This is a generalized input-to-output copy
152utility that also has many transformation capabilities.</para>
154<para><parameter>if=/dev/zero</parameter>: This parameter assigns
155<command>dd</command>'s input file to a device that returns an infinite
156stream of zeroes.</para>
158<para><parameter>of=/tmp/rfloppy</parameter>: This parameter directs
159<command>dd</command>'s output to <filename>/tmp/rfloppy</filename>.</para>
161<para><parameter>bs=1k count=4096</parameter>: These parameters tell
162<command>dd</command> to read and write in "chunks" of 1024 bytes and
163process 4096 "chunks".</para>
165<para><emphasis>Bind the file to a loopback device, make a file system and mount it.</emphasis></para>
167<para>The reason these commands are used is that they work regardless of
168the version of <command>mount</command> (older ones don't have the
169<userinput>-o loop</userinput> option) or if <filename>/etc/mtab</filename>
170is symlinked to <filename class="directory">/proc</filename> (which causes mount to be
171unable to properly "unbind" a loop device, due to "lost" information).
172An alternate set of commands is provided, after these three commands,
173that you can use if you don't have either of these situations.</para>
175<screen><userinput><command>losetup /dev/loop1 /tmp/rfloppy
176mke2fs -m 0 -N 504 /dev/loop1
177mount -t ext2 /dev/loop1 /mnt/loop1</command></userinput></screen>
179<para><emphasis>Command explanations</emphasis></para>
181<para><command>losetup /dev/loop1 /tmp/rfloppy</command>: This
182command "binds" a loopback device to the empty file.</para>
184<para><command>mke2fs -m 0 -N 504 /dev/loop1</command>: This
185command makes an ext2 file system on the loopback device (which really
186means it is created in the file to which the loopback device is bound)
187and reserves no blocks. The <userinput>-N 504</userinput> parameter causes
188only 504 inodes to be allocated, leaving more space for other things needed
189in the file system.</para>
191<para><command>mount -t ext2 /dev/loop1 /mnt/loop1</command>: This
192mounts the file system just created, just as if it were a real device,
193like a hard drive or diskette. This allows all the normal system I/O
194commands to operate as if a real device were present.</para>
196<para>If your <command>mount</command> supports the
197<option>-o loop</option> option <emphasis>and</emphasis> your
198<filename>/etc/mtab</filename> is a real file, rather than a symlink to
199<filename class="directory">/proc</filename>, the three above commands can be replaced
200by these next two commands.</para>
202<screen><userinput><command>mke2fs -F -m 0 -N 504 /tmp/rfloppy
203mount -o loop /tmp/rfloppy /mnt/loop1</command></userinput></screen>
205<para><emphasis>Command explanations</emphasis></para>
207<para><command>mke2fs -F -m 0 -N 504 /tmp/rfloppy</command>: As before,
208a file system is made, with only 504 inodes and no reserved blocks, that
209will be bound to a loopback device. The <userinput>-F</userinput> parameter
210just suppresses an irritating question issued when
211<command>mke2fs</command> realizes that you are not accessing a
214<para><command>mount -o loop /tmp/rfloppy /mnt/loop1</command>: This
215command tells <command>mount</command> to bind the named file to a
216loopback device it automatically selects (the first available) and mount
217the device on <filename class="directory">/mnt/loop1</filename>.</para>
219<para><emphasis>Add components to the file system</emphasis></para>
221<para><emphasis>A cautionary note:</emphasis> if you are not running in a
222<command>chroot</command> environment, be sure that you do not accidentally
223omit the <filename class="directory">/mnt/loop1</filename> reference in the commands. If
224you do so, you might replace the equivalent components on your host with
225the components that are installed by these procedures. Even if you are
226in a chroot environment, you may need to be careful if the environment
227is your freshly built <acronym>LFS</acronym> system which you intend to
228use as a host in the future.</para>
230<para>First, to have as much free space as possible, remove the
231<filename>lost+found</filename> directory, which is not needed because
232it is only used by <command>fsck</command>. Since <command>fsck</command>
233will never be run on this file system, it is unneeded.</para>
235<screen><userinput><command>rmdir /mnt/loop1/lost+found/</command></userinput></screen>
237<para>Now make a minimal set of directories.</para>
239<screen><userinput><command>mkdir /mnt/loop1/{dev,proc,etc,sbin,bin,lib,mnt,usr,var}</command></userinput></screen>
241<para>Add needed device files to the initrd image. If you use devfs,
242the following command works well, as you only have the devices you use
245<screen><userinput><command>cp -dpR /dev/* /mnt/loop1/dev</command></userinput></screen>
247<para>If you used <command>MAKEDEV</command> to create your devices on
248your host, you'll want to use something similar to this longer command,
249to minimize wasting space with unneeded inodes.</para>
251<para><emphasis>You must modify this to suit your rescueimage configuration and
252other needs.</emphasis> For example, you may need
253<acronym>SCSI</acronym> devices and may not need
254frame buffer devices or the pseudo-terminal directory. Also, the number
255of hard drives and partitions that you include should be the minimal
256that you need. Extensive analysis has not been done on the list below,
257so there are more inodes and space to be gained by "fine tuning" this
260<screen><userinput><command>mkdir /mnt/loop1/dev/pts
261cp -a \
262 /dev/null /dev/console \
263 /dev/fb[0-7] /dev/fd /dev/fd0 /dev/fd0h1440 /dev/full \
264 /dev/hda* /dev/hdb* /dev/hdc* /dev/hdd* /dev/initctl /dev/kmem \
265 /dev/loop[0-3] /dev/lp0 /dev/mem /dev/port \
266 /dev/psaux /dev/ram \
267 /dev/ram0 /dev/ram1 /dev/ram2 /dev/ram3 /dev/random /dev/rtc \
268 /dev/shm /dev/stderr /dev/stdin /dev/stdout /dev/tty \
269 /dev/tty[0-9] /dev/ttyS0 /dev/ttyS1 /dev/urandom /dev/zero \
270 /mnt/loop1/dev</command></userinput></screen>
272<para><emphasis>What is needed in the <filename class="directory">/etc</filename>
275<para>If you choose, you can copy all or selected parts of your
276<filename>/etc/passwd</filename> and <filename>/etc/group</filename>
277files. But even if each is less than 1024 bytes, you will lose two
278inodes and two blocks of space on the initial ramdisk. This only really
279matters because of trying to squeeze everything onto a 1.44MB
280diskette. Every little bit helps. The strategy taken here is to create
281these two files as part of the rescue boot and initialization process.
282The commands that make the two files will be embedded inside the
283<filename>rcS</filename> script that <filename>linuxrc</filename>
284(really <application><ulink
286</ulink></application>) invokes after the initrd is
287loaded. This way no more inodes or blocks are used on the
288diskette to carry these files.</para>
290<para>Some might like to copy their <filename class="directory">/etc/rc*</filename>
291directory into the ramdisk image, but this may have no value, other
292than archival use, in a worst-case recovery scenario. If you want
293automatic initialization of the system after repair, they may have some
294value. But few people need or want this to happen. If the file system
295on the hard drives are corrupted, what good will mount scripts do? Some
296scripts may be useful, like access to a network to copy over backup data
297when the hard drive's file systems are usable again. The point is that
298you should copy only the parts that you can use because space is at a
299premium on the diskette.</para>
301<para>Here, only the <filename>fstab</filename> will be included. This
302is handy because it eases mounting of partitions that may be useful and
303also can be examined and used as a guide as to what is available and
304what may need reconstruction. Because it may be larger than needed, you
305should edit it to remove any useless entries and minimize commentary.
306No other editing is needed because the boot scripts are not included and
307no automatic mounting will be done using the <filename>fstab</filename>.
308If you decide to include some boot scripts that might try to mount
309things, change the <filename>fstab</filename>'s entries to
310<command>noauto</command> in the options field so they don't cause an
311attempt to mount a potentially corrupt partition. Copy it to
312<filename class="directory">/tmp</filename>, edit it as desired and then:</para>
314<screen><userinput><command>cp -a /tmp/fstab /mnt/loop1/etc</command></userinput></screen>
316<para>Now the initialization script will be added. As mentioned above,
317<command>linuxrc</command> is symlinked to <application><ulink
320After the kernel and initial ramdisk have been loaded, the kernel gives
321control to <command>linuxrc</command> (<application><ulink
323</ulink></application>). It wants to run an <filename class="directory">/etc/init.d/rcS</filename>
324script to do any initial setup.</para>
326<para>If you use devfsd, you will need to set up the
327<filename>rcS</filename> script to handle the devfsd startup. Put the
328following commands in <filename class="directory">/mnt/loop1/etc/init.d/rcS</filename>.
329You may also want to add some of the processes shown in the non-devfs
330version that follows.</para>
333mount -t devfs devfs /dev
334/sbin/devfsd /dev</userinput></screen>
336<para>If you don't use devfsd, but created a static <filename
338directory using <command>MAKEDEV</command>, or any similar process, the
339<filename>rcS</filename> script will do slightly different things.
340Also, don't forget that it is creating the
341<filename>/etc/passwd</filename> and <filename>/etc/group</filename>
342files, thus saving space on the diskette.</para>
344<para>The script made next will mount <filename class="directory">/proc</filename>, turn
345on swap (no harm is done if it fails), make the
346<filename>/etc/passwd</filename> and <filename>/etc/group</filename>
347files, create a log directory and turn on swapping. Create the script
350<screen><userinput><command>mkdir -p /mnt/loop1/etc/init.d
351cat &gt;/mnt/loop1/etc/init.d/rcS &lt;&lt; EOD</command>
353mount -t proc proc /proc
354swapon -a
356echo "root:x:0:0:root:/root:/bin/bash" &gt; /etc/passwd
358<command>cat &gt; /etc/group &lt;&lt;EOF</command>
372chmod 644 /etc/passwd /etc/group</command>
374mkdir /var/log
377chmod u+x /mnt/loop1/etc/init.d/rcS</command></userinput></screen>
379<para>Unless you add a lot to this script, which <emphasis>is</emphasis>
380encouraged, the above should be reasonably close to what you need.</para>
382<para><emphasis>Install packages</emphasis></para>
384<para>There are two packages that must be installed. The <application><ulink
386package incorporates the core functions that provide a shell and many
387basic utilities. A file system package, like <application><ulink
388url="">e2fsprogs</ulink></application>, or
389a package for the file system you are using, will provide a minimal
390set of utilities for file system checking and reconstruction. The whole
391package will not be installed, but only certain needed components.</para>
393<para>If you use devfsd, you will also need to install that software.</para>
395<para>Install <application><ulink
397into the initial ramdisk image. Busybox incorporates many Unix utility
398program functions into a single small executable file.</para>
400<screen><userinput><command>make &amp;&amp;
401make PREFIX=/mnt/loop1 install &amp;&amp;
402&gt; /mnt/loop1/var/utmp</command></userinput></screen>
404<para>A <filename>var/utmp</filename> is made because <application><ulink
406needs it for the reboot command to work properly. If this file doesn't
407exist when <application><ulink
409is started, the reboot command will not work. This would be a bad thing
410for people that have no reset button available to them.</para>
412<para>If you use devfs to create devices on the fly and free up precious
413inodes on the floppy, you'll also install devfsd to facilitate the
414devices that <application><ulink
416expects to find. Use the following commands to do the install.</para>
418<screen><userinput><command>mv GNUmakefile Makefile &amp;&amp;
419make &amp;&amp;
420make PREFIX=/mnt/loop1 install</command></userinput></screen>
422<para><emphasis>Install part of <application>e2fsprogs</application></emphasis></para>
424<para>If you use the ext2 or ext3 (journaling) file system, you can use
425the commands below to install the minimal functionality that should
426allow you to get your hard drives usable again. If you use ext3, keep in
427mind that it is a part of the <application>e2fsprogs</application>
428package and you can get the components, which are mostly hard links,
429from the same places shown below. If you use some other file system,
430such as reiserfs, you should apply the <emphasis>principals</emphasis>
431you see here to install parts of that package instead.</para>
434mkdir build &amp;&amp;
435cd build &amp;&amp;
436../configure --prefix=/mnt/loop1/usr --with-root-prefix="" \
437 --disable-swapfs --disable-debugfs \
438 --enable-dynamic-e2fsck --disable-nls --disable-evms \
439 --disable-rpath &amp;&amp;
440make LDFLAGS="$LDFLAGS" &amp;&amp;
441strip -p --strip-unneeded --remove-section=.comment \
442 -o /mnt/loop1/sbin/mke2fs misc/mke2fs &amp;&amp;
443strip -p --strip-unneeded --remove-section=.comment \
444 -o /mnt/loop1/sbin/e2fsck e2fsck/e2fsck &amp;&amp;
445chmod 555 /mnt/loop1/sbin/{mke2fs,e2fsck}
448<para><emphasis>Two useful utilities</emphasis></para>
450<para>There are two very useful utilities that any rescue disk should
451have, to help in faster and more accurate recovery. The first is a
452partitioning utility. The <command>sfdisk</command> program is
453used here because of its small size and great power. Be warned though -
454it is not what is considered to be "user friendly". But the
455<command>fdisk</command> and <command>cfdisk</command> programs are
456substantially larger or require more shared objects, like <application>ncurses
459<para>The second utility is an editor. Most graphical editors are
460inherently too large and also require additional shared objects. For
461this reason, <command>ed</command> is used here. It is small, requires
462no additional shared objects and is a regex-based editor that is the
463ancestor to almost all subsequent editors that support regex-based
464editing, whether graphical or not. It is a "context editor" and offers
465powerful, but non-graphical, editing features. There are many other
466editors that may be suitable - feel free to use one of them instead.</para>
468<para>Read the <application>busybox</application>
469<filename>INSTALL</filename> and <filename>README</filename> files to
470see how to include a <command>vi</command> editor. It has not been
471investigated here yet, so it may or may not easily fit onto a single
472diskette image such as is made here.</para>
474<para>You can install these or not, but it is important for you to have
475some capability such as these offer. Exactly how you would install the
476utilities you choose will have to be determined by you.</para>
478<para><command>Sfdisk</command> and <command>ed</command> are installed
479by, essentially, copying them from your host. Strip is used, just to
480assure that they carry no "excess baggage", even though the base
481<acronym>LFS</acronym> install should have stripped them already. Use
482the following commands:</para>
484<screen><userinput><command>strip -p --strip-unneeded --remove-section=.comment \
485 -o /mnt/loop1/sbin/sfdisk /sbin/sfdisk
486strip -p --strip-unneeded --remove-section=.comment \
487 -o /mnt/loop1/bin/ed /bin/ed
488chmod 555 /mnt/loop1/sbin/sfdisk /mnt/loop1/bin/ed</command></userinput></screen>
490<para>Also, keeping in mind your space limitations, copy any other
491binaries and libraries you need to the image. Use the
492<command>ldd</command> command to see which libraries you will need to
493copy over for any executables. Don't forget to also strip them
494<emphasis>before</emphasis> copying them to the ramdisk image or use the
495<command>strip</command>, as above, to "copy" them.</para>
497<para><emphasis>Set up the lib directory</emphasis></para>
499<para>Once you have installed all the utilities from above and any
500additional ones you want, use the <command>ldd</command> command, as
501mentioned above, on those that were not listed in this document. If
502any additional libraries are needed, add them into the setup commands
503shown next.</para>
505<para>If you installed only those things shown above, the shared objects
506needed will be minimal. You can add them to the ramdisk image with:</para>
508<screen><userinput><command>strip -p --strip-unneeded --remove-section=.comment \
509 -o /mnt/loop1/lib/ /lib/ &amp;&amp;
510strip -p --strip-unneeded --remove-section=.comment \
511 -o /mnt/loop1/lib/ /lib/ &amp;&amp;
512strip -p --strip-unneeded --remove-section=.comment \
513 -o /mnt/loop1/lib/ /lib/ &amp;&amp;
514chmod 555 /mnt/loop1/lib/{,,}</command></userinput></screen>
516<para>Note that the above commands change the names of the libraries,
517eliminating the need for the usual symlinks. If you add any additional
518shared objects, be alert for similar opportunities and also the pitfalls
519that may be present.</para>
521<para><emphasis>Make the compressed initrd</emphasis></para>
523<para>Unmount the loopback file. If you used <command>mount</command>'s
524<option>-o loop</option> option, the "bond" between the loop device
525and the file will be removed when the unmount is done. Just omit the
526<command>losetup -d /dev/loop1</command> from the following
527sequence. The <userinput>-9</userinput> parameter is used with
528<command>gzip</command> to make the smallest possible compressed image. To
529make sure it will fit on the diskette, list the file's size.</para>
531<screen><userinput><command>umount /mnt/loop1 &amp;&amp;
532losetup -d /dev/loop1 &amp;&amp; # Omit if mount's -o loop was used
533gzip -9 &lt; /tmp/rfloppy &gt; /tmp/rootfs.gz
534ls -l /tmp/rootfs.gz</command></userinput></screen>
536<para><emphasis>Join rescueimage and initrd onto a diskette</emphasis></para>
538<para>Now the rescueimage and initial ramdisk image will be written to
539the boot diskette. Before doing this, calculate the number of blocks
540needed for rescueimage and for <filename>/tmp/rootfs.gz</filename>
541(the initial ramdisk), individually, by dividing each
542size by 1024 and adding one if there is any remainder. Add these two
543results together. They must total 1,440 or fewer blocks. If they total
544more than this, don't worry too much. Changes to make a two-diskette
545set are presented later. Of course, you could reexamine your choices and
546try to shrink either the rescueimage or the initial ramdisk image.</para>
548<para>To make a single-floppy rescue, using devfs, use the following
549commands. If you use the static <filename class="directory">/dev</filename> setup, use
550<filename>/dev/fd0</filename> instead of the /dev/floppy/0.</para>
552<screen><userinput><command>dd if=rescueimage of=/dev/floppy/0 bs=1k
553rdev /dev/floppy/0 0,0
554rdev -R /dev/floppy/0 0</command></userinput></screen>
556<para><emphasis>Command explanations</emphasis></para>
558<para><command>rdev /dev/floppy/0 0,0</command>: sets the root file system
559the kernel will use when it boots. Because it loads an initrd, it will
560automatically set that as the root device, initially. So, the
561<option>0,0</option> gives it "no value", telling the kernel to not
562mount any other device. Some folks give <filename>/dev/fd0</filename> or
563something similar. But this has effect <emphasis>only</emphasis> when
564<command>linuxrc</command> (really <application><ulink
566</ulink></application>) exits and the normal <command>init</command>
567processes get invoked. Since this is not being done here, and the floppy
568is <emphasis>not</emphasis> a valid file system, it would be useless
569here. A hard drive would be a better choice if you are looking to
570automatically bring the system up after repair. Since <application><ulink
572</ulink></application> provides the <command>reboot</command> command,
573automatic initialization is not needed.</para>
575<para>The <command>rdev -R /dev/floppy/0 0</command> will set the
576"root flags" to zero. They have no use in this application.</para>
578<para>The <command>dd</command> from above showed some results, like</para>
580<screen> 480+1 records in
581 480+1 records out</screen>
583<para>In this example the rescueimage (kernel) was 480+1 blocks in size.
584Make sure that this number, which may be different for you, matches your
585calculations from above. You need to calculate a "magic number" now
586that will be inserted into rescueimage. The value consists of three
587significant parts. Two are discussed here. The third is touched upon
590<para>Bits 0 - 10 will contain the size of rescueimage, in blocks,
591that you calculated above, and which should match the results from the
592dd above. Bit 14 (the 15th bit, which is 2 to the 14th power, or 16,384)
593is a flag that, when set to 1, tells the kernel an initial ramdisk is to
594be loaded. So for the single-floppy rescue diskette, the two numbers
59516,384 and 481 (or whatever number is right for your rescueimage size) are
596added together to produce a decimal value, like 16865. This value is
597inserted into the proper place in rescueimage by the
598<command>rdev</command> command done next.</para>
600<para>Insert the "magic number" into rescueimage and then write the
601root file system right after rescueimage on the floppy by executing the
602following commands, with the proper numbers inserted. Notice that the
603<command>seek</command> parameter's number must be the size, in blocks,
604of your rescueimage. If you use the static <filename class="directory">/dev</filename>
605setup, use <filename>/dev/fd0</filename> in the commands below, instead
606of <filename>/dev/floppy/0</filename>.</para>
608<screen><userinput><command>rdev -r /dev/floppy/0 <replaceable>16865</replaceable>
609dd if=/tmp/rootfs.gz of=/dev/floppy/0 bs=1k seek=<replaceable>481</replaceable></command></userinput></screen>
611<para>In this command, <command>seek</command> was used to position to
612the block following the end of the rescueimage (480+1) and begin writing the
613root file system to the floppy.</para>
618<title>A Two-diskette Rescue Setup</title>
620<para>If you just can't live with a single-diskette rescue system, here
621is what to do to make a simple two-diskette system. Note that the
622endless possibilities presented by the availability of
623<command>linuxrc</command> and other components are not addressed
624here. Here you will just use the kernel's ability to prompt for a second
625diskette that contains the initrd image and load it.</para>
627<para>Modify the above instructions as follows. First a different magic
628number is needed. The 15th bit (bit 14) still needs to be set, but the
629size of the rescueimage, in blocks, is replaced with a zero. The third
630component, which was not discussed above, is now used. This is the 16th
631bit (bit 15) of the "magic number". When set, it tells the kernel to ask
632the user to insert the "root" floppy. It then loads the initrd image
633from that diskette. Because the size of the rescueimage was replaced
634by zero, the kernel starts loading from the "zero'th" block (the first
635one) on the second diskette.</para>
637<para>The 16th bit (bit 15) represents 2 raised to the 15th power, or
63832,768. So the new magic number is 32,768 + 16384, which is 49,152. This
639value tells the kernel to prompt for, and then load, an initial ramdisk
640image from the first block on the inserted floppy. So your first
641modification is to the command to write the "magic number" to the rescueimage
642image on the diskette.</para>
644<screen><userinput><command>rdev -r /dev/floppy/0 <replaceable>49152</replaceable></command></userinput></screen>
646<para>Note that the initrd image is <emphasis>not</emphasis> copied to
647the diskette yet. Remove the boot diskette and insert another diskette
648that will hold your root file system. Run this modified command (don't
649forget to use <filename>/dev/fd0</filename> if you don't use devfs).
650Note that no <command>seek</command> parameter is used.</para>
652<screen><userinput><command>dd if=/tmp/rootfs.gz of=/dev/floppy/0 bs=1k</command></userinput></screen>
654<para>That's all there is to it. The possibilities from here are limited only
655by your imagination and tenacity in pursuing enhancements. And your
656willingness to research available documentation. A good starting point
657is the "Documentation" directory in your kernel source tree. More help
658may be gained at
659<ulink url=""><acronym>LFS </acronym> Hints</ulink>
660(please use a mirror site that is suitable) and
661<ulink url="">TLDP</ulink>.</para>
Note: See TracBrowser for help on using the repository browser.