Changeset 35fd1edf


Ignore:
Timestamp:
09/03/2002 02:58:17 AM (20 years ago)
Author:
Larry Lawrence <larry@…>
Branches:
10.0, 10.1, 11.0, 11.1, 11.2, 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, v1_0, v5_0, v5_0-pre1, v5_1, v5_1-pre1, xry111/intltool, xry111/soup3, xry111/test-20220226
Children:
565318f2
Parents:
4195cd8
Message:

added bootdisk writeup

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

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • introduction/welcome/changelog.xml

    r4195cd8 r35fd1edf  
    1010
    1111<itemizedlist>
     12
     13<listitem><para>September 2nd, 2002 [larry]: Postlfs: Added Boot disk
     14writeup by Mike Bedwell.</para></listitem>
    1215
    1316<listitem><para>September 2nd, 2002 [highos]: Filesystems: Updated to
  • introduction/welcome/credits.xml

    r4195cd8 r35fd1edf  
    4545<listitem><para>Chapter 03: Random number script <emphasis>Larry
    4646Lawrence</emphasis>.</para></listitem>
     47
     48<listitem><para>Chapter 03: Creating a custom bootdisk <emphasis>Mike
     49Bedwell</emphasis>.</para></listitem>
    4750
    4851<listitem><para>Chapter 05: Which <emphasis>Mark Hymers</emphasis> with
  • postlfs/config/bootdisk.xml

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