source: postlfs/config/bootdisk.xml@ 69e0f0f

10.0 10.1 11.0 11.1 11.2 11.3 12.0 12.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 kea ken/TL2024 ken/inkscape-core-mods ken/tuningfonts krejzi/svn lazarus lxqt nosym perl-modules plabs/newcss plabs/python-mods python3.11 qt5new rahul/power-profiles-daemon renodr/vulkan-addition systemd-11177 systemd-13485 trunk upgradedb v5_0 v5_0-pre1 v5_1 v5_1-pre1 xry111/intltool xry111/llvm18 xry111/soup3 xry111/test-20220226 xry111/xf86-video-removal
Last change on this file since 69e0f0f was 03973ca6, checked in by Larry Lawrence <larry@…>, 21 years ago

convert bootdisk to use sect2

git-svn-id: svn://svn.linuxfromscratch.org/BLFS/trunk/BOOK@1040 af4574ff-66df-0310-9fd7-8a98e5e911e0

  • Property mode set to 100644
File size: 5.9 KB
Line 
1<sect1 id="postlfs-config-bootdisk">
2<?dbhtml filename="bootdisk.html" dir="postlfs"?>
3<title>Creating a custom bootdisk</title>
4
5<sect2>
6<title>How to create a decent bootdisk</title>
7<para>The intent here is to create a "rescue bootdisk" that will load
8enough 'linux' to enable you to do rescue operations. What is presented here
9is enough to do file manipulation, mounting and unmounting, and other tasks.
10This, however, is not the limit. The minimal disk is described here, and you
11can add anything you can fit on the floppy.</para>
12</sect2>
13
14<sect2>
15<title>Boot Disk/Rescue Disk</title>
16
17<para>First we will create a loopback file on which we build the root file
18system for our rescue disk image. This is commonly known as the initial
19ramdisk, or initrd for short, and it is automatically loaded by the boot
20process if all setup is done correctly.</para>
21
22<para>Next we'll make a file system on the loopback file and use
23<command>mount</command> to mount the loopback file as a regular disk, allowing
24us to read and write files there. The following commands will build us a 4 MB
25image.</para>
26
27<screen><userinput><command>dd if=/dev/zero of=/tmp/rfloppy bs=1k count=4096 &amp;&amp;
28mke2fs -m 0 -N 2000 /tmp/rfloppy &amp;&amp;
29mount -o loop /tmp/rfloppy /mnt/loop1 &amp;&amp;
30rmdir /mnt/loop1/lost+found/</command></userinput></screen>
31
32<para>Now that we have a file mounted and usable, let's prepare it to be
33filled with useful material. Since this is only a rescue floppy we'll
34only need to set up the minimum directories.</para>
35
36<screen><userinput><command>mkdir /mnt/loop1/{dev,proc,etc,sbin,bin,lib,mnt,usr,var}</command></userinput></screen>
37
38<para>Next, we will set up the device files. I use devfs on my system, so
39the following command works well, as I only have the devices I use
40anyway. If you used <command>MAKEDEV</command> to create your devices, you'll
41want to trim the <filename>/mnt/loop1/dev</filename> directory to reclaim the
42inode space wasted by the devices you don't use in the <filename>dev</filename>
43directory.</para>
44
45<screen><userinput><command>cp -dpR /dev/* /mnt/loop1/dev</command></userinput></screen>
46
47<para>Now to tend to the <filename>/etc</filename> directory. To start, all we
48will do is use the passwd and group file that worked for our static chroot
49environment when we built <acronym>LFS</acronym>. We'll also copy the startup scripts over and a
50few other files that serve well as starting points.</para>
51
52<screen><userinput><command>cp -ax /etc/rc* /mnt/loop1/etc
53cp -ax /etc/fstab /mnt/loop1/etc
54echo "root:x:0:0:root:/root:/bin/bash" &gt; /mnt/loop1/etc/passwd
55cat &gt; /mnt/loop1/etc/group &lt;&lt; "EOF"</command>
56root:x:0:
57bin:x:1:
58sys:x:2:
59kmem:x:3:
60tty:x:4:
61tape:x:5:
62daemon:x:6:
63floppy:x:7:
64disk:x:8:
65lp:x:9:
66dialout:x:10:
67audio:x:11:
68<command>EOF</command></userinput></screen>
69
70<para>To prevent automatic mounting of hard drive partitions, make sure to add
71the noauto option in their fstab entry. Also, add the following entries to the
72<filename>/mnt/loop1/etc/fstab</filename> to assist with mounting our
73floppy and the ram image</para>
74
75<screen><userinput>/dev/ram0 / ext2 defaults
76/dev/fd0 / ext2 defaults</userinput></screen>
77
78<para>Next, we will install <ulink
79url="http://www.busybox.net/downloads/busybox-0.60.4.tar.bz2">busybox</ulink>
80onto the image. Busybox incorporates many of the unix functions into a single
81small executable file.</para>
82
83<screen><userinput><command>make &amp;&amp;
84make PREFIX=/mnt/loop1 install &amp;&amp;
85cp -ax /var/utmp /mnt/loop1/var &amp;&amp;
86mkdir /mnt/loop1/var/log</command></userinput></screen>
87
88<para>Also, keeping in mind your space limitations, copy any other binaries and
89libraries you need to the image. Use the <userinput>ldd</userinput> command to
90see which libraries you will need to copy over for any executables.</para>
91
92<para>Now, since I use devfs to create devices on the fly and free up precious
93inodes on the floppy, we'll also install devfsd to facilitate the
94devices that busybox expects to find.</para>
95
96<screen><userinput><command>mv GNUmakefile Makefile &amp;&amp;
97make &amp;&amp;
98make PREFIX=/mnt/loop1 install &amp;&amp;
99cp /lib/libc.so.6 /lib/ld-linux.so.2 /lib/libdl.so.2 /tmp &amp;&amp;
100strip --strip-deb /tmp/ld-linux.so.2 /tmp/libc.so.6 /tmp/libdl.so.2 &amp;&amp;
101mv /tmp/ld-linux.so.2 /tmp/libc.so.6 /tmp/libdl.so.2 /mnt/loop1/lib/</command></userinput></screen>
102
103<para>We will also need to set up an rc script to handle the devfsd startup.
104Put this in <filename>/mnt/loop1/etc/init.d/rcS</filename>.</para>
105
106<screen><userinput>#!/bin/sh
107mount -t devfs devfs /dev
108/sbin/devfsd /dev</userinput></screen>
109
110<para>Next create your compressed root filesystem. We use -9 with gzip to
111make the smallest possible compressed image.</para>
112
113<screen><userinput><command>umount /mnt/loop1 &amp;&amp; dd if=/tmp/rfloppy bs=1k | gzip -v9 > rootfs.gz</command></userinput></screen>
114
115<para><userinput><command>ls -l rootfs.gz</command></userinput> to make
116sure it will fit on the diskette.</para>
117
118<para>Make a custom kernel that is optimized for size. Include only those
119features you will need to rescue your system. no sense in building in support
120for things like xfree86 dri, etc, as most rescues are performed from the
121command prompt.</para>
122
123<screen><userinput><command>dd if=rescueimg of=/dev/floppy/0 bs=1k</command>
124 429+1 records in
125 429+1 records out
126<command>rdev /dev/floppy/0 /dev/floppy/0
127rdev -R /dev/floppy/0 0</command></userinput></screen>
128
129<para>In this example the rescueimage (KERNEL) was 429+1 blocks in size.
130We will remember this for the next command. We now write the root file
131system right after the kernel on the floppy by doing 16384+429+1=
13216814.</para>
133
134<screen><userinput><command>rdev -r /dev/floppy/0 16814
135dd if=rootfs.gz of=/dev/floppy/0 bs=1k seek=430</command></userinput></screen>
136
137<para>In this command we use seek to find the end of the kernel (429+1) and write the root file system to the floppy.</para>
138</sect2>
139</sect1>
Note: See TracBrowser for help on using the repository browser.