home *** CD-ROM | disk | FTP | other *** search
/ CD/PC Actual 13 / CDA13.ISO / DOC / HOWTO / OTHER_FO / SGML / BOOTDISK.GZ / Bootdisk-HOWTO.sgml
Encoding:
SGML Document  |  1996-08-18  |  86.6 KB  |  2,252 lines

  1. <!doctype linuxdoc system>
  2.  
  3. <article>
  4.  
  5. <title>The Linux Bootdisk HOWTO
  6. <author>Tom Fawcett and Graham Chapman
  7. <date>v2.1, 18 August 1996
  8. <abstract>
  9. This document describes how to create Linux boot, boot/root and utility
  10. maintenance disks. These disks could be used as rescue disks or to test
  11. new kernels.
  12.  
  13. Note: if you haven't read the Linux FAQ and related documents such as
  14. the Linux Installation HOWTO and the Linux Install Guide, then you
  15. should not be trying to build boot diskettes.
  16. </abstract>
  17.  
  18. <toc>
  19.  
  20. <sect>Introduction
  21. <p>
  22. <sect1>Why Build Boot Disks?
  23. <p>
  24. Linux boot disks are useful in a number of situations, such as:
  25. <itemize>
  26. <item>Testing a new kernel.
  27. <item>Recovering from disk or system failure. Such a failure could be
  28. anything from a lost boot sector to a disk head crash.
  29. </itemize>
  30.  
  31. There are several ways of producing boot disks:
  32. <itemize>
  33. <item>Use one from a distribution such as Slackware. This will at 
  34. least allow you to boot.
  35. <item>Use a rescue package to set up disks designed to be used
  36. as rescue disks.
  37. <item>Learn what is required for each of the various types of disk
  38. to operate, then build your own.
  39. </itemize>
  40.  
  41. I originally chose the last option - learn how it works so that you
  42. can do it yourself. That way, if something breaks, you can work out
  43. what to do to fix it. Plus you learn a lot about how Linux works along
  44. the way.
  45.  
  46. Experienced Linux users may find little of use in this 
  47. document. However users new to Linux system administration who
  48. wish to protect against root disk loss and other mishaps may find
  49. it useful.
  50.  
  51. A note on versions - this document has been updated to support the
  52. following packages and versions:
  53. <itemize>
  54. <item>Linux 2.0.6
  55. <item>LILO 0.19
  56. </itemize>
  57.  
  58. Copyright (c) Tom Fawcett and Graham Chapman 1996.
  59.  
  60. Permission is granted for this material to be freely
  61. used and distributed, provided the source is acknowledged.
  62. The copyright conditions are intended to be no
  63. more restrictive than version 2 of the GNU General Public License
  64. as published by the Free Software Foundation.
  65.  
  66. No warranty of any kind is provided. You use this material
  67. at your own risk.
  68.  
  69.  
  70. <sect1>Feedback and Credits
  71. <p>
  72. We welcome any feedback, good or bad, on the content of this document.
  73. Please let us know if you find any errors or omissions. Send comments,
  74. corrections and questions to Tom Fawcett (<tt/fawcett@nynexst.com/) or
  75. Graham Chapman (<tt/grahamc@zeta.org.au/).
  76.  
  77. I thank the following people for correcting errors and providing
  78. useful suggestions for improvement:
  79.  
  80. <tscreen><verb>
  81.     Randolph Bentson
  82.     Grant R. Bowman
  83.     Scott Burkett
  84.     Cameron Davidson
  85.     Bruce Elliot
  86.     HARIGUCHI Youichi
  87.     Bjxrn-Helge Mevik
  88.     Dwight Spencer
  89.     Cameron Spitzer
  90.     Johannes Stille
  91. </verb></tscreen>
  92.  
  93. <sect1>Change History
  94. <p>
  95. v2.1, 18 August 1996. Changes in this version:
  96. <p>
  97. Summary: this was a major cleanup to reflect changes between kernel
  98. version 1.2 and 2.0. Specific changes are:
  99. <itemize>
  100. <item>Chg: replaced shell scripts and directory listings.
  101. <item>Chg: removed most of the text of "oversize ramdisk" FAQ question.
  102. <item>Fix: mkfs -i should have been mke2fs -i.
  103. <item>Fix: missing parameter name in dd command to zero rootdisk device.
  104. <item>Fix: remove accidental extra parameter from mke2fs command to create
  105. rootdisk filesystem.
  106. <item>Chg: minor changes to reflect less reliance on the Bootkit utility.
  107. <item>Chg: change section cross-references to refer to section title, not
  108. number (sometime I'll add hypertext links...)
  109. <item>Add: use cpio as an alternate way of copying files.
  110. <item>Add: tips for removing unnecessary device special files.
  111. <item>Add: FAQ question - what to do if nothing happens at boot time.
  112. <item>Add: various minor changes.
  113. </itemize>
  114.  
  115. v2.0, 12 June 1996. Changes in this version:
  116. <itemize>
  117. <item>Add: additional author and maintainer, Tom Fawcett.
  118. <item>Add: section 6.3, Ramdisk Usage.
  119. <item>Add: section titled Advanced Bootdisk Creation, which describes how
  120. to take advantage of ramdisk changes in kernels 1.3.48+
  121. <Item>Chg: rewrite section on /lib directory.
  122. <Item>Chg: various minor tips on changed ramdisk usage.
  123. </itemize>
  124.  
  125. Version history:
  126. <itemize>
  127. <item>v1.02, 25 June 1995 - minor changes.
  128. <item>v1.01, 6 February 1995 - minor changes.
  129. <item>v1.0, 2 January 1995 - first release in standard HOWTO layout.
  130. <item>v0.10, 1 Novemer 1994 - original version, labelled "Draft".
  131. </itemize>
  132.  
  133. <sect>Disks
  134. <p>
  135. <sect1>Summary of Disk Types
  136. <p>
  137. I classify boot-related disks into 4 types. The discussion here
  138. and throughout this document uses the term "disk" to refer to
  139. diskettes unless otherwise specified. Most of the discussion could
  140. be equally well applied to hard disks. 
  141.  
  142. A summary of disk types and uses is:
  143. <descrip>
  144. <tag/boot/ A disk containing a kernel which can be booted. The disk
  145. can contain a filesystem and use a boot loader to boot, or it can
  146. simply contain the kernel only at the start of the disk.
  147. The disk can be used to boot the kernel using a root
  148. file system on another disk. This could be useful if you lost your
  149. boot loader due to, for example, an incorrect installation attempt.
  150.  
  151. <tag>root</tag> A disk with a file system containing everything
  152. required to run a Linux system. It does not necessarily contain 
  153. either a kernel or a boot loader.
  154.  
  155. This disk can be used to run the system independently of any other
  156. disks, once the kernel has been booted. A special kernel feature
  157. allows a separate root disk to be mounted after booting, with the
  158. root disk being automatically copied to a ramdisk.
  159.  
  160. You could use this type of disk to check another disk for corruption
  161. without mounting it, or to restore another disk after a disk failure or
  162. loss of files.
  163.  
  164. <tag>boot/root</tag> A disk which is the same as a root disk, but 
  165. contains a kernel and a boot loader. It can be used to boot from,
  166. and to run the system. The advantage of this type of disk is
  167. that is it compact - everything required is on a single disk.
  168. However the gradually increasing size of everything means that
  169. it won't necessarily always be possbile to fit everything on a single 
  170. diskette, even with compression.
  171.  
  172. <tag>utility</tag> A disk which contains a file system, but is not
  173. intended to be mounted as a root file system. It is an additional
  174. data disk. You would use this type of disk to carry additional
  175. utilities where you have too much to fit on your root disk.
  176.  
  177. The term "utility" only really applies to diskettes, where you would
  178. use a utility disk to store additional recovery utility software.
  179. </descrip>
  180.  
  181. The most flexible approach for rescue diskettes is probably to 
  182. use separate boot and root diskettes, and one or more utility 
  183. diskettes to handle the overflow. 
  184.  
  185. <sect1>Boot
  186. <p>
  187. <sect2>Overview
  188. <p>
  189. All PC systems start the boot process by executing code in ROM to load
  190. the sector from sector 0, cylinder 0 of the boot drive and try and
  191. execute it. On most bootable disks, sector 0, cylinder 0 contains either:
  192. <itemize>
  193. <item>code from a boot loader such as LILO, which locates the kernel,
  194. loads it and executes it to start the boot proper.
  195. <item>the start of an operating system kernel, such as Linux.
  196. </itemize>
  197.  
  198. If a Linux kernel has been written to a diskette as a raw device,
  199. then the first sector will be the first sector of the Linux kernel
  200. itself, and this sector will continue the boot process by loading 
  201. the rest of the kernel and running Linux. For a more detailed
  202. description of the boot sector contents, see the documentation
  203. in lilo-01.5 or higher.
  204.  
  205. An alternative method of storing a kernel on a boot disk is to create
  206. a filesystem, not as a root filesystem, but simply as a means of 
  207. installing LILO and thus allowing boot-time command line options
  208. to be specified. For example, the same kernel could then be used
  209. to boot using a hard disk root filesystem, or a diskette root
  210. filesystem. This could be useful if you were trying to rebuild 
  211. the hard disk filesystem, and wanted to repeatedly test results.
  212.  
  213. <sect2>Setting Pointer to Root
  214. <p>
  215. The kernel must somehow obtain a pointer to the drive and partititon to 
  216. be mounted as the root drive. This can be provided
  217. in several ways:
  218. <itemize>
  219. <item>By setting <tt/ROOT_DEV = devicename/ in the Linux kernel makefile
  220. and rebuilding the kernel (for advice on how to rebuild the kernel,
  221. read the Linux FAQ and look in <tt>/usr/src/linux</tt>). Comments in the 
  222. Linux makefile describe the valid values for <tt/devicename/.
  223. <item>By running the rdev utility:
  224. <tscreen><verb>
  225.     rdev filename devicename
  226. </verb></tscreen>
  227.  
  228. This will set the root device of the kernel contained in <tt/filename/
  229. to be <tt/devicename/. For example:
  230. <tscreen><verb>
  231.     rdev zImage /dev/sda1
  232. </verb></tscreen>
  233.  
  234. This sets the root device in the kernel in zImage to the first partition on
  235. the first SCSI drive.
  236. </itemize>
  237.  
  238. There are some alternative ways of issuing the rdev command. Try:
  239. <tscreen><verb>
  240.     rdev -h
  241. </verb></tscreen>
  242.  
  243. and it will display command usage.
  244.  
  245. There is usually no need to configure the root device for
  246. boot diskette use, because the kernel currently used to boot from 
  247. probably already points to the root drive device. The need can
  248. arise, howoever, if you obtain a kernel from another machine,
  249. for example, from a distribution, or if you want to use the kernel
  250. to boot a root diskette. It is probably a good idea to check the
  251. current root drive setting, just in case it is wrong. To get
  252. rdev to check the current root device in a kernel file, enter
  253. the command:
  254. <tscreen><verb>
  255.     rdev <filename>
  256. </verb></tscreen>
  257.  
  258. It is possible to change the root device set in a kernel by means other
  259. than using rdev. For details, see the FAQ at the end of this document.
  260.  
  261. <sect2>Copying Kernel to Boot Diskette
  262. <p>
  263. Once the kernel has been configured then it must be copied to the 
  264. boot diskette. 
  265.  
  266. The commands described below (and throughout the HOWTO) assume that
  267. the diskettes have been formatted. If not, then use fdformat to format
  268. the diskettes before continuing.
  269.  
  270. If the disk is not intended to contain a file system, then the kernel
  271. can be copied using the dd command, as follows:
  272. <tscreen><verb>
  273.     dd if=infilename of=devicename
  274.  
  275.     where     infilename is the name of the kernel
  276.     and    devicename is the diskette raw device,
  277.         usually /dev/fd0
  278. </verb></tscreen>
  279.  
  280. The cp command can also be used:
  281. <tscreen><verb>
  282.     cp filename devicename
  283. </verb></tscreen>
  284.  
  285. For example:
  286.  
  287. <tscreen><verb>
  288.     dd if=zImage of=/dev/fd0
  289. or
  290.     cp zImage /dev/fd0
  291. </verb></tscreen>
  292.  
  293. The seek parameter to the dd command should NOT be used. The file
  294. must be copied to start at the boot sector (sector 0, cylinder 0),
  295. and omitting the seek parameter will do this.
  296.  
  297. The output device name to be used is usually <tt>/dev/fd0</tt> for
  298. the primary diskette drive (i.e. drive "A:" in DOS), and <tt>/dev/fd1</tt>
  299. for the secondary. These device names will cause the kernel to 
  300. autodetect the attributes of the drives. Drive attributes can
  301. be specified to the kernel by using other device names: for
  302. example <tt>/dev/fd0H1440</tt> specifies a high density 1.44 Mb
  303. drive. It is rare to need to use these specific device names.
  304.  
  305. Where the kernel is to be copied to a boot disk containing a filesystem,
  306. then the disk is mounted at a suitable point in a currently-mounted
  307. filesystem, then the cp command is used. For example:
  308. <tscreen><verb>
  309.     mount -t ext2 /dev/fd0 /mnt
  310.     cp zImage /mnt
  311.     umount /mnt
  312. </verb></tscreen>
  313.  
  314. Note that for almost all operations in this HOWTO, the user should be
  315. operating as the superuser.
  316.  
  317. <sect1>Root
  318. <p>
  319. <sect2>Overview
  320. <p>
  321. A root disk contains a complete working Linux system, but without
  322. necessarily including a kernel. In other words, the disk may not
  323. be bootable, but once the kernel is running, the root disk contains
  324. everything needed to support a full Linux system. To be able to
  325. do this, the disk must include the minimum requirements for a 
  326. Linux system:
  327. <itemize>
  328. <item>File system.
  329. <item>Minimum set of directories - dev, proc, bin, etc, lib, usr, tmp.
  330. <item>Basic set of utilities - bash (to run a shell), ls, cp etc.
  331. <item>Minimum set of config files - rc, inittab, fstab etc.
  332. <item>Runtime library to provide basic functions used by utilities.
  333. </itemize>
  334.  
  335. Of course, any system only becomes useful when you can run something
  336. on it, and a root diskette usually only becomes useful when you
  337. can do something like:
  338. <itemize>
  339. <item>Check a file system on another drive, for example to check
  340. your root file system on your hard drive, you need to be 
  341. able to boot Linux from another drive, as you can with a
  342. root diskette system. Then you can run fsck on your
  343. original root drive while it is not mounted.
  344. <item>Restore all or part of your original root drive from backup
  345. using archive/compression utilities including cpio, tar,
  346. gzip and ftape.
  347. </itemize>
  348.  
  349. <sect1>Boot/Root 
  350. <p>
  351. This is essentially the same as the root disk, with the
  352. addition of a kernel and a boot loader such as LILO.
  353.  
  354. With this configuration, a kernel file is copied to the root file
  355. system, and LILO is then run to install a configuration which
  356. points to the kernel file on the target disk. At boot time, LILO
  357. will boot the kernel from the target disk.
  358.  
  359. Several files must be copied to the diskette for this method to 
  360. work. Details of these files and the required LILO configuration,
  361. including a working sample, are given below in the section
  362. titled "LILO".
  363.  
  364. <sect2>RAM Disks and Root Filesystems on Diskette
  365. <p>
  366. For a diskette root filesystem to be efficient, you need to be able to run 
  367. it from a ramdisk, i.e. an emulated disk drive in main memory.
  368. This avoids having the system run at a snail's pace, which a 
  369. diskette would impose. The Ftape HOWTO states that a ramdisk will
  370. be required when using Ftape because Ftape requires exclusive use of
  371. the diskette controller.
  372.  
  373. There is an added benefit from using a ramdisk - the Linux kernel
  374. includes an automatic ramdisk root feature, whereby it will, under
  375. certain circumstances, automatically copy the contents of a
  376. root diskette to a ramdisk, and then switch the root drive
  377. to be the ramdisk instead of the diskette. This has three major
  378. benefits:
  379. <itemize>
  380. <item>The system runs a lot faster.
  381. <item>The diskette drive is freed up to allow other diskettes
  382. to be used on a single-diskette drive system.
  383. <item>With compression, the ramdisk image on a disk can be substantially
  384. smaller than (eg, 40% the size of) the corresponding disk image.  This
  385. means that a 1.44 meg floppy disk may hold a root containing roughly 3.6
  386. meg.
  387. </itemize>
  388.  
  389. For kernels 1.3.48+, the ramdisk code was substantially rewritten.
  390. You have some more options and the commands for using the ramdisk
  391. are somewhat different. The section titled "Advanced Bootdisk Creation"
  392. discusses how to take advantage of these.
  393.  
  394. You must configure your kernel to have ramdisk support, but the
  395. ramdisk is dynamically expandible so you need not specify the size.
  396. <tt/rdev -r/ is no longer used to specify the ramdisk size, but
  397. instead sets a ramdisk word in the kernel image.  The section titled
  398. "Advanced Bootdisk Creation" discusses this in more detail.
  399.  
  400. If you have a kernel *before* 1.3.48, the following requirements
  401. apply. Note that this applies ONLY to kernels prior to 1.3.48.
  402. <itemize>
  403. <item>The file system on the diskette drive must be either a minix 
  404. or an ext2 file system. The ext2 file system is generally the preferred
  405. file system to use. Note that if you have a Linux kernel earlier 
  406. than 1.1.73, then you should see the comments in the section
  407. titled "File Systems" to see whether your kernel will
  408. support ext2. If your kernel is old then you may have to use
  409. minix. This will not cause any significant problems.
  410. <item>A ramdisk must be configured into the kernel, and it must
  411. be at least as big as the diskette drive.
  412. </itemize>
  413.  
  414. A ramdisk can be configured into the kernel in several ways:
  415. <itemize>
  416. <item>By uncommenting the RAMDISK macro in the Linux kernel
  417. makefile, so that it reads:
  418. <tscreen><verb>
  419.     RAMDISK = -DRAMDISK=1440
  420. </verb></tscreen>
  421. to define a ramdisk of 1440 1K blocks, the size of a
  422. high-density diskette.
  423. <item>By running the rdev utility, available on most Linux
  424. systems. This utility displays or sets values for several
  425. things in the kernel, including the desired size for a 
  426. ramdisk. To configure a ramdisk of 1440 blocks into a 
  427. kernel in a file named zImage, enter:
  428. <tscreen><verb>
  429.     rdev -r zImage 1440
  430. </verb></tscreen>
  431. this might change in the future, of course. To see what
  432. your version of rdev does, enter the command:
  433. <tscreen><verb>
  434.     rdev -h
  435. </verb></tscreen>
  436. and it should display its options.
  437. <item>By using the boot loader package LILO to configure it into
  438. your kernel at boot time. This can be done using the 
  439. LILO configuration parameter:
  440. <tscreen><verb>
  441.     ramdisk = 1440 
  442. </verb></tscreen>
  443. to request a ramdisk of 1440 1K blocks at boot time.
  444. <item>By interrupting a LILO automatic boot and adding ramdisk=1440 
  445. to the command line. For example, such a command line might be:
  446. <tscreen><verb>
  447.     zImage ramdisk=1440 
  448. </verb></tscreen>
  449. See the section on LILO for more details.
  450. <item>By editing the kernel file and altering the values near the
  451. start of the file which record the ramdisk size. This is definitely a 
  452. last resort, but can be done. See the FAQ near the end of this 
  453. document for more details.
  454. </itemize>
  455.  
  456. The easiest of these methods is LILO configuration, because you
  457. need to set up a LILO configuration file anyway, so why not add the
  458. ramdisk size here?
  459.  
  460. LILO configuration is briefly described in a section titled "LILO"
  461. below, but it is advisable to obtain the latest stable version of
  462. LILO from your nearest Linux mirror site, and read the documentation
  463. that comes with it.
  464.  
  465. Ramdisks can be made larger than the size of a diskette, and made to
  466. contain a filesystem as large as the ramdisk. This can be
  467. useful to load all the software required for rescue work onto a single
  468. high-performance ramdisk. The method of doing this is described in 
  469. the FAQ section under the question "How can I create an oversize
  470. ramdisk filesystem?"
  471.  
  472. <sect1>Utility
  473. <p>
  474. Often one disk is not sufficient to hold all the software you need 
  475. to be able to perform rescue functions of analysing, repairing and
  476. restoring corrupted disk drives. By the time you include tar, gzip
  477. e2fsck, fdisk, Ftape and so on, there is enough for a whole new 
  478. diskette, maybe even more if you want lots of tools.
  479.  
  480. This means that a rescue set often requires a utility diskette,
  481. with a file system containing any extra files required. This file
  482. system can then be mounted at a convenient point, such as /usr, on
  483. the boot/root system.
  484.  
  485. Creating a file system is fairly easy, and is described in 
  486. the section titled "File Systems". 
  487.  
  488. <sect>Components
  489. <p>
  490. <sect1>File Systems
  491. <p>
  492. The Linux kernel now supports two file system types for root 
  493. disks to be automatically copied to ramdisk. These are minix
  494. and ext2, of which ext2 is the preferred file system. 
  495. The ext2 support was added sometime between 1.1.17 and 1.1.57,
  496. I'm not sure exactly which. If you have a kernel within this range
  497. then edit /usr/src/linux/drivers/block/ramdisk.c and look for the
  498. word "ext2". If it is not found, then you will have to use a minix
  499. file system, and therefore the "mkfs" command to create it. If using ext2,
  500. then you may find it useful to use the -i option to specify more inodes
  501. than the default; -i 2000 is suggested so that you don't run out of
  502. inodes. Alternatively, you can save on inodes by removing lots of
  503. unnecessary /dev files. Mke2fs will by default create 360 inodes on a 1.44Mb 
  504. diskette. I find that 120 inodes is ample on my current
  505. rescue root diskette, but if you include all the devices in the /dev
  506. directory then you will easily exceed 360. Using a compressed root
  507. filesystem allows a larger filesystem, and hence more inodes by 
  508. default, but you may still need to either reduce the number of files
  509. or increase the number of inodes.
  510.  
  511. To create an ext2 file system on a diskette on my system, I issue the
  512. following command:
  513. <tscreen><verb>
  514.     mke2fs -m 0 /dev/fd0
  515. </verb></tscreen>
  516.  
  517. The mke2fs command will automatically detect the space available and
  518. configure itself accordingly. If desired, the diskette size in 1Kb blocks
  519. can be specified to speed up mke2fs operation. The -m 0 parameter prevents
  520. it from reserving space for root, and hence provides more usable space
  521. on the disk. 
  522.  
  523. An easy way to test the result is to create a system using the above
  524. command or similar, and then attempt to mount the diskette. If it is
  525. an ext2 system, then the command:
  526. <tscreen><verb>
  527.     mount -t ext2 /dev/fd0 /<mount point>
  528. </verb></tscreen>
  529. should work.
  530.  
  531. <sect1>Kernel
  532. <p>
  533. <sect2>Building a Custom Kernel
  534. <p>
  535. In most cases it would be possible to copy your current kernel and 
  536. boot the diskette from that. However there may be cases where you
  537. wish to build a separate one.
  538.  
  539. One reason is size.  The kernel is one of the
  540. largest files in a minimum system, so if you want to build a 
  541. boot/root diskette, then you will have to reduce the size of the kernel
  542. as much as possible.  The kernel now supports changing
  543. the diskette after booting and before mounting root, so it is not
  544. necessary any more to squeeze the kernel into the same disk as
  545. everything else, therefore these comments apply only if you choose
  546. to build a boot/root diskette.
  547.  
  548. There are two ways of reducing kernel size:
  549. <itemize>
  550. <item>Building it with the minumum set of facilities necessary
  551. to support the desired system. This means leaving out 
  552. everything you don't need. Networking is a good thing to
  553. leave out, as well as support for any disk drives and 
  554. other devices which you don't need when running your
  555. boot/root system.
  556. <item>Compressing it, using the standard compressed-kernel
  557. option included in the makefile:
  558. <tscreen><verb>
  559.     make zImage
  560. </verb></tscreen>
  561. Refer to the documentation included with the kernel source
  562. for up-to-date information on building compressed kernels.
  563. Note that the kernel source is usually in /usr/src/linux.
  564. </itemize>
  565.  
  566. Having worked out a minimum set of facilities to include in a kernel,
  567. you then need to work out what to add back in. Probably the most
  568. common uses for a boot/root diskette system would be to examine  
  569. and restore a corrupted root file system, and to do this you may
  570. need kernel support.
  571.  
  572. For example, if your backups are all held on tape using Ftape to 
  573. access your tape drive, then, if you lose your current root drive
  574. and drives containing Ftape, then you will not be able to restore
  575. from your backup tapes. You will have to reinstall Linux, download
  576. and reinstall Ftape, and then try and read your backups.
  577.  
  578. It is probably desirable to maintain a copy of the same version 
  579. of backup utilities used to write the backups, so that you don't 
  580. waste time trying to install versions that cannot read your 
  581. backup tapes.
  582.  
  583. The point here is that, whatever I/O support you have added to 
  584. your kernel to support backups should also be added into your
  585. boot/root kernel.
  586.  
  587. The procedure for actually building the kernel is described in
  588. the documentation that comes with the kernel. It is quite easy to
  589. follow, so start by looking in /usr/src/linux. Note that if you
  590. have trouble building a kernel, then you should probably not
  591. attempt to build boot/root systems anyway.
  592.  
  593. <sect1>Devices
  594. <p>
  595. A /dev directory containing a special file for all devices to be
  596. used by the system is mandatory for any Linux system. The
  597. directory itself is a normal directory, and can be created with 
  598. the mkdir command in the normal way. The device special files,
  599. however, must be created in a special way, using the mknod command.
  600.  
  601. There is a shortcut, though - copy your existing /dev directory
  602. contents, and delete the ones you don't want. The only requirement
  603. is that you copy the device special files using the -R option.  
  604. <footnote>
  605. Warning: The <tt/cp/ command supplied with the most recent version of
  606. fileutils (3.13) is reported not to respect the <tt/-R/ flag.
  607. </footnote>
  608. This will copy the directory without attempting to copy the contents of the
  609. files. Note that if you use lower caser, as in "-r", there will be
  610. a vast difference, because you will probably end up copying the 
  611. entire contents of all of your hard disks - or at least as much
  612. of them as will fit on a diskette! Therefore, take care, and use
  613. the command:
  614. <tscreen><verb>
  615.     cp -dpR /dev /mnt
  616. </verb></tscreen>
  617. assuming that the diskette is mounted at /mnt.  The dp switches 
  618. ensure that symbolic links are copied as links (rather than 
  619. the target file being copied) and that the original file attributes
  620. are preserved, thus preserving ownership information.
  621.  
  622. You can also use the -p option of cpio, because cpio will handle 
  623. device special files correctly, and not try and copy the contents.
  624. For example:
  625. <tscreen><verb>
  626.     cd /dev
  627.     find . -print | cpio -pmd /mnt/dev
  628. </verb></tscreen>
  629.  
  630. will copy all device special files from /dev to /mnt/dev. In fact it
  631. will copy all files in the directory tree starting at /dev, and will 
  632. create any required subdirectories in the target directory tree.
  633.  
  634. If you want to do it the hard way, use ls -l to display the major
  635. and minor device numbers for the devices you want, and create 
  636. them on the diskette using mknod.
  637.  
  638. Many distributions include a shell script called MAKEDEV in the 
  639. /dev directory. This shell script could be used to create the devices,
  640. but it is probably easier to just copy your existing ones, especially
  641. for rescue disk purposes.
  642.  
  643. Whichever way the device directory is copied, it is worth checking
  644. that any special devices you need have been placed on the 
  645. rescue diskette. For example, Ftape uses tape devices, so you will
  646. need to copy all of these.
  647.  
  648. Note that an inode is required for each device special file, and 
  649. inodes can at times be a scarce resource, especially on diskette
  650. filesystems. It therefore makes sense to remove any device special
  651. files that you don't need from the diskette /dev directory. Many
  652. devices are obviously unnecessary on specific systems. For example,
  653. if you do not have SCSI disks, then you can safely remove all the 
  654. device files starting with "sd". Similarly,
  655. if you don't intend to use
  656. your serial port then all the device files starting with 
  657. "cua" can go.
  658.  
  659. <sect1>Directories 
  660. <p>
  661. It might be possible to get away with just /dev, /proc and /etc to run
  662. a Linux system. I don't know - I've never tested it. However it will 
  663. certainly be difficult, because without shared libraries all your 
  664. executables would have to be statically linked. A
  665. reasonable minimum set of directories consists of the following:
  666. <descrip>
  667. <tag>/dev</tag> Required to perform I/O with devices
  668. <tag>/proc</tag> Required by the ps command
  669. <tag>/etc</tag> System configuration files
  670. <tag>/bin</tag> Utility executables considered part of the system
  671. <tag>/lib</tag> Shared libraries to provide run-time support
  672. <tag>/mnt</tag> A mount point for maintenance on other disks
  673. <tag>/usr</tag> Additional utilities and applications
  674. </descrip>
  675.  
  676. Note that the directory tree presented here is for root diskette use only.
  677. Refer to the Linux File System Standard for much better information
  678. on how file systems should be structured in "standard" Linux 
  679. systems.
  680.  
  681. Four of these directories can be created very easily:
  682. <itemize>
  683. <item>/dev is described above in the section titled DEVICES.
  684. <item>/proc only needs to exist. Once the directory is created using
  685. mkdir, nothing more is required.
  686. <item>Of the others, /mnt and /usr are included in this list only as
  687. mount points for use after the boot/root system is running.
  688. Hence again, these directories only need to be created.
  689. </itemize>
  690.  
  691. The remaining 3 directories are described in the following sections.
  692.  
  693. <sect2>/etc
  694. <p>
  695. This directory must contain a number of configuration files. On most
  696. systems, these can be divided into 3 groups:
  697. <itemize>
  698. <item>Required at all times, e.g. rc, fstab, passwd.
  699. <item>May be required, but no-one is too sure.
  700. <item>Junk that crept in. 
  701. </itemize>
  702.  
  703. Files which are not essential can be identified with the command:
  704. <tscreen><verb>
  705.     ls -ltru
  706. </verb></tscreen>
  707. This lists files in reverse order of date last accessed, so if any
  708. files are not being accessed, then they can be omitted from a root
  709. diskette.
  710.  
  711. On my root diskettes, I have the number of config files down to
  712. 15. This reduces my work to dealing with three sets of files:
  713. <itemize>
  714. <item>The ones I must configure for a boot/root system:
  715. <tscreen><verb>
  716.     rc.d/*    system startup and run level change scripts
  717.     fstab    list of file systems to be mounted
  718.     inittab parameters for the init process - the
  719.         first process started at boot time.
  720. </verb></tscreen>
  721.  
  722. <item>the ones I should tidy up for a boot/root system:
  723. <tscreen><verb>
  724.     passwd    list of logins
  725.     shadow    contains passwords
  726. </verb></tscreen>
  727. These should be pruned on secure systems to avoid copying 
  728. user's passwords off the system, and so that when you boot
  729. from diskette, unwanted logins are rejected. 
  730. <footnote>Note that there is a reason <em/not/ to prune passwd and shadow.
  731. Tar (and probably other archivers) stores user and group names with files.
  732. If you restore files to your hard disk from tape, the files will be
  733. restored with their original names.  If these names do not exist in
  734. passwd/group when they are restored, the UID/GID will not be correct.
  735. </footnote>
  736.  
  737. <item>The rest. They work at the moment, so I leave them alone.
  738. </itemize>
  739.  
  740. Out of this, I only really have to configure two files, and what they
  741. should contain is surprisingly small.
  742. <itemize>
  743. <item>rc should contain:
  744. <tscreen><verb>
  745.     #!/bin/sh    
  746.     /etc/mount -av
  747.     /bin/hostname boot_root
  748. </verb></tscreen>
  749. and I don't really need to run hostname - it just looks nicer 
  750. if I do. Even mount is actually only needed to mount /proc to
  751. support the ps command - Linux will run without it, although rescue
  752. operations are rather limited without mount!
  753. <item>fstab should contain:
  754. <tscreen><verb>
  755.         /dev/ram        /               ext2    defaults
  756.     /dev/fd0    /        ext2    defaults
  757.     /proc        /proc        proc    defaults
  758. </verb></tscreen>
  759. I don't think that the first entry is really needed, but I 
  760. find that if I leave it out, mount won't mount /proc.
  761. </itemize>
  762.  
  763. Inittab should be ok as is, unless you want to ensure that users on
  764. serial ports cannot login. To prevent this, comment out all the entries
  765. for /etc/getty which include a ttys or ttyS device at the end of the line.
  766. Leave in the tty ports so that you can login at the console.
  767.  
  768. Inittab defines what the system will run or rerun in various states
  769. including startup, move to multi-user mode, powerfail, and others.
  770. A point to be careful of here is to carefully check that the commands
  771. entered in inittab refer to programs which are present and to the 
  772. correct directory. If you place your command files on your rescue disk
  773. using the sample directory listing in this HOWTO as a guide, and then
  774. copy your inittab to your rescue disk without checking it, then the
  775. probability of failure will be quite high, because half of the
  776. inittab entries will refer to missing programs or to the wrong
  777. directory.
  778.  
  779. It is worth noting here as well that some programs cannot be moved
  780. from one directory to another or they will fail at runtime because
  781. they have hardcoded the name of another program which they attempt
  782. to run. For example on my system, <tt>/etc/shutdown</tt> has hardcoded in
  783. it <tt>/etc/reboot</tt>. If I move reboot to /bin/reboot, and then
  784. issue a shutdown command, it will fail because it can't find the 
  785. reboot file.
  786.  
  787. For the rest, just copy all the text files in your /etc directory, plus
  788. all the executables in your /etc directory that you cannot be sure you
  789. do not need. As a guide, consult the sample ls listing in 
  790. "Sample Boot/Root ls-lR Directory Listing" -
  791. this is what I have, so probably it will be sufficient for you if 
  792. you copy only those files - but note that systems differ a great 
  793. deal, so you cannot be sure that the same set of files on your 
  794. system is equivalent to the files on mine. The only sure method is
  795. to start with inittab and work out what is required.
  796.  
  797. Most systems now use
  798. an /etc/rc.d directory containing shell scripts for different run levels.
  799. The absolute minimum is a single rc script, but it will probably be
  800. a lot simpler in practice to copy the inittab and /etc/rc.d directory
  801. from your existing system, and prune the shell scripts in the rc.d
  802. directory to remove processing not relevent to a diskette system
  803. environment.
  804.  
  805. <sect2>/bin
  806. <p>
  807. Here is a convenient point to place the extra utilities you need to
  808. perform basic operations, utilities such as ls, mv, cat, dd etc.
  809.  
  810. See the section titled "Sample Boot/Root ls-lR Directory Listing" 
  811. for the list of files that I place in my boot/root /bin
  812. directory. You may notice that it does not include any of the utilities 
  813. required to restore from backup, such as 
  814. cpio, tar, gzip etc. That is because I place these on a separate
  815. utility diskette, to save space on the boot/root diskette. Once I
  816. have booted my boot/root diskette, it then copies itself to the ramdisk
  817. leaving the diskette drive free to mount another diskette, the utility
  818. diskette. I usually mount this as /usr.
  819.  
  820. Creation of a utility diskette is described below in the section
  821. titled "Adding Utility Diskettes".
  822.  
  823. <sect2>/lib
  824. <p>
  825. In /lib you place necessary shared libraries and loaders.  If the
  826. necessary libraries are not found in your /lib directory then the
  827. system will be unable to boot. If you're lucky you may see an error
  828. message telling you why.
  829.  
  830. Nearly every program requires at least the libc library:
  831. <tscreen><verb>
  832.     libc.so.X
  833. </verb></tscreen>
  834. where X is the current version number.  Check your /lib directory.
  835. Note that libc.so.4 may be a symlink to a libc library with version
  836. number in the filename. If you issue the command:
  837. <tscreen><verb>
  838.     ls -l /lib
  839. </verb></tscreen>
  840. you will see something like:
  841. <tscreen><verb>
  842.     libc.so.4 -> libc.so.4.5.21
  843. </verb></tscreen>
  844.  
  845. In this case, the libc library you want is libc.so.4.5.21. This is
  846. an example only - the ELF libc library is currently libc.so.5.xxxx.
  847.  
  848. To find other libraries you should go through all the binaries you
  849. plan to include and check their dependencies.  You can do this with
  850. ldd command.  For example, on my system the command:
  851. <tscreen><verb>
  852.     ldd /bin/mount
  853. </verb></tscreen>
  854. produces the output:
  855. <tscreen><verb>
  856.     /bin/mount:
  857.         libc.so.5 => /lib/libc.so.5.2.18
  858. </verb></tscreen>
  859. indicating that /bin/mount needs the library libc.so.5, which is a
  860. symbolic link to libc.so.5.2.18.
  861.  
  862. In /lib you must also include one or more loaders to load the
  863. libraries.  The loader file is either ld.so (for a.out libraries) or
  864. ld-linux.so (for ELF libraries).  If you're not sure which you need,
  865. run the "file" command on the library.  For example, on my system:
  866. <tscreen><verb>
  867.     file /lib/libc.so.5.2.18
  868. </verb></tscreen>
  869. tells me:
  870. <tscreen><verb>
  871.     /lib/libc.so.5.2.18: ELF 32-bit LSB shared object ...
  872. </verb></tscreen>
  873. so it needs an ELF loader.  If you have an a.out library you'll
  874. instead see something like:
  875. <tscreen><verb>
  876.     /lib/libc.so.4.7.2: Linux/i386 demand-paged executable (QMAGIC) ...
  877. </verb></tscreen>
  878.  
  879. Copy the specific loader(s) you need.
  880.  
  881. Libraries and loaders should be checked carefully against the included
  882. binaries.  If the kernel cannot load a necessary library, the kernel will
  883. usually hang with no error message.
  884.  
  885. <sect1>LILO
  886. <p>
  887. <sect2>Overview
  888. <p>
  889. For the boot/root to be any use, it must be bootable. To achieve this,
  890. the easiest way is to install a boot loader,
  891. which is a piece of executable code stored at sector 0, cylinder 0 of
  892. the diskette. See the section above titled "BOOT DISKETTE" for an
  893. overview of the boot process.
  894.  
  895. LILO is a tried and trusted boot loader available from any Linux
  896. mirror site. It allows you to configure the boot loader, including:
  897. <itemize>
  898. <item>Which device is to be mounted as the root drive.
  899. <item>Whether to use a ramdisk.
  900. </itemize>
  901.  
  902. <sect2>Sample LILO Configuration
  903. <p>
  904. This provides a very convenient place to specify to the kernel how
  905. it should boot. My root/boot LILO configuration file, used with
  906. LILO 0.15, is:
  907. <tscreen><code>
  908. boot = /dev/fd0
  909. install = ./mnt/boot.b
  910. map = ./mnt/lilo.map
  911. delay = 50
  912. message = ./mnt/lilo.msg
  913. timeout = 150
  914. compact
  915. image = ./mnt/zImage 
  916.     ramdisk = 1440
  917.     root = /dev/fd0
  918. </code></tscreen>
  919.  
  920. Note that I have not tested this recently, because I no longer use 
  921. LILO-based boot/root diskettes. There is no reason to suppose that it 
  922. does not still work, but if you try it and it fails, you must 
  923. read the LILO documentation to find out why. 
  924.  
  925. Note also that boot/root systems no longer rely on LILO, because since
  926. 1.3.48, the kernel supports loading a compressed root filesystem from
  927. the same diskette as the kernel. See the section "Advanced Bootdisk
  928. Creation" for details.
  929.  
  930. If you have a kernel later than 1.3.48, the "ramdisk = 1440" line is
  931. unnecessary and should be removed.
  932.  
  933. Note that boot.b, lilo.msg and the kernel must first have been copied to
  934. the diskette using a command similar to:
  935. <tscreen><code>
  936. cp /boot/boot.b ./mnt
  937. </code></tscreen>
  938.  
  939. If this is not done, then LILO will not run correctly at boot time if
  940. the hard disk is not available, and there is little point setting up
  941. a rescue disk which requires a hard disk in order to boot.
  942.  
  943. I run lilo using the command:
  944. <tscreen><verb>
  945.     /sbin/lilo -C <configfile>
  946. </verb></tscreen>
  947.  
  948. I run it from the directory containing the mnt directory where I have
  949. mounted the diskette. This means that I am telling LILO to install a
  950. boot loader on the boot device (/dev/fd0 in this case), to boot a 
  951. kernel in the root directory of the diskette.
  952.  
  953. I have also specified that I want the root device to be the diskette,
  954. and I want a ramdisk created of 1440 1K blocks, the same size as the
  955. diskette. Since I have created an ext2 file system on the diskette,
  956. this completes all the conditions required for Linux to automatically
  957. switch the root device to the ramdisk, and copy the diskette contents
  958. there as well.
  959.  
  960. The ramdisk features of Linux are described further in the section
  961. above titled "RAM DISKS AND BOOT/ROOT SYSTEMS".
  962.  
  963. It is also worth considering using the "single" parameter to cause
  964. Linux to boot in single-user mode. This could be useful to prevent
  965. users logging in on serial ports.
  966.  
  967. I also use the "DELAY" "MESSAGE" and "TIMEOUT" statements so
  968. that when I boot the disk, LILO will give me the opportunity to
  969. enter command line options if I wish. I don't need them at present,
  970. but I never know when I might want to set a different root device
  971. or mount a filesystem read-only.
  972.  
  973. The message file I use contains the message:
  974.  
  975. <tscreen><verb>
  976. Linux Boot/Root Diskette
  977. ========================
  978.  
  979. Enter a command line of the form:
  980.  
  981.       zImage [ command-line options]
  982.  
  983. If nothing is entered, linux will be loaded with
  984. defaults after 15 seconds.
  985. </verb></tscreen>
  986.  
  987. This is simply a reminder to myself what my choices are.
  988.  
  989. Readers are urged to read the LILO documentation carefully before 
  990. atttempting to install anything. It is relatively easy to destroy
  991. partitions if you use the wrong "boot = " parameter. If you are
  992. inexperienced, do NOT run LILO until you are sure you understand it
  993. and you have triple-checked your parameters.
  994.  
  995. Note that you must re-run LILO every time you change the kernel, so
  996. that LILO can set up its map file to correctly describe the new
  997. kernel file. It is in fact possible to replace the kernel file with
  998. one which is almost identical without rerunning LILO, but it is far
  999. better not to gamble - if you change the kernel, re-run LILO.
  1000.  
  1001. <sect2>Removing LILO
  1002. <p>
  1003. One other thing I might as well add here while I'm on the LILO topic:
  1004. if you mess up lilo on a drive containing DOS, you can always replace
  1005. the boot sector with the DOS boot loader by issuing the DOS command:
  1006. <tscreen><verb>
  1007.     FDISK /MBR
  1008. </verb></tscreen>
  1009.  
  1010. where MBR stands for "Master Boot Record". Note that some purists
  1011. disagree with this, and they may have grounds, but it works.
  1012.  
  1013. <sect2>Useful LILO Options
  1014. <p>
  1015.  
  1016. LILO has several useful options which are worth keeping in mind when
  1017. building boot disks:
  1018. <itemize>
  1019. <item>Command line options - you can enter command line options 
  1020. to set the root device, ramdisk size (for kernels less than 1.3.48),
  1021. special device parameters, or
  1022. other things. If you include the DELAY = nn statement in your LILO
  1023. configuration file, then LILO will pause to allow you to select
  1024. a kernel image to boot, and to enter, on the same line, any options.
  1025. For example:
  1026. <tscreen><verb>
  1027.     zImage aha152x=0x340,11,3,1 ro 
  1028. </verb></tscreen>
  1029. will pass the aha152x parameters through to the aha152x scsi disk
  1030. driver (provided that driver has been included when the kernel was
  1031. built) and will ask for the root filesystem to be mounted read-only.
  1032. <item>Command line "lock" option - this option asks LILO to store
  1033. the command line entered as the default command line to be used for
  1034. all future boots. This is particularly useful where you have a device
  1035. which cannot be autoselected. By using "lock" you can avoid having
  1036. to type in the device parameter string every time you boot.
  1037. For example:
  1038. <tscreen><verb>
  1039.     zImage aha152x=0x340,11,3,1 root=/dev/sda8 ro lock
  1040. </verb></tscreen>
  1041. <item>APPEND configuration statement - this allows device parameter
  1042. strings to be stored in the configuration, as an alternative to 
  1043. using the "lock" command line option. Note that any keywords of 
  1044. the form word=value MUST be enclosed in quotes. For example:
  1045. <tscreen><verb>
  1046.     APPEND = "aha152x=0x340,11,3,1"
  1047. </verb></tscreen>
  1048. <item>DELAY configuration statement - this pauses for DELAY tenths
  1049. of seconds and allows the user to interrupt the automatic boot of
  1050. the default command line, so that the user can enter an alternate
  1051. command line.
  1052. </itemize>
  1053.  
  1054. <sect>Advanced Bootdisk Creation
  1055. <p>
  1056. <sect1>Overview
  1057. <p>
  1058. Previous Sections of this document covered the basics of creating
  1059. boot/root disks, and are applicable to nearly all kernels up to the
  1060. present (2.0, the latest stable kernel).
  1061.  
  1062. Kernels 1.3.48+ involved a substantial rewrite of the ramdisk code,
  1063. adding significant new capabilities.  These kernels could automatically
  1064. detect compressed filesystems, uncompress them and load them into the
  1065. ramdisk on boot-up.  Root filesystems could be placed on a second disk,
  1066. and as of kernel 1.3.98 or so, ramdisks are dynamically expandable.
  1067.  
  1068. Altogether, these new capabilities mean that boot disks can contain
  1069. substantially more than they used to.  With compression, a 1722K disk may
  1070. now hold up to about 3.5 megs of files.  As anyone who has created
  1071. bootdisks knows, much time is spent pruning down the file set and finding
  1072. trimmed-down versions of files that will all fit in a small filesystem.
  1073. With the new capabilities this is no longer such a concern.
  1074.  
  1075. Unfortunately, creating bootdisks to exploit these new features is
  1076. slightly more difficult now.  To build a compressed filesystem on a
  1077. floppy, the filesystem has to be built on another device and then
  1078. compressed and transferred to the floppy.  This means a few more steps.
  1079.  
  1080. The basic strategy is to create a compressed root filesystem, copy the
  1081. kernel to the floppy disk, tell the kernel where to find the root
  1082. filesystem, then copy the compressed root filesystem to the floppy.
  1083.  
  1084. Here's a simple ASCII drawing of what the disk will look like:
  1085. <tscreen><verb>
  1086. |<--- zImage --->|<------ Compressed root filesystem -------->|
  1087. |________________|____________________________________________|
  1088.          Floppy disk space
  1089. </verb></tscreen>
  1090.  
  1091. Here are the steps to create the boot floppy:
  1092.  
  1093. <sect1>Creating a root filesystem
  1094. <p>
  1095. The root filesystem is created pretty much the same way as outlined in
  1096. Section 2.3 of this document.  The primary difference is that you can no
  1097. longer create a root filesystem directly on a floppy -- you must create
  1098. it on a separate device larger than the floppy area it will occupy.
  1099.  
  1100. <sect2>Choosing a device
  1101. <p>
  1102. In order to build such a root filesystem, you need a spare device that is
  1103. large enough.  There are several choices:
  1104. <itemize>
  1105. <item>If you have an unused hard disk partition that is large enough
  1106. (several megabytes), this is the easiest solution.
  1107. Alternatively, if you have enough physical RAM you can simply
  1108. turn off swapping and build the filesystem in your swap
  1109. partition.
  1110.  
  1111. However, most people don't have a spare partition and can't afford
  1112. to turn swapping off, so...
  1113. <item>Use a loopback device.  A loopback device allows a disk file on
  1114. an existing filesystem to be treated as a device.  In order to
  1115. use loopback devices you need specially modified mount
  1116. and unmount programs.  You can find these at:
  1117. <tscreen><verb>
  1118.     ftp://ftp.win.tue.nl:/pub/linux/util/mount-2.5X.tar.gz
  1119. </verb></tscreen>
  1120. where X is the latest modification letter. 
  1121.  
  1122. If you do not have loop devices (/dev/loop0, /dev/loop1, etc) on your
  1123. system, you'll have to create them first.  The command 
  1124. <tscreen><verb>
  1125.         MAKEDEV loop 
  1126. </verb></tscreen> 
  1127. will do this.  <footnote>Older MAKEDEV scripts may not know about loop devices.
  1128. A MAKEDEV that can create loop devices is available in the directory
  1129. <tt>ftp://tsx-11.mit.edu/pub/linux/sources/sbin/</tt> </footnote>
  1130.  
  1131. One you've installed these special mount/umount binaries,
  1132. create a temporary file on a hard disk with enough capacity (eg,
  1133. /tmp/fsfile).  You can use a command like 
  1134. <tscreen><verb>
  1135.         dd if=/dev/zero of=/tmp/fsfile bs=1k count=nnn
  1136. </verb></tscreen>
  1137. to create an <it/nnn/-block file.
  1138.  
  1139. Use the file name in place of DEVICE below.
  1140. When you issue a mount command you must include the
  1141. option "-o loop" to tell mount to use a loopback device.  
  1142. For example:
  1143. <tscreen><verb>
  1144.     mount -o loop -t ext2 /tmp/fsfile /mnt
  1145. </verb></tscreen>
  1146.  
  1147. will mount /tmp/fsfile (via a loopback device) at the mount point
  1148. /mnt.  A 'df' will confirm this.
  1149. <item>A final option is to use the ramdisk (DEVICE = /dev/ram or
  1150. /dev/ramdisk).  In this case, RAM is used to simulate a disk
  1151. drive.  The ramdisk must be large enough to hold a
  1152. filesystem of the appropriate size. Check your Lilo configuration file
  1153. (/etc/lilo.conf) for a line like:
  1154. <tscreen><verb>
  1155.     RAMDISK_SIZE = nnn
  1156. </verb></tscreen>
  1157. which determines how much RAM will be allocated.  The default
  1158. is 4096K.
  1159. </itemize>
  1160.        
  1161. After you've chosen one of these options, prepare the device with:
  1162. <tscreen><verb>
  1163.     dd if=/dev/zero of=DEVICE bs=1k count=3000
  1164. </verb></tscreen>
  1165.  
  1166. This command zeroes out the device.  This step is important because the
  1167. filesystem on the device will be compressed later, so all unused
  1168. portions should be filled with zeroes to achieve maximum compression.
  1169.  
  1170. Next, create the filesystem with:
  1171. <tscreen><verb>
  1172.     mke2fs -m 0 DEVICE
  1173. </verb></tscreen>
  1174.  
  1175. (If you're using a loopback device, the disk file you're using should be
  1176. supplied in place of this DEVICE.  In this case, mke2fs will ask if you
  1177. really want to do this; say yes.)
  1178.  
  1179. Then mount the device:
  1180. <tscreen><verb>
  1181.     mount -t ext2 DEVICE /mnt
  1182. </verb></tscreen>
  1183.  
  1184. Proceed as before, copying files into /mnt, as specified in Section 2.3.
  1185.  
  1186. <sect2>Compressing the filesystem
  1187. <p>
  1188. After you're done copying files into the root filesystem, you need to
  1189. copy it back out and compress it.  First, umount it:
  1190. <tscreen><verb>
  1191.     umount /mnt
  1192. </verb></tscreen>
  1193.  
  1194. (Technically you can copy the filesystem without unmounting it first,
  1195. but that's somewhat dangerous, and bad practice.)
  1196.  
  1197. Next, copy data off the device to a disk file.  Call the disk file
  1198. <tt/rootfs/:
  1199. <tscreen><verb>
  1200.     dd if=DEVICE of=rootfs bs=1k
  1201. </verb></tscreen>
  1202.  
  1203. Then compress it.  Use the '-9' option of gzip for maximal compression:
  1204. <tscreen><verb>
  1205.     gzip -9 rootfs
  1206. </verb></tscreen>
  1207.  
  1208. This may take several minutes.  When it finishes, you'll have a file
  1209. rootfs.gz that is your compressed root filesystem.
  1210.  
  1211. If you're tight on disk space you can combine dd and gzip:
  1212. <tscreen><verb>
  1213.     dd if=DEVICE bs=1k | gzip -9 > rootfs.gz
  1214. </verb></tscreen>
  1215.  
  1216. <sect1>Calculating the space
  1217. <p>
  1218. At this point, check the space to make sure both the kernel and the root
  1219. filesystem will fit on the floppy.  An "ls -l" will show how many bytes
  1220. each occupies; divide by 1024 to determine how many blocks each will
  1221. need.  For partial blocks, be sure to round up to the next block.
  1222.  
  1223. For example, if the kernel size is 453281 bytes, it will need
  1224. <tscreen><verb>
  1225.     ceil(453281 / 1024) = 443
  1226. </verb></tscreen>
  1227. blocks, so it will occupy blocks 0-442 on the floppy disk.  The
  1228. compressed root filesystem will begin at block 443.  Remember this
  1229. block number for the commands to follow; call it ROOTBEGIN.
  1230.  
  1231. You must tell the kernel where on the floppy to find the root
  1232. filesystem.  Inside the kernel image is a ramdisk word that specifies
  1233. where the root filesystem is to be found, along with other options.  The
  1234. word is defined in /usr/src/linux/arch/i386/kernel/setup.c and is
  1235. interpreted as follows:
  1236. <tscreen><verb>
  1237.     bits  0-10:    Offset to start of ramdisk, in 1024 byte blocks
  1238.             (This is ROOTBEGIN, calculated above)
  1239.     bits 11-13:    unused
  1240.     bit     14:    Flag indicating that ramdisk is to be loaded
  1241.     bit    15:    Flag indicating to prompt for floppy
  1242. </verb></tscreen>
  1243.  
  1244. (If bit 15 is set, on boot-up you will be prompted to place a new floppy
  1245. disk in the drive.  This is necessary for a two-disk boot set, discussed
  1246. below in the section "Making a two-disk set".  For now, this will be zero.)
  1247.  
  1248. If the root filesystem is to begin at block 443, the ramdisk word is
  1249. <tscreen><verb>
  1250.     1BB (hex)    443 (decimal)     (bits 0-10)
  1251.      + 4000 (hex)       Ramdisk load flag (bit 14)
  1252.        ----------
  1253.      = 41BB (hex) 
  1254.      =16827 (decimal)
  1255. </verb></tscreen>
  1256.  
  1257. This ramdisk word will be set in the kernel image using the "rdev -r"
  1258. command in the next section.
  1259.  
  1260. <sect1>Copying files to the floppy
  1261. <p>
  1262.    
  1263. At this point you're ready to create the boot floppy.  First copy the
  1264. kernel:
  1265. <tscreen><verb>
  1266.     dd if=zImage of=/dev/fd0
  1267. </verb></tscreen>
  1268.  
  1269. Next, tell the kernel to find its root filesystem on the floppy:
  1270. <tscreen><verb>
  1271.     rdev /dev/fd0 /dev/fd0
  1272. </verb></tscreen>
  1273.  
  1274. Next, you have to set the ramdisk word in the kernel image now residing
  1275. on the floppy.  The ramdisk word is set using the "rdev -r" command.
  1276. Using the figure calculated above in the section titled 
  1277. "Calculating the space":
  1278. <tscreen><verb>
  1279.     rdev -r zImage 16827
  1280. </verb></tscreen>
  1281.  
  1282. Finally, place the root filesystem on the floppy after the kernel.  The
  1283. <tt/dd/ command has a <tt/seek/ option that allows you to specify how many
  1284. blocks to skip:
  1285. <tscreen><verb>
  1286.     dd if=rootfs.gz of=/dev/fd0 bs=1k seek=443
  1287. </verb></tscreen>
  1288.  
  1289. (The value 443 is ROOTBEGIN from the section "Calculating the space" above.)
  1290.  
  1291. Wait for the floppy drive to finish writing, and you're done.
  1292.  
  1293. <sect1>Making a two-disk set
  1294. <p>
  1295. If you want more space, you can make a two-disk boot set.  In this case,
  1296. the first floppy disk will contain the kernel alone, and the second will
  1297. contain the compressed root filesystem.  With this configuration you can use a
  1298. compressed filesystem of up to 1440K.
  1299.  
  1300. A two-disk set is created using a simple variation of the instructions
  1301. above.  First, you must set the ramdisk PROMPT flag to 1 to instruct the
  1302. kernel to prompt and wait for the second floppy.  The root filesystem
  1303. will begin at byte 0 of the second floppy.  
  1304.  
  1305. From the section "Calculating the space" above, the ramdisk
  1306. PROMPT flag (bit 15) will be set to 1, and
  1307. the ramdisk offset will be zero.  In our example the new calculation
  1308. would be:
  1309. <tscreen><verb>
  1310.         4000 (hex)      Ramdisk load flag (bit 14)
  1311.           +    8000 (hex)    Ramdisk prompt flag (bit 15)
  1312.               ------------
  1313.               = C000 (hex)
  1314.               =49152 (decimal)
  1315. </verb></tscreen>
  1316.  
  1317. which would be used in the 'rdev -r' calculation as before.
  1318.  
  1319. Follow the instructions of "Copying files to the floppy" above, but
  1320. after issuing the 'rdev -r'
  1321. command, put a new floppy in the drive and issue the command:
  1322. <tscreen><verb>
  1323.     dd if=rootfs.gz of=/dev/fd0
  1324. </verb></tscreen>
  1325.  
  1326. The <tt/seek/ option is not needed since the root filesystem starts at block
  1327. zero.
  1328.  
  1329. <sect>Samples
  1330. <p>
  1331. <sect1>Disk Directory Listings
  1332. <p>
  1333. This lists the contents of directories from my root and utility 
  1334. diskettes. These lists are provided as an example only of the files 
  1335. included to create a working system. I have added some explanatory
  1336. notes where it seemed useful.
  1337.  
  1338. <sect2>Root Disk ls-lR Directory Listing
  1339. <p>
  1340.  
  1341. <tscreen><verb>
  1342. total 18
  1343. drwxr-xr-x   2 root     root         1024 Jul 29 21:16 bin/
  1344. drwxr-xr-x   2 root     root         9216 Jul 28 16:21 dev/
  1345. drwxr-xr-x   3 root     root         1024 Jul 29 20:25 etc/
  1346. drwxr-xr-x   2 root     root         1024 Jul 28 19:53 lib/
  1347. drwxr-xr-x   2 root     root         1024 Jul 24 22:47 mnt/
  1348. drwxr-xr-x   2 root     root         1024 Jul 24 22:47 proc/
  1349. drwxr-xr-x   2 root     root         1024 Jul 28 19:07 sbin/
  1350. drwxr-xr-x   2 root     root         1024 Jul 29 20:57 tmp/
  1351. drwxr-xr-x   4 root     root         1024 Jul 29 21:35 usr/
  1352. drwxr-xr-x   3 root     root         1024 Jul 28 19:52 var/
  1353.  
  1354. bin:
  1355. total 713
  1356. -rwxr-xr-x   1 root     bin          7737 Jul 24 22:16 cat*
  1357. -rwxr-xr-x   1 root     bin          9232 Jul 24 22:48 chmod*
  1358. -rwxr-xr-x   1 root     bin          8156 Jul 24 22:48 chown*
  1359. -rwxr-xr-x   1 root     bin         19652 Jul 24 22:48 cp*
  1360. -rwxr-xr-x   1 root     root         8313 Jul 29 21:16 cut*
  1361. -rwxr-xr-x   1 root     bin         12136 Jul 24 22:48 dd*
  1362. -rwxr-xr-x   1 root     bin          9308 Jul 24 22:48 df*
  1363. -rwxr-xr-x   1 root     root         9036 Jul 29 20:24 dircolors*
  1364. -rwxr-xr-x   1 root     bin          9064 Jul 24 22:48 du*
  1365. -rwxr-x---   1 root     bin         69252 Jul 24 22:51 e2fsck*
  1366. -rwxr-xr-x   1 root     bin          5361 Jul 24 22:48 echo*
  1367. -rwxr-xr-x   1 root     bin          5696 Jul 24 22:16 hostname*
  1368. -rwxr-xr-x   1 root     bin          6596 Jul 24 22:49 kill*
  1369. -rwxr-xr-x   1 root     bin         10644 Jul 24 22:17 ln*
  1370. -rwxr-xr-x   1 root     bin         13508 Jul 24 22:17 login*
  1371. -rwxr-xr-x   1 root     bin         26976 Jul 24 22:17 ls*
  1372. -rwxr-xr-x   1 root     bin          7416 Jul 24 22:49 mkdir*
  1373. -rwxr-x---   1 root     bin         34596 Jul 24 22:51 mke2fs*
  1374. -rwxr-xr-x   1 root     bin          6712 Jul 24 22:49 mknod*
  1375. -rwxr-xr-x   1 root     bin         20304 Jul 24 22:17 more*
  1376. -rwxr-xr-x   1 root     bin         24704 Jul 24 22:17 mount*
  1377. -rwxr-xr-x   1 root     bin         12464 Jul 24 22:17 mv*
  1378. -rwxr-xr-x   1 root     bin         20829 Jul 24 22:50 ps*
  1379. -rwxr-xr-x   1 root     bin          9424 Jul 24 22:50 rm*
  1380. -rwxr-xr-x   1 root     bin          4344 Jul 24 22:50 rmdir*
  1381. -rwxr-xr-x   1 root     root       299649 Jul 27 14:12 sh*
  1382. -rwxr-xr-x   1 root     bin          9853 Jul 24 22:17 su*
  1383. -rwxr-xr-x   1 root     bin           380 Jul 27 14:12 sync*
  1384. -rwxr-xr-x   1 root     bin         13620 Jul 24 22:17 umount*
  1385. -rwxr-xr-x   1 root     root         5013 Jul 29 20:03 uname*
  1386.  
  1387. dev:
  1388. total 0
  1389. lrwxrwxrwx   1 root     root           10 Jul 24 22:34 cdrom -> /dev/sbpcd
  1390. crw--w--w-   1 root     tty        4,   0 Jul 24 21:49 console
  1391. brw-rw----   1 root     floppy     2,   0 Apr 28  1995 fd0
  1392. lrwxrwxrwx   1 root     root            4 Jul 24 22:34 ftape -> rft0
  1393. crw-rw-rw-   1 root     sys       10,   2 Jul 18  1994 inportbm
  1394. crw-rw----   1 root     kmem       1,   2 Jul 28 16:21 kmem
  1395. crw-rw----   1 root     kmem       1,   1 Jul 18  1994 mem
  1396. lrwxrwxrwx   1 root     root            4 Jul 24 22:34 modem -> cua0
  1397. lrwxrwxrwx   1 root     root            4 Jul 24 22:34 mouse -> cua1
  1398. crw-rw-rw-   1 root     sys        1,   3 Jul 18  1994 null
  1399. brw-rw----   1 root     disk       1,   1 Jul 18  1994 ram
  1400. crw-rw----   1 root     disk      27,   0 Jul 18  1994 rft0
  1401. brw-rw----   1 root     disk      25,   0 Jul 19  1994 sbpcd
  1402. ***  I have only included devices for the SCSI partitions I use.
  1403. ***  If you use IDE, then use /dev/hdxx instead.
  1404. brw-rw----   1 root     disk       8,   0 Apr 29  1995 sda
  1405. brw-rw----   1 root     disk       8,   6 Apr 29  1995 sda6
  1406. brw-rw----   1 root     disk       8,   7 Apr 29  1995 sda7
  1407. brw-rw----   1 root     disk       8,   8 Apr 29  1995 sda8
  1408. lrwxrwxrwx   1 root     root            7 Jul 28 12:56 systty -> console
  1409. ***  this link from systty to console is required
  1410. crw-rw-rw-   1 root     tty        5,   0 Jul 18  1994 tty
  1411. crw--w--w-   1 root     tty        4,   0 Jul 18  1994 tty0
  1412. crw--w----   1 root     tty        4,   1 Jul 24 22:33 tty1
  1413. crw--w----   1 root     tty        4,   2 Jul 24 22:34 tty2
  1414. crw--w--w-   1 root     root       4,   3 Jul 24 21:49 tty3
  1415. crw--w--w-   1 root     root       4,   4 Jul 24 21:49 tty4
  1416. crw--w--w-   1 root     root       4,   5 Jul 24 21:49 tty5
  1417. crw--w--w-   1 root     root       4,   6 Jul 24 21:49 tty6
  1418. crw-rw-rw-   1 root     tty        4,   7 Jul 18  1994 tty7
  1419. crw-rw-rw-   1 root     tty        4,   8 Jul 18  1994 tty8
  1420. crw-rw-rw-   1 root     tty        4,   9 Jul 19  1994 tty9
  1421. crw-rw-rw-   1 root     sys        1,   5 Jul 18  1994 zero
  1422.  
  1423. etc:
  1424. total 20
  1425. -rw-r--r--   1 root     root         2167 Jul 29 20:25 DIR_COLORS
  1426. -rw-r--r--   1 root     root           20 Jul 28 12:37 HOSTNAME
  1427. -rw-r--r--   1 root     root          109 Jul 24 22:57 fstab
  1428. -rw-r--r--   1 root     root          271 Jul 24 22:21 group
  1429. -rw-r--r--   1 root     root         2353 Jul 24 22:27 inittab
  1430. -rw-r--r--   1 root     root            0 Jul 29 21:02 issue
  1431. -rw-r--r--   1 root     root         2881 Jul 28 19:38 ld.so.cache
  1432. ***  Lots of things get upset at boot time if ld.so.cache is missing, but
  1433. ***  make sure that ldconfig is included and run from rc.x to
  1434. ***  update it.
  1435. -rw-r--r--   1 root     root           12 Jul 24 22:22 motd
  1436. -rw-r--r--   1 root     root          606 Jul 28 19:25 passwd
  1437. -rw-r--r--   1 root     root         1065 Jul 24 22:21 profile
  1438. drwxr-xr-x   2 root     root         1024 Jul 29 21:01 rc.d/
  1439. -rw-r--r--   1 root     root           18 Jul 24 22:21 shells
  1440. -rw-r--r--   1 root     root          774 Jul 28 13:43 termcap
  1441. -rw-r--r--   1 root     root          126 Jul 28 13:44 ttys
  1442. -rw-r--r--   1 root     root            0 Jul 24 22:47 utmp
  1443.  
  1444. etc/rc.d:
  1445. total 5
  1446. *** I didn't bother with shutdown scripts - everthing runs on a 
  1447. *** ramdisk, so there's not much point shutting it down.
  1448. -rwxr-xr-x   1 root     root         1158 Jul 24 22:23 rc.K*
  1449. -rwxr-xr-x   1 root     root         1151 Jul 28 19:08 rc.M*
  1450. -rwxr-xr-x   1 root     root          507 Jul 29 20:25 rc.S*
  1451.  
  1452. lib:
  1453. total 588
  1454. *** I have an ELF system, so I include the ELF loader ld-linux.so. if
  1455. *** you are still on a.out, then you need ld.so. Use the file command to
  1456. *** see which libraries you should include.
  1457. lrwxrwxrwx   1 root     root           17 Jul 24 23:36 ld-linux.so.1 -> ld-linux.so.1.7.3*
  1458. -rwxr-xr-x   1 root     root        20722 Aug 15  1995 ld-linux.so.1.7.3*
  1459. lrwxrwxrwx   1 root     root           13 Jul 24 23:36 libc.so.5 -> libc.so.5.0.9*
  1460. -rwxr-xr-x   1 root     root       562683 May 19  1995 libc.so.5.0.9*
  1461. ***  Must include libtermcap
  1462. lrwxrwxrwx   1 root     root           19 Jul 28 19:53 libtermcap.so.2 -> libtermcap.so.2.0.0*
  1463. -rwxr-xr-x   1 root     root        11360 May 19  1995 libtermcap.so.2.0.0*
  1464.  
  1465. mnt:
  1466. total 0
  1467.  
  1468. proc:
  1469. total 0
  1470.  
  1471. sbin:
  1472. total 191
  1473. ***  I use Slackware, which uses agetty. Many systems use getty. 
  1474. ***  Check your /etc/inittab to see which it uses. Note that you
  1475. ***  need (a)getty and login to be able to start doing much.
  1476. -rwxr-xr-x   1 root     bin         11309 Jul 24 22:54 agetty*
  1477. -rwxr-xr-x   1 root     bin          5204 Jul 24 22:19 halt*
  1478. ***  Must have this to boot
  1479. -rwxr-xr-x   1 root     bin         20592 Jul 24 22:19 init*
  1480. -rwxr-xr-x   1 root     root        86020 Jul 28 19:07 ldconfig*
  1481. -rwxr-xr-x   1 root     bin          5329 Jul 27 14:10 mkswap*
  1482. -rwxr-xr-x   1 root     root         5204 Jul 24 22:20 reboot*
  1483. -rwxr-xr-x   1 root     bin         12340 Jul 24 22:20 shutdown*
  1484. -rwxr-xr-x   1 root     root         5029 Jul 24 22:20 swapoff*
  1485. -rwxr-xr-x   1 root     bin          5029 Jul 24 22:20 swapon*
  1486. -rwxr-xr-x   1 root     root        20592 Jul 27 18:18 telinit*
  1487. -rwxr-xr-x   1 root     root         7077 Jul 24 22:20 update*
  1488.  
  1489. tmp:
  1490. total 0
  1491.  
  1492. usr:
  1493. total 2
  1494. drwxr-xr-x   2 root     root         1024 Jul 29 21:00 adm/
  1495. drwxr-xr-x   2 root     root         1024 Jul 29 21:16 lib/
  1496.  
  1497. usr/adm:
  1498. total 0
  1499.  
  1500. usr/lib:
  1501. total 0
  1502.  
  1503. var:
  1504. total 1
  1505. ***  Several things complained until I included this and 
  1506. ***  the /etc/rc.S code to initialise /var/run/utmp, but this
  1507. ***  won't necessarily apply to your system.
  1508. drwxr-xr-x   2 root     root         1024 Jul 28 19:52 run/
  1509.  
  1510. var/run:
  1511. total 0
  1512. </verb></tscreen>
  1513.  
  1514. <sect2>Utility Disk ls-lR Directory Listing
  1515. <p>
  1516.  
  1517. <tscreen><verb>
  1518. total 579
  1519. -rwxr-xr-x   1 root     root        42333 Jul 28 19:05 cpio*
  1520. -rwxr-xr-x   1 root     root       103560 Jul 29 21:31 elvis*
  1521. -rwxr-xr-x   1 root     root        56401 Jul 28 19:06 find*
  1522. -rw-r--r--   1 root     root       128254 Jul 28 19:03 ftape.o
  1523. -rwxr-xr-x   1 root     root        64161 Jul 29 20:47 grep*
  1524. -rwxr-xr-x   1 root     root        45309 Jul 29 20:48 gzip*
  1525. -rwxr-xr-x   1 root     root        23560 Jul 28 19:04 insmod*
  1526. -rwxr-xr-x   1 root     root          118 Jul 28 19:04 lsmod*
  1527. lrwxrwxrwx   1 root     root            5 Jul 28 19:04 mt -> mt-st*
  1528. -rwxr-xr-x   1 root     root         9573 Jul 28 19:03 mt-st*
  1529. lrwxrwxrwx   1 root     root            6 Jul 28 19:05 rmmod -> insmod*
  1530. -rwxr-xr-x   1 root     root       104085 Jul 28 19:05 tar*
  1531. lrwxrwxrwx   1 root     root            5 Jul 29 21:35 vi -> elvis*
  1532. </verb></tscreen>
  1533.  
  1534. <sect1>Shell Scripts to Build Diskettes
  1535. <p>
  1536. These shell scripts are provided as examples only. I use them on my 
  1537. system to create rescue diskettes. You may find it convenient to use them,
  1538. but if so, read the instructions carefully - for example, if you specify
  1539. the wrong swap device, you will find your root filesystem has been
  1540. throroughly and permanently erased.... so just be darn sure you have
  1541. it correctly configured before you use it!
  1542.  
  1543. The upside of the scripts are that they provide a quick way to get a
  1544. rescue set together, by doing the following:
  1545. <itemize>
  1546. <item>copy a kernel to a bootdisk, and use rdev to configure it, as explained
  1547. above.
  1548. <item>adjust mkroot to your system and build a root disk. Use the directory
  1549. listing above as a guide to what to include.
  1550. <item>use mkutil to throw your favourite utilities onto one or more 
  1551. utility disks.
  1552. </itemize>
  1553.  
  1554. There are two shell scripts:
  1555. <itemize>
  1556. <item>mkroot - builds a root or boot/root diskette.
  1557. <item>mkutil - builds a utility diskette.
  1558. </itemize>
  1559.  
  1560. Both are currently configured to run in the parent directory of
  1561. boot_disk and util_disk, each of which contains everything to be
  1562. copied to it's diskette. Note that these shell scripts will *NOT*
  1563. automatically set up and copy all the files for you - you work 
  1564. out which files are needed, set up the directories and copy the 
  1565. files to those directories. The shell scripts are samples which
  1566. will copy the contents of those directories. Note that they are
  1567. primitive shell scripts and are not meant for the novice user.
  1568.  
  1569. The scripts both contain configuration variables at the
  1570. start which allow them to be easily configured to run anywhere.
  1571. First, set up the model directories and copy all the required 
  1572. files into them. To see what directories and files are needed,
  1573. have a look at the sample directory listings in the previous
  1574. sections.
  1575.  
  1576. Check the configuration variables in the 
  1577. shell scripts and change them as required before running the 
  1578. scripts.
  1579.  
  1580. <sect2>mkroot - Make Root Diskette
  1581. <p>
  1582. <tscreen><code>
  1583. # mkroot: make a root disk - creates a root diskette
  1584. #      by building a file system on it, then mounting it and
  1585. #      copying required files from a model.
  1586. #      Note: the model to copy from from must dirst be set up,
  1587. #      then change the configuration variables below to suit
  1588. #      your system.
  1589. #
  1590. # usage: mkroot [ -d swap | ram ]
  1591. #    where swap means use $SWAPDEV swap device
  1592. #    and ram means use $RAMDISKDEV ramdisk device
  1593.  
  1594. # Copyright (c) Graham Chapman 1996. All rights reserved.
  1595. # Permission is granted for this material to be freely
  1596. # used and distributed, provided the source is acknowledged.
  1597. # No warranty of any kind is provided. You use this material
  1598. # at your own risk.
  1599.  
  1600. # Configuration variables - set these to suit your system
  1601. #
  1602. ####  set the device to use to build the root filesystem on.
  1603. ####  ramdisk is safer - swap is ok only if you have plenty of
  1604. ####  free memory. If linux can't swap then things get nasty.
  1605. USEDEVICE="ramdisk"        # set to either "ramdisk" or "swap"
  1606. RAMDISKDEV="/dev/ram"        # ramdisk device <==== CHANGE if using ramdisk
  1607. SWAPDEV="/dev/sda7"        # swap device    <==== CHANGE if using swap
  1608. FSBLOCKS=3072            # desired filesystem size in blocks
  1609. #
  1610. ####  set name or directory where you have set up your rootdisk
  1611. ####  model
  1612. ROOTDISKDIR="./root_disk"    # name of root disk directory
  1613. MOUNTPOINT="/mnt"        # temporary mount point for diskette
  1614. DISKETTEDEV="/dev/fd0"        # device name of diskette drive
  1615. LOGFL="`pwd`/mkroot.log"    # log filename
  1616. TEMPROOTFS="/tmp/mkrootfs.gz"    # temp file for compressed filesystem
  1617. # End of Configuration variables
  1618.  
  1619. # Internal variables
  1620. ROOTDISKDEV=
  1621.  
  1622. case $USEDEVICE in
  1623. swap|ramdisk)    :;;
  1624. *)    echo "Invalid setting for USEDEVICE variable"
  1625.     exit;;
  1626. esac
  1627.  
  1628. clear
  1629. echo "    ***************** W A R N I N G ******************
  1630.  
  1631. Use this script with care. If you don't understand it, then
  1632. exit NOW!"
  1633.  
  1634. if [ "$USEDEVICE" = "swap" ]
  1635. then
  1636.     ROOTDISKDEV=$SWAPDEV
  1637.     echo -e "\nThis script will temporarily remove the swap file $SWAPDEV"
  1638.     echo "and use the space to build a compressed root filesystem from"
  1639.     echo "the files in the directory tree below $ROOTDISKDIR. To do this"
  1640.     echo "safely you must have 8Mb or more of memory, and you should"
  1641.     echo "switch to single user mode via 'init 1'."
  1642.     echo -e "\nIf you have used a ramdisk since the last reboot, then"
  1643.     echo "reboot NOW before using this script."
  1644.     echo -e "\nIf the script fails, you may not have a swap partition. Run 'free'"
  1645.     echo "and check the total size to see if it is correct. If the swap"
  1646.     echo "partition $SWAPDEV is missing, do the following:"
  1647.     echo "    umount $MOUNTPOINT"
  1648.     echo "    mkswap $SWAPDEV"
  1649.     echo "    swapon $SWAPDEV"
  1650.     echo "to restore the swap partition $SWAPDEV."
  1651. else
  1652.     ROOTDISKDEV=$RAMDISKDEV
  1653.     echo -e "\nThis script will use a ramdisk of $FSBLOCKS Kb. To do this safely"
  1654.     echo "you must have at least 8Mb of memory. If you have only 8Mb you should"
  1655.     echo "ensure nothing else is running on the machine."
  1656.     echo -e "\nWhen the script is complete, the ramdisk will still be present, so"
  1657.     echo "you should reboot to reclaim the memory allocated to the ramdisk."
  1658. fi
  1659.  
  1660. echo -e "
  1661. Do you want to continue (y/n)? \c"
  1662. read ans
  1663. if [ "$ans" != "Y" -a $ans != "y" ]
  1664. then
  1665.     echo "not confirmed - aborting"
  1666.     exit 
  1667. fi
  1668.  
  1669. echo "Starting mkroot at `date`" > $LOGFL
  1670.  
  1671. if [ "$USEDEVICE" = "swap" ]
  1672. then
  1673.     echo "Unmounting swap device $SWAPDEV" | tee -a $LOGFL
  1674.     swapoff $SWAPDEV >> $LOGFL 2>&1
  1675. fi
  1676.  
  1677. echo "Zeroing device $ROOTDISKDEV" | tee -a $LOGFL
  1678. dd if=/dev/zero of=$ROOTDISKDEV bs=1024 count=$FSBLOCKS >> $LOGFL 2>&1
  1679. if [ $? -ne 0 ]
  1680. then
  1681.     echo "dd zeroing $ROOTDISKDEV failed" | tee -a $LOGFL
  1682.     exit 1
  1683. fi
  1684.  
  1685. echo "Creating filesystem on device $ROOTDISKDEV" | tee -a $LOGFL
  1686. mke2fs -m0 $ROOTDISKDEV $FSBLOCKS >> $LOGFL 2>&1
  1687.  
  1688. echo "Mounting $ROOTDISKDEV filesystem at $MOUNTPOINT" | tee -a $LOGFL
  1689. mount -t ext2 $ROOTDISKDEV $MOUNTPOINT >> $LOGFL 2>&1
  1690. if [ $? -ne 0 ]
  1691. then
  1692.     echo "mount failed"
  1693.     exit 1
  1694. fi
  1695.  
  1696. # copy the directories containing files
  1697. echo "Copying files from $ROOTDISKDIR to $MOUNTPOINT" | tee -a $LOGFL
  1698. currdir=`pwd`
  1699. cd $ROOTDISKDIR
  1700. find . -print | cpio -dpumv $MOUNTPOINT >> $LOGFL 2>&1
  1701. if [ $? -ne 0 ]
  1702. then
  1703.     echo "cpio step failed."
  1704.     cd $currdir
  1705.     exit 1
  1706. fi
  1707. cd $currdir
  1708.  
  1709. fssize=`du -sk $MOUNTPOINT|cut -d"    " -f1`
  1710. echo "Uncompressed root filesystem size is $fssize Kb" | tee -a $LOGFL
  1711. echo "Unmounting filesystem from $ROOTDISKDEV" | tee -a $LOGFL
  1712. umount $MOUNTPOINT >> $LOGFL 2>&1
  1713.  
  1714. echo "Compressing filesystem from $ROOTDISKDEV into $TEMPROOTFS
  1715.     This may take a few minutes..." | tee -a $LOGFL
  1716.  
  1717. #    We don't bother with gzip -9 here - takes more than twice as long
  1718. #    and saves less than 1% in space on my root disk...
  1719. dd if=$ROOTDISKDEV bs=1024 count=$FSBLOCKS 2>>$LOGFL | gzip -c > $TEMPROOTFS
  1720.  
  1721. fssize=`du -k $TEMPROOTFS|cut -d"    " -f1`
  1722. echo "Compressed root filesystem size is $fssize Kb" | tee -a $LOGFL
  1723.  
  1724. echo -e "Insert diskette in $DISKETTEDEV and press any key
  1725.     ***  Warning: data on diskette will be overwritten!\c"
  1726. read ans
  1727.  
  1728. echo "Copying compressed filesystem from $TEMPROOTFS to $DISKETTEDEV" | tee -a $LOGFL
  1729. dd if=$TEMPROOTFS of=$DISKETTEDEV >>$LOGFL 2>&1
  1730. if [ $? -ne 0 ]
  1731. then
  1732.     echo "copy step failed."
  1733.     exit 1
  1734. fi
  1735.  
  1736. if [ "$USEDEVICE" = "swap" ]
  1737. then
  1738.     echo "Reinitialising swap device $SWAPDEV" | tee -a $LOGFL
  1739.     mkswap $SWAPDEV >> $LOGFL 2>&1
  1740.     echo "Starting swapping to swap device $SWAPDEV" | tee -a $LOGFL
  1741.     swapon $SWAPDEV >> $LOGFL 2>&1
  1742. fi
  1743.  
  1744. echo "Deleting $TEMPROOTFS" | tee -a $LOGFL
  1745. rm $TEMPROOTFS
  1746.  
  1747. echo "mkroot completed at `date`" >> $LOGFL
  1748.  
  1749. echo "Root diskette creation complete - please read log file $LOGFL"
  1750.  
  1751. </code></tscreen>
  1752.  
  1753. <sect2>mkutil - Make Utility Diskette
  1754. <p>
  1755. <tscreen><code>
  1756. # mkutil: make a utility diskette - creates a utility diskette
  1757. #      by building a file system on it, then mounting it and
  1758. #      copying required files from a model.
  1759. #      Note: the model to copy from from must first be set up,
  1760. #      then change the configuration variables below to suit
  1761. #      your system.
  1762.  
  1763. # Copyright (c) Graham Chapman 1996. All rights reserved.
  1764. # Permission is granted for this material to be freely
  1765. # used and distributed, provided the source is acknowledged.
  1766. # No warranty of any kind is provided. You use this material
  1767. # at your own risk.
  1768.  
  1769. # Configuration variables...
  1770. UTILDISKDIR=./util_disk        # name of directory containing model
  1771. MOUNTPOINT=/mnt            # temporary mount point for diskette
  1772. DISKETTEDEV=/dev/fd0        # device name of diskette drive
  1773.  
  1774. echo $0: create utility diskette
  1775. echo Warning: data on diskette will be overwritten!
  1776. echo Insert diskette in $DISKETTEDEV and and press any key...
  1777. read anything
  1778.  
  1779. mke2fs $DISKETTEDEV
  1780. if [ $? -ne 0 ]
  1781. then
  1782.     echo mke2fs failed
  1783.     exit
  1784. fi
  1785.  
  1786. # Any file system type would do here
  1787. mount -t ext2 $DISKETTEDEV $MOUNTPOINT
  1788. if [ $? -ne 0 ]
  1789. then
  1790.     echo mount failed
  1791.     exit
  1792. fi
  1793.  
  1794. # copy the directories containing files
  1795. cp -dpr $UTILDISKDIR/* $MOUNTPOINT
  1796.  
  1797. umount $MOUNTPOINT
  1798.  
  1799. echo Utility diskette complete
  1800. </code></tscreen>
  1801.  
  1802. <sect>FAQ
  1803. <p>
  1804. <sect1>Q. I boot from my boot/root disks and nothing happens. What do I do?
  1805. <p>
  1806. This is the most common problem experienced by first-time root disk users,
  1807. and it can be quite tricky finding the cause. The basic problem is that
  1808. there is very little that is exactly the same in all Linux systems, but
  1809. to get a system to boot to the stage where it will talk to you requires 
  1810. several components to be present and correctly configured.
  1811.  
  1812. The first thing to be understood is that creating a root disk is usually
  1813. an iterative process. Requirements change as the kernel changes, and 
  1814. different distributions arrange things in different ways. The normal boot
  1815. process is for the kernel to execute /sbin/init, which in turn reads 
  1816. /etc/inittab to find out what to execute next... but anything is possible, so
  1817. to understand things you must RTFM, including:
  1818. <itemize>
  1819. <item>the man pages for init, inittab , agetty or getty, login, ldconfig.
  1820. <item>the kernel documentation in /usr/src/linux/Documentation.
  1821. <item>the /etc/rc.x scripts and /etc/inittab in your system.
  1822. </itemize>
  1823.  
  1824. The general approach to building a root disk is to assemble components from
  1825. your existing system, and try and get the diskette-based system to the 
  1826. point where it displays messages on the console. Once it starts talking to
  1827. you, the battle is half over, because you can see what it is complaining about,
  1828. and you can fix individual problems until the system works smoothly.
  1829.  
  1830. Inittab is possibly the trickiest part because its syntax and content
  1831. depend on the init program used and the nature of the system. The only 
  1832. way to tackle it really is to read the man pages for init and inittab and
  1833. work out exactly what your existing system is doing when it boots.
  1834.  
  1835. The recommended procedure for investigating the problem where the system will
  1836. not talk to you is as follows:
  1837. <itemize>
  1838. <item>check that the root disk actually contains the directories you think it
  1839. does. It is easy to copy at the wrong level so that you end up with something
  1840. like /root_disk/bin instead of /bin on your root diskette.
  1841. <item>check /sbin/init is present, and /etc/inittab has a system initialisation
  1842. entry. This should contain a command of the form /etc/rc.x, to execute one
  1843. of the /etc/rc scripts. The specific script in the inittab must exist.
  1844. <item>check what the the /etc/rc.x script specified in inittab does exist.
  1845. All commands that it executes must be present on the disk.
  1846. <item>check that there is a /lib/libc.so and /lib/libtermcap.so, with the same
  1847. links as appear in your lib directory on your hard disk. 
  1848. <item>check that any symbolic links in your /dev directory in your existing 
  1849. system also exist on your root diskette filesystem, where those links are to
  1850. devices which you have included in your root diskette. In particular,
  1851. /dev/console links are essential in many cases.
  1852. <item>check that you have included /dev/tty1 on your root disk.
  1853. <item>check that you have included /dev/null, /dev/zero, /dev/mem, /dev/ram 
  1854. and /dev/kmem devices.
  1855. <item>check your kernel configuration - support for all resources 
  1856. required up to login point must be built in, not modules. Also,
  1857. ramdisk support must be included.
  1858. <item>check that your kernel root device and ramdisk settings are
  1859. correct. Refer to the Advanced Bootdisk Creation section for details.
  1860. </itemize>
  1861.  
  1862. <sect1>Q. How can I make a boot disk with a XXX driver?
  1863. <p>
  1864. The easiest way is to obtain a Slackware kernel from your nearest 
  1865. Slackware mirror site. Slackware kernels are generic kernels which atttempt
  1866. to include drivers for as many devices as possible, so if you have a 
  1867. SCSI or IDE controller, chances are that a driver for it is included 
  1868. in the Slackware kernel.
  1869.  
  1870. Go to the a1 directory and select either IDE or SCSI
  1871. kernel depending on the type of controller you have. Check the xxxxkern.cfg
  1872. file for the selected kernel to see the drivers which have been included
  1873. in that kernel. If the device you want is in that list, then the
  1874. corresponding kernel should boot your computer. Download the xxxxkern.tgz
  1875. file and copy it to your boot diskette as described above in the section
  1876. on making boot disks.
  1877.  
  1878. You must then check the root device in the kernel, using the rdev
  1879. command:
  1880. <tscreen><verb>
  1881.     rdev zImage 
  1882. </verb></tscreen>
  1883.  
  1884. Rdev will then display the current root device in the kernel. If this
  1885. is not the same as the root device you want, then use rdev to change it.
  1886. For example, the kernel I tried was set to /dev/sda2, but my root
  1887. scsi partition is /dev/sda8. To use a root diskette, you would have
  1888. to use the command:
  1889. <tscreen><verb>
  1890.     rdev zImage /dev/fd0
  1891. </verb></tscreen>
  1892.  
  1893. If you want to know how to set up a Slackware root disk as well, 
  1894. that's outside the scope of this HOWTO, so I suggest you check the
  1895. Linux Install Guide or get the Slackware distribution. See the section
  1896. in this HOWTO titled "References".
  1897.  
  1898. <sect1>Q. How do I update my boot floppy with a new kernel?
  1899. <p>
  1900. Just copy the kernel to your boot diskette using the dd command for
  1901. a boot diskette without a filesystem, or the cp command for a
  1902. boot/root disk. Refer to the section in this HOWTO titled "Boot"
  1903. for details on creating a boot disk. The description applies equally
  1904. to updating a kernel on a boot disk.
  1905.  
  1906. <sect1>Q. How do I remove LILO so that I can use DOS to boot again?
  1907. <p>
  1908. This is not really a Bootdisk topic, but it is asked so often, so: the
  1909. answer is, use the DOS command:
  1910. <tscreen><verb>
  1911.     FDISK /MBR
  1912. </verb></tscreen>
  1913.  
  1914. MBR stands for Master Boot Record, and it replaces the boot sector
  1915. with a clean DOS one, without affecting the partition table. Some
  1916. purists disagree with this, but even the author of LILO, Werner
  1917. Almesberger, suggests it. It is easy, and it works.
  1918.  
  1919. You can also use the dd command to copy the backup saved by LILO
  1920. to the boot sector - refer to the LILO documentation if you wish
  1921. to do this.
  1922.  
  1923. <sect1>Q. How can I boot if I've lost my kernel AND my boot disk?
  1924. <p>
  1925. If you don't have a boot disk standing by, then probably
  1926. the easiest method is to obtain a Slackware kernel for your
  1927. disk controller type (IDE or SCSI) as described above for "How do I
  1928. make a boot disk with a XXX driver?". You can then boot your 
  1929. computer using this kernel, then repair whatever damage there is.
  1930.  
  1931. The kernel you get may not have the root device set to the disk
  1932. type and partition you want. For example, Slackware's generic
  1933. scsi kernel has the root device set to /dev/sda2, whereas my
  1934. root Linux partition happens to be /dev/sda8. In this case the
  1935. root device in the kernel will have to be changed.
  1936.  
  1937. You can still change the root device and ramdisk settings in the kernel
  1938. even if all you have is a kernel, and some other operating system,
  1939. such as DOS.
  1940.  
  1941. Rdev changes kernel settings by changing the
  1942. values at fixed offsets in the kernel file, so you can do the same
  1943. if you have a hex editor available on whatever systems you do still
  1944. have running - for example, Norton Utilities Disk Editor under DOS.
  1945. You then need to check and if necessary change the values in the 
  1946. kernel at the following offsets:
  1947. <tscreen><verb>
  1948. 0x01F8  Low byte of RAMDISK size
  1949. 0x01F9    High byte of RAMDISK size 
  1950. 0x01FC  Root minor device number - see below
  1951. 0X01FD  Root major device number - see below
  1952. </verb></tscreen>
  1953.  
  1954. The ramdisk size is the number of blocks of ramdisk to create. 
  1955. If you want to boot from a root diskette then set this to decimal
  1956. 1440, which is 0x05A0, thus set offset 0x01F8 to 0xA0 and
  1957. offset 0x01F9 to 0x05. This will allocate enough space for
  1958. a 1.4Mb diskette.
  1959.  
  1960. Note that the meaning of the ramdisk size word changed in kernel
  1961. version 1.3.48. This meaning is described in the section titled
  1962. "Advanced Bootdisk Creation".
  1963.  
  1964. The major and minor device numbers must be set to the device
  1965. you want to mount your root filesystem on. Some useful values
  1966. to select from are:
  1967. <tscreen><verb>
  1968. device        major minor
  1969. /dev/fd0        2     0   1st floppy drive
  1970. /dev/hda1        3      1   partition 1 on 1st IDE drive
  1971. /dev/sda1        8     1   partition 1 on 1st scsi drive
  1972. /dev/sda8        8     8   partition 8 on 1st scsi drive
  1973. </verb></tscreen>
  1974.  
  1975. Once you have set these values then you can write the file to 
  1976. a diskette using either Norton Utilities Disk Editor, or a program called
  1977. rawrite.exe. This program is included
  1978. in several distributions, including the SLS and Slackware distributions.
  1979. It is a DOS program which writes a file to the "raw" disk, starting 
  1980. at the boot sector, instead of writing it to the file system. If you use 
  1981. Norton Utilities, then you must write the file to a physical disk
  1982. starting at the beginning of the disk.
  1983.  
  1984. <sect1>Q. How can I make extra copies of boot/root diskettes?
  1985. <p>
  1986. It is never desirable to have just one set of rescue disks - 2 or 3
  1987. should be kept in case one is unreadable.
  1988.  
  1989. The easiest way of making copies of any diskettes, including 
  1990. bootable and utility diskettes, is to use the dd command to copy the
  1991. contents of the original diskette to a file on your hard drive, and 
  1992. then use the same command to copy the file back to a new diskette.
  1993. Note that you do not need to, and should not, mount the diskettes,
  1994. because dd uses the raw device interface.
  1995.  
  1996. To copy the original, enter the command:
  1997. <tscreen><verb>
  1998.     dd if=devicename of=filename
  1999.     where    devicename the device name of the diskette
  2000.         drive
  2001.     and    filename the name of the file where you
  2002.         want to copy to
  2003. </verb></tscreen>
  2004.  
  2005. For example, to copy from /dev/fd0 to a temporary file called 
  2006. /tmp/diskette.copy, I would enter the command:
  2007. <tscreen><verb>
  2008.     dd if=/dev/fd0 of=/tmp/diskette.copy
  2009. </verb></tscreen>
  2010.  
  2011. Omitting the "count" parameter, as we have done here, means that the 
  2012. whole diskette of 2880 (for a high-density) blocks will be copied.
  2013.  
  2014. To copy the resulting file back to a new diskette, insert the new
  2015. diskette and enter the reverse command:
  2016. <tscreen><verb>
  2017.     dd if=filename of=devicename
  2018. </verb></tscreen>
  2019.  
  2020. Note that the above discussion assumes that you have only one diskette
  2021. drive. If you have two of the same type, then you can copy diskettes
  2022. using a command like:
  2023. <tscreen><verb>
  2024.     dd if=/dev/fd0 of=/dev/fd1
  2025. </verb></tscreen>
  2026.  
  2027. <sect1>Q. How can I boot without typing in "ahaxxxx=nn,nn,nn" every time?
  2028. <p>
  2029. Where a disk device cannot be autodetected it is necessary to supply
  2030. the kernel with a command device parameter string, such as:
  2031. <tscreen><verb>
  2032.     aha152x=0x340,11,3,1
  2033. </verb></tscreen>
  2034. This parameter string can be supplied in several ways using LILO:
  2035. <itemize>By entering it on the command line every time the system 
  2036. is booted via LILO. This is boring, though.
  2037. <item>By using the LILO "lock" keyword to make it store the 
  2038. command line as the default command line, so that LILO will use
  2039. the same options every time it boots.
  2040. <item>By using the APPEND statement in the lilo config file. Note that 
  2041. the parameter string must be enclosed in quotes.
  2042. </itemize>
  2043.  
  2044. For example, a sample command line using the above parameter string
  2045. would be:
  2046. <tscreen><verb>
  2047.     zImage    aha152x=0x340,11,3,1 root=/dev/sda1 lock
  2048. </verb></tscreen>
  2049. This would pass the device parameter string through, and also ask the
  2050. kernel to set the root device to /dev/sda1 and save the whole command
  2051. line and reuse it for all future boots.
  2052.  
  2053. A sample APPEND statement is:
  2054. <tscreen><verb>
  2055.     APPEND = "aha152x=0x340,11,3,1"
  2056. </verb></tscreen>
  2057.  
  2058. Note that the parameter string must NOT be enclosed in quotes on the 
  2059. command line, but it MUST be enclosed in quotes in the APPEND statement.
  2060.  
  2061. Note also that for the parameter string to be acted on, the kernel 
  2062. must contain the driver for that disk type. If it does not, then there
  2063. is nothing listening for the parameter string, and you will have to 
  2064. rebuild the kernel to include the required driver. For details on
  2065. rebuilding the kernel, cd to /usr/src/linux and read the README, and
  2066. read the Linux FAQ and Installation HOWTO. Alternatively you could
  2067. obtain a generic kernel for the disk type and install that.
  2068.  
  2069. Readers are strongly urged to read the LILO documentation before
  2070. experimenting with LILO installation. Incautious use of the "BOOT"
  2071. statement can damage partitions.
  2072.  
  2073. <sect1>Q. How can I create an oversize ramdisk filesystem?
  2074. <p>
  2075. For kernels 1.3.48+, it is best to create a compressed filesystem as
  2076. described in Advanced Bootdisk Creation. If your kernel is earlier than
  2077. this, you can either upgrade, or refer to version 2.0 or below of
  2078. this HOWTO.
  2079.  
  2080. <sect1>Q. At boot time, I get error <tt>A: cannot execute B</tt>. Why?
  2081. <p>
  2082. There are several cases of program names being hardcoded in various
  2083. utilities. These cases do not occur everywhere, but they may explain
  2084. why an executable apparently cannot be found on your system even though
  2085. you can see that it is there. You can find out if a given program
  2086. has the name of another hardcoded by using the "strings" command and
  2087. piping the output through grep.
  2088.  
  2089. Known examples of hardcoding are:
  2090. <itemize>
  2091. <item>Shutdown in some versions has <tt>/etc/reboot</tt> hardcoded, so
  2092. <tt>reboot</tt> must be placed in the /etc directory.
  2093. <item>Init has caused problems for at least one person, with the kernel
  2094. being unable to find init. 
  2095. </itemize>
  2096. To fix these problems, either move the programs to the correct directory,
  2097. or change configuration files (e.g. inittab) to point to the correct
  2098. directory. If in doubt, put programs in the same directories as they
  2099. are on your hard disk, and use the same inittab and <tt>/etc/rc.d</tt>
  2100. files as they appear on your hard disk.
  2101.  
  2102. <sect1>Q. My kernel has ramdisk support, but initializes ramdisks of 0K
  2103. <p>
  2104. Where this occurs, a kernel message similar to:
  2105. <tscreen><verb>
  2106. Ramdisk driver initialized : 16 ramdisks of 0K size
  2107. </verb></tscreen>
  2108. appears as the kernel is booting. The size should be either the default 
  2109. of 4096K, or the size specified in kernel parameters ramdisk_size or ramdisk. 
  2110. If the size is 0K, it is probably because the size has been set to 0 by
  2111. kernel parameters at boot time. This
  2112. could possibly be because of an overlooked LILO configuration file parameter:
  2113. <tscreen><verb>
  2114. ramdisk 0
  2115. </verb></tscreen>
  2116.  
  2117. This was included in sample LILO configuration files included in some older
  2118. distributions, and was put there to override any previous kernel setting.
  2119. Since 1.3.48 it is irrelevant, because the ramdisk_size kernel parameter
  2120. now sets the maximum ramdisk size, not the size allocated at boot time.
  2121. No ramdisk memory is allocated at boot time.
  2122.  
  2123. The solution is to remove the LILO ramdisk parameter.
  2124.  
  2125. Note that if you attempt to use a ramdisk which has been set to 0K, then
  2126. behaviour can be unpredictable, and can result in kernel panics.
  2127.  
  2128. <sect>References
  2129. <p>
  2130. In this section, vvv is used in package names in place of the version,
  2131. to avoid referring here to specific versions. When retrieving a package,
  2132. always get the latest version unless you have good reasons for not
  2133. doing so.
  2134.  
  2135. <sect1>LILO - Linux Loader
  2136. <p>
  2137. Written by Werner Almesberger. Excellent boot loader, and the
  2138. documentation includes information on the boot sector contents and
  2139. the early stages of the boot process.
  2140.  
  2141. Ftp from: <tt>tsx-11.mit.edu:
  2142. /pub/linux/packages/lilo/lilo.vvv.tar.gz</tt>
  2143. also on sunsite and mirror sites.
  2144.  
  2145. <sect1>Linux FAQ and HOWTOs
  2146. <p>
  2147. These are available from many sources. Look at the usenet newsgroups
  2148. <tt/news.answers/ and <tt/comp.os.linux.announce/. 
  2149.  
  2150. Ftp from: <tt>sunsite.unc.edu:/pub/Linux/docs</tt>
  2151. <itemize>
  2152. <item>FAQ is in <tt>/pub/linux/docs/faqs/linux-faq</tt>
  2153. <item>HOWTOs are in <tt>/pub/Linux/docs/HOWTO</tt>
  2154. </itemize>
  2155.  
  2156. For WWW, start at the Linux documentation home page:
  2157. <tscreen><verb>
  2158. http://sunsite.unc.edu/mdw/linux.html
  2159. </verb></tscreen>
  2160.  
  2161. If desperate, send mail to:
  2162. <tscreen><verb>
  2163.     mail-server@rtfm.mit.edu
  2164. </verb></tscreen>
  2165.  
  2166. with the word "help" in the message, then follow the mailed instructions.
  2167.  
  2168. Note: if you haven't read the Linux FAQ and related documents such as the
  2169. Linux Installation HOWTO and the Linux Install Guide, then you should not
  2170. be trying to build boot diskettes.
  2171.  
  2172. <sect1>Ramdisk Usage
  2173. <p>
  2174. An excellent description of the how the new ramdisk code works may be found
  2175. with the documentation supplied with the Linux kernel.  See
  2176. /usr/src/linux/Documentation/ramdisk.txt.  It is written by Paul Gortmaker
  2177. and includes a section on creating a compressed ramdisk, similar to the 
  2178. section titled "Advanced Bootdisk Creation" of this HOWTO.
  2179.  
  2180. <sect1>Rescue Packages
  2181. <p>
  2182. <sect2>Bootkit
  2183. <p>
  2184. Written by Scott Burkett. Bootkit provides a flexible menu-driven
  2185. framework for managing rescue disk creation and contents. It uses the
  2186. Dialog package to provide nice menus, and a straight-forward directory
  2187. tree to contain definitions of rescue disk contents. The package
  2188. includes samples of the main files needed. The package
  2189. aims to provide only the framework; it is up to the user to work out
  2190. what to put on the disks and set up the config files accordingly.
  2191. For those users who don't mind doing this, it is a good choice.
  2192.  
  2193. Ftp from: <tt>sunsite.unc.edu:
  2194. /pub/Linux/system/Recovery/Bootkit-vvv.tar.gz</tt>
  2195.  
  2196. <sect2>CatRescue
  2197. <p>
  2198. Written by Oleg Kibirev. This package concentrates on saving space
  2199. on the rescue diskettes by extensive use of compression, and by
  2200. implementing executables as shells scripts. The doco includes some
  2201. tips on what to do in various disaster situations.
  2202.  
  2203. Ftp from: <tt>gd.cs.csufresno.edu/pub/sun4bin/src/CatRescue100.tgz</tt>
  2204.  
  2205. <sect2>Rescue Shell Scripts
  2206. <p>
  2207. Written by Thomas Heiling. This contains shell scripts to produce
  2208. boot and boot/root diskettes. It has some dependencies on specific
  2209. versions of other software such as LILO, and so might need some
  2210. effort to convert to your system, but it might be useful as a 
  2211. starting point if you wanted more comprehensive shell scripts than
  2212. are provided in this document.
  2213.  
  2214. Ftp from: <tt>sunsite.unc.edu:/pub/Linux/system/Recovery/rescue.tgz</tt>
  2215.  
  2216. <sect2>SAR - Search and Rescue
  2217. <p>
  2218. Written by Karel Kubat. SAR produces a rescue diskette, using 
  2219. several techniques to minimize the space required on the diskette.
  2220. The manual includes a description of the Linux boot/login process.
  2221.  
  2222. Ftp from: <tt>ftp.icce.rug.nl:/pub/unix/SAR-vvv.tar.gz</tt>
  2223.  
  2224. The manual is available via WWW from:
  2225.  
  2226. <tt>http://www.icce.rug.nl/karel/programs/SAR.html</tt>
  2227.  
  2228. <sect2>YARD
  2229. <p>
  2230. Written by Tom Fawcett.  Yard produces customized rescue diskettes using
  2231. the compressed ramdisk option of more recent kernels (1.3.48+).  Yard was
  2232. designed to automate most of the instructions in Section 4, above.
  2233. In addition, Yard checks your file selections (loaders and libraries, and
  2234. /etc/fstab, rc, and passwd) to make sure you've included everything
  2235. needed to make a bootable rescue disk.  Yard needs Perl 5 and LILO, and
  2236. works with kernel 1.3.48+.  
  2237.  
  2238. Ftp from: <tt>sunsite.unc.edu:/pub/Linux/system/Recovery/yard-1.n.tar.gz</tt>
  2239.  
  2240. A companion set of customized rescue specifications is available for use
  2241. with Yard.
  2242.  
  2243. Ftp from:
  2244. <tt>sunsite.unc.edu:/pub/Linux/system/Recovery/yard-prefabs-n.tar.gz</tt>
  2245.  
  2246. <sect1>Slackware Distribution
  2247. <p>
  2248. Apart from being one of the more popular Linux distributions around, it
  2249. is also a good place to get a generic kernel. It is available from
  2250. almost everywhere, so there is little point in putting addresses here.
  2251. </article>
  2252.