<HTML ><HEAD ><TITLE >Putting them together: Making the diskette(s)</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.63 "><LINK REL="HOME" TITLE="The Linux Bootdisk HOWTO" HREF="index.html"><LINK REL="PREVIOUS" TITLE="Choosing a kernel" HREF="x688.html"><LINK REL="NEXT" TITLE="Troubleshooting, or The Agony of Defeat" HREF="troubleshooting.html"></HEAD ><BODY CLASS="SECT1" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >The Linux Bootdisk HOWTO</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="x688.html" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="troubleshooting.html" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="SECT1" ><H1 CLASS="SECT1" ><A NAME="AEN703" >6. Putting them together: Making the diskette(s)</A ></H1 ><P >At this point you have a kernel and a compressed root filesystem. If you are making a boot/root disk, check their sizes to make sure they will both fit on one disk. If you are making a two disk boot+root set, check the root filesystem to make sure it will fit on a single diskette.</P ><P > You should decide whether to use LILO to boot the bootdisk kernel. The alternative is to copy the kernel directly to the diskette and boot without LILO. The advantage of using LILO is that it enables you to supply some parameters to the kernel which may be necessary to initialize your hardware (Check the file <TT CLASS="FILENAME" >/etc/lilo.conf</TT > on your system. If it exists and has a line like ``<TT CLASS="LITERAL" >append=...</TT >'', you probably need this feature). The disadvantage of using LILO is that building the bootdisk is more complicated and takes slightly more space. You will have to set up a small separate filesystem, which we shall call the <EM >kernel filesystem</EM >, where you transfer the kernel and a few other files that LILO needs.</P ><P > If you are going to use LILO, read on; if you are going to transfer the kernel directly, skip ahead to <A HREF="x703.html#TRANSFERRINGWITHOUTLILO" >Section 6.2</A >.</P ><DIV CLASS="SECT2" ><H2 CLASS="SECT2" ><A NAME="TRANSFERRINGWITHLILO" >6.1. Transferring the kernel with LILO</A ></H2 ><P >First, make sure you have a recent version of LILO.</P ><P >You must create a small configuration file for LILO. It should look like this: <TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><FONT COLOR="#000000" ><PRE CLASS="PROGRAMLISTING" > boot =/dev/fd0 install =/boot/boot.b map =/boot/map read-write backup =/dev/null compact image = KERNEL label = Bootdisk root =/dev/fd0</PRE ></FONT ></TD ></TR ></TABLE > For an explanation of these parameters, see LILO's user documentation. You will probably also want to add an <TT CLASS="LITERAL" >append=...</TT > line to this file from your hard disk's <TT CLASS="FILENAME" >/etc/lilo.conf</TT > file.</P ><P >Save this file as <TT CLASS="FILENAME" >bdlilo.conf</TT >.</P ><P > You now have to create a small filesystem, which we shall call a <EM >kernel filesystem</EM >, to distinguish it from the root filesystem.</P ><P >First, figure out how large the filesystem should be. Take the size of your kernel in blocks (the size shown by ``<B CLASS="COMMAND" >ls -s KERNEL</B >'') and add 50. Fifty blocks is approximately the space needed for inodes plus other files. You can calculate this number exactly if you want to, or just use 50. If you're creating a two-disk set, you may as well overestimate the space since the first disk is only used for the kernel anyway. Call this number <TT CLASS="LITERAL" >KERNEL_BLOCKS</TT >.</P ><P >Put a floppy diskette in the drive (for simplicity we'll assume <TT CLASS="FILENAME" >/dev/fd0</TT >) and create an ext2 kernel filesystem on it: <TABLE BORDER="1" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><FONT COLOR="#000000" ><PRE CLASS="SCREEN" > mke2fs -N 24 -m 0 /dev/fd0 KERNEL_BLOCKS</PRE ></FONT ></TD ></TR ></TABLE > The ``<TT CLASS="LITERAL" >-N 24</TT >'' specifies 24 inodes, which is all you should need for this filesystem. Next, mount the filesystem, remove the <TT CLASS="FILENAME" >lost+found</TT > directory, and create <TT CLASS="FILENAME" >dev</TT > and <TT CLASS="FILENAME" >boot</TT > directories for LILO: <TABLE BORDER="1" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><FONT COLOR="#000000" ><PRE CLASS="SCREEN" > mount -o dev /dev/fd0 /mnt rm -rf /mnt/lost+found mkdir /mnt/{boot,dev}</PRE ></FONT ></TD ></TR ></TABLE ></P ><P >Next, create devices <TT CLASS="FILENAME" >/dev/null</TT > and <TT CLASS="FILENAME" >/dev/fd0</TT >. Instead of looking up the device numbers, you can just copy them from your hard disk using <TT CLASS="LITERAL" >-R</TT >: <TABLE BORDER="1" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><FONT COLOR="#000000" ><PRE CLASS="SCREEN" > cp -R /dev/{null,fd0} /mnt/dev</PRE ></FONT ></TD ></TR ></TABLE > LILO needs a copy of its boot loader, <TT CLASS="FILENAME" >boot.b</TT >, which you can take from your hard disk. It is usually kept in the <TT CLASS="FILENAME" >/boot</TT > directory. <TABLE BORDER="1" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><FONT COLOR="#000000" ><PRE CLASS="SCREEN" > cp /boot/boot.b /mnt/boot</PRE ></FONT ></TD ></TR ></TABLE > Finally, copy in the LILO configuration file you created in the last section, along with your kernel. Both can be put in the root directory: <TABLE BORDER="1" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><FONT COLOR="#000000" ><PRE CLASS="SCREEN" > cp bdlilo.conf KERNEL /mnt</PRE ></FONT ></TD ></TR ></TABLE > Everything LILO needs is now on the kernel filesystem, so you are ready to run it. LILO's <TT CLASS="LITERAL" >-r</TT > flag is used for installing the boot loader on some other root: <TABLE BORDER="1" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><FONT COLOR="#000000" ><PRE CLASS="SCREEN" > lilo -v -C bdlilo.conf -r /mnt</PRE ></FONT ></TD ></TR ></TABLE > LILO should run without error, after which the kernel filesystem should look something like this: <TABLE BORDER="1" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><FONT COLOR="#000000" ><PRE CLASS="SCREEN" >total 361 1 –rw–r––r–– 1 root root 176 Jan 10 07:22 bdlilo.conf 1 drwxr–xr–x 2 root root 1024 Jan 10 07:23 boot/ 1 drwxr–xr–x 2 root root 1024 Jan 10 07:22 dev/ 358 –rw–r––r–– 1 root root 362707 Jan 10 07:23 vmlinuz boot: total 8 4 –rw–r––r–– 1 root root 3708 Jan 10 07:22 boot.b 4 –rw––––––– 1 root root 3584 Jan 10 07:23 map dev: total 0 0 brw–r––––– 1 root root 2, 0 Jan 10 07:22 fd0 0 crw–r––r–– 1 root root 1, 3 Jan 10 07:22 null </PRE ></FONT ></TD ></TR ></TABLE ></P ><P >Do not worry if the file sizes are slightly different from yours.</P ><P >Now leave the diskette in the drive and go to <A HREF="x703.html#SETTINGRAMDISKWORD" >Section 6.3</A >.</P ></DIV ><DIV CLASS="SECT2" ><H2 CLASS="SECT2" ><A NAME="TRANSFERRINGWITHOUTLILO" >6.2. Transferring the kernel without LILO</A ></H2 ><P >If you are <EM >not</EM > using LILO, transfer the kernel to the bootdisk with <B CLASS="COMMAND" >dd</B >: <TABLE BORDER="1" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><FONT COLOR="#000000" ><PRE CLASS="SCREEN" > % dd if=KERNEL of=/dev/fd0 bs=1k 353+1 records in 353+1 records out</PRE ></FONT ></TD ></TR ></TABLE > In this example, <B CLASS="COMMAND" >dd</B > wrote 353 complete records + 1 partial record, so the kernel occupies the first 354 blocks of the diskette. Call this number <TT CLASS="LITERAL" >KERNEL_BLOCKS</TT > and remember it for use in the next section.</P ><P >Finally, set the root device to be the diskette itself, then set the root to be loaded read/write: <TABLE BORDER="1" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><FONT COLOR="#000000" ><PRE CLASS="SCREEN" > rdev /dev/fd0 /dev/fd0 rdev -R /dev/fd0 0</PRE ></FONT ></TD ></TR ></TABLE > Be careful to use a capital <TT CLASS="LITERAL" >-R</TT > in the second <B CLASS="COMMAND" >rdev</B > command.</P ></DIV ><DIV CLASS="SECT2" ><H2 CLASS="SECT2" ><A NAME="SETTINGRAMDISKWORD" >6.3. Setting the ramdisk word</A ></H2 ><P > Inside the kernel image is the <EM >ramdisk word</EM > that specifies where the root filesystem is to be found, along with other options. The word can be accessed and set via the <B CLASS="COMMAND" >rdev</B > command, and its contents are interpreted as follows: <DIV CLASS="INFORMALTABLE" ><A NAME="AEN782" ></A ><P ></P ><TABLE BORDER="1" CLASS="CALSTABLE" ><THEAD ><TR ><TH WIDTH="96" ALIGN="RIGHT" VALIGN="TOP" >Bit field</TH ><TH WIDTH="100%" ALIGN="LEFT" VALIGN="TOP" >Description</TH ></TR ></THEAD ><TBODY ><TR ><TD WIDTH="96" ALIGN="RIGHT" VALIGN="TOP" >0-10</TD ><TD WIDTH="100%" ALIGN="LEFT" VALIGN="TOP" >Offset to start of ramdisk, in 1024 byte blocks</TD ></TR ><TR ><TD WIDTH="96" ALIGN="RIGHT" VALIGN="TOP" >11-13</TD ><TD WIDTH="100%" ALIGN="LEFT" VALIGN="TOP" >unused</TD ></TR ><TR ><TD WIDTH="96" ALIGN="RIGHT" VALIGN="TOP" >14</TD ><TD WIDTH="100%" ALIGN="LEFT" VALIGN="TOP" >Flag indicating that ramdisk is to be loaded</TD ></TR ><TR ><TD WIDTH="96" ALIGN="RIGHT" VALIGN="TOP" >15</TD ><TD WIDTH="100%" ALIGN="LEFT" VALIGN="TOP" >Flag indicating to prompt before loading rootfs</TD ></TR ></TBODY ></TABLE ><P ></P ></DIV ></P ><P >If bit 15 is set, on boot-up you will be prompted to place a new floppy diskette in the drive. This is necessary for a two-disk boot set.</P ><P >There are two cases, depending on whether you are building a single boot/root diskette or a double ``boot+root'' diskette set.</P ><P ></P ><OL TYPE="1" ><LI ><P > If you are building a single disk, the compressed root filesystem will be placed right after the kernel, so the offset will be the first free block (which should be the same as <TT CLASS="LITERAL" >KERNEL_BLOCKS</TT >). Bit 14 will be set to 1, and bit 15 will be zero. For example, say you're building a single disk and the root filesystem will begin at block 253 (decimal). The ramdisk word value should be 253 (decimal) with bit 14 set to 1 and bit 15 set to 0. To calculate the value you can simply add the decimal values. 253 + (2^14) = 253 + 16384 = 16637. If you don't quite understand where this number comes from, plug it into a scientific calculator and convert it to binary,</P ></LI ><LI ><P >If you are building a two-disk set, the root filesystem will begin at block zero of the second disk, so the offset will be zero. Bit 14 will be set to 1 and bit 15 will be 1. The decimal value will be 2^14 + 2^15 = 49152 in this case.</P ></LI ></OL ><P >After carefully calculating the value for the ramdisk word, set it with <B CLASS="COMMAND" >rdev -r</B >. Be sure to use the <EM >decimal</EM > value. If you used LILO, the argument to <B CLASS="COMMAND" >rdev</B > here should be the <EM >mounted kernel path</EM >, e.g. <TT CLASS="FILENAME" >/mnt/vmlinuz</TT >; if you copied the kernel with <B CLASS="COMMAND" >dd</B >, instead use the floppy device name (<EM >e.g.,</EM > <TT CLASS="FILENAME" >/dev/fd0</TT >). <TABLE BORDER="1" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><FONT COLOR="#000000" ><PRE CLASS="SCREEN" > rdev -r KERNEL_OR_FLOPPY_DRIVE VALUE</PRE ></FONT ></TD ></TR ></TABLE ></P ><P >If you used LILO, unmount the diskette now.</P ><DIV CLASS="IMPORTANT" ><P ></P ><TABLE CLASS="IMPORTANT" WIDTH="100%" BORDER="0" ><TR ><TD WIDTH="25" ALIGN="CENTER" VALIGN="TOP" ><IMG SRC="../images/important.gif" HSPACE="5" ALT="Important"></TD ><TD ALIGN="LEFT" VALIGN="TOP" ><P >Do not believe what the rdev/ramsize manpage says about ramdisk size. The manpage is obsolete. As of kernel 2.0 or so, the ramdisk word no longer determines the ramdisk size; the word is instead interpreted according to the table at the beginning of section <A HREF="x703.html#SETTINGRAMDISKWORD" >Section 6.3</A >. For a detailed explanation, see the documentation file <A HREF="file:/usr/src/linux/Documentation/ramdisk.txt" TARGET="_top" >ramdisk.txt</A > or <A HREF="http://www.linuxhq.com/kernel/v2.4/doc/ramdisk.txt.html" TARGET="_top" >http://www.linuxhq.com/kernel/v2.4/doc/ramdisk.txt.html</A >. </P ></TD ></TR ></TABLE ></DIV ></DIV ><DIV CLASS="SECT2" ><H2 CLASS="SECT2" ><A NAME="AEN831" >6.4. Transferring the root filesystem</A ></H2 ><P >The last step is to transfer the root filesystem.</P ><P > <P ></P ><UL ><LI ><P > If the root filesystem will be placed on the <EM >same</EM > disk as the kernel, transfer it using <B CLASS="COMMAND" >dd</B > with the <TT CLASS="OPTION" >seek</TT > option, which specifies how many blocks to skip: <TABLE BORDER="1" BGCOLOR="#E0E0E0" WIDTH="90%" ><TR ><TD ><FONT COLOR="#000000" ><PRE CLASS="SCREEN" > dd if=rootfs.gz of=/dev/fd0 bs=1k seek=<EM >KERNEL_BLOCKS</EM ></PRE ></FONT ></TD ></TR ></TABLE ></P ></LI ><LI ><P >If the root filesystem will be placed on a <EM >second</EM > disk, remove the first diskette, put the second diskette in the drive, then transfer the root filesystem to it: <TABLE BORDER="1" BGCOLOR="#E0E0E0" WIDTH="90%" ><TR ><TD ><FONT COLOR="#000000" ><PRE CLASS="SCREEN" > dd if=rootfs.gz of=/dev/fd0 bs=1k</PRE ></FONT ></TD ></TR ></TABLE ></P ></LI ></UL > </P ><P >Congratulations, you are done! </P ><DIV CLASS="IMPORTANT" ><P ></P ><TABLE CLASS="IMPORTANT" WIDTH="100%" BORDER="0" ><TR ><TD WIDTH="25" ALIGN="CENTER" VALIGN="TOP" ><IMG SRC="../images/important.gif" HSPACE="5" ALT="Important"></TD ><TD ALIGN="LEFT" VALIGN="TOP" ><P >You should always test a bootdisk before putting it aside for an emergency. If it fails to boot, read on.</P ></TD ></TR ></TABLE ></DIV ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="x688.html" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="troubleshooting.html" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Choosing a kernel</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" > </TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Troubleshooting, or The Agony of Defeat</TD ></TR ></TABLE ></DIV ></BODY ></HTML >