bootfloppy.txt 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. Building a Busybox Boot Floppy
  2. ==============================
  3. This document describes how to buid a boot floppy using the following
  4. components:
  5. - Linux Kernel (http://www.kernel.org)
  6. - uClibc: C library (http://www.uclibc.org/)
  7. - Busybox: Unix utilities (http://busybox.net/)
  8. - Syslinux: bootloader (http://syslinux.zytor.com)
  9. It is based heavily on a paper presented by Erik Andersen at the 2001 Embedded
  10. Systems Conference.
  11. Building The Software Components
  12. --------------------------------
  13. Detailed instructions on how to build Busybox, uClibc, or a working Linux
  14. kernel are beyond the scope of this document. The following guidelines will
  15. help though:
  16. - Stock Busybox from CVS or a tarball will work with no modifications to
  17. any files. Just extract and go.
  18. - Ditto uClibc.
  19. - Your Linux kernel must include support for initrd or else the floppy
  20. won't be able to mount it's root file system.
  21. If you require further information on building Busybox uClibc or Linux, please
  22. refer to the web pages and documentation for those individual programs.
  23. Making a Root File System
  24. -------------------------
  25. The following steps will create a root file system.
  26. - Create an empty file that you can format as a filesystem:
  27. dd if=/dev/zero of=rootfs bs=1k count=4000
  28. - Set up the rootfs file we just created to be used as a loop device (may not
  29. be necessary)
  30. losetup /dev/loop0 rootfs
  31. - Format the rootfs file with a filesystem:
  32. mkfs.ext2 -F -i 2000 rootfs
  33. - Mount the file on a mountpoint so we can place files in it:
  34. mkdir loop
  35. mount -o loop rootfs loop/
  36. (you will probably need to be root to do this)
  37. - Copy on the C library, the dynamic linking library, and other necessary
  38. libraries. For this example, we copy the following files from the uClibc
  39. tree:
  40. mkdir loop/lib
  41. (chdir to uClibc directory)
  42. cp -a libc.so* uClibc*.so \
  43. ld.so-1/d-link/ld-linux-uclibc.so* \
  44. ld.so-1/libdl/libdl.so* \
  45. crypt/libcrypt.so* \
  46. (path to)loop/lib
  47. - Install the Busybox binary and accompanying symlinks:
  48. (chdir to busybox directory)
  49. make PREFIX=(path to)loop/ install
  50. - Make device files in /dev:
  51. This can be done by running the 'mkdevs.sh' script. If you want the gory
  52. details, you can read the script.
  53. - Make necessary files in /etc:
  54. For this, just cp -a the etc/ directory onto rootfs. Again, if you want
  55. all the details, you can just look at the files in the dir.
  56. - Unmount the rootfs from the mountpoint:
  57. umount loop
  58. - Compress it:
  59. gzip -9 rootfs
  60. Making a SYSLINUX boot floppy
  61. -----------------------------
  62. The following steps will create the boot floppy.
  63. Note: You will need to have the mtools package installed beforehand.
  64. - Insert a floppy in the drive and format it with an MSDOS filesystem:
  65. mformat a:
  66. (if the system doesn't know what device 'a:' is, look at /etc/mtools.conf)
  67. - Run syslinux on the floppy:
  68. syslinux -s /dev/fd0
  69. (the -s stands for "safe, slow, and stupid" and should work better with
  70. buggy BIOSes; it can be omitted)
  71. - Put on a syslinux.cfg file:
  72. mcopy syslinux.cfg a:
  73. (more on syslinux.cfg below)
  74. - Copy the root file system you made onto the MSDOS formatted floppy
  75. mcopy rootfs.gz a:
  76. - Build a linux kernel and copy it onto the disk with the filename 'linux'
  77. mcopy bzImage a:linux
  78. Sample syslinux.cfg
  79. ~~~~~~~~~~~~~~~~~~~
  80. The following simple syslinux.cfg file should work. You can tweak it if you
  81. like.
  82. ----begin-syslinux.cfg---------------
  83. DEFAULT linux
  84. APPEND initrd=rootfs.gz root=/dev/ram0
  85. TIMEOUT 10
  86. PROMPT 1
  87. ----end-syslinux.cfg---------------
  88. Some changes you could make to syslinux.cfg:
  89. - This value is the number seconds it will wait before booting. You can set
  90. the timeout to 0 (or omit) to boot instantly, or you can set it as high as
  91. 10 to wait awhile.
  92. - PROMPT can be set to 0 to disable the 'boot:' prompt.
  93. - you can add this line to display the contents of a file as a welcome
  94. message:
  95. DISPLAY display.txt
  96. Additional Resources
  97. --------------------
  98. Other useful information on making a Linux bootfloppy is available at the
  99. following URLs:
  100. http://www.linuxdoc.org/HOWTO/Bootdisk-HOWTO/index.html
  101. http://www.linux-embedded.com/howto/Embedded-Linux-Howto.html
  102. http://linux-embedded.org/howto/LFS-HOWTO.html
  103. http://linux-embedded.org/pmhowto.html
  104. http://recycle.lbl.gov/~ldoolitt/embedded/ (Larry Doolittle's stuff)
  105. Possible TODOs
  106. --------------
  107. The following features that we might want to add later:
  108. - support for additional filesystems besides ext2, i.e. minix
  109. - different libc, static vs dynamic loading
  110. - maybe using an alternate bootloader