From Funtoo
Revision as of 13:31, 15 February 2011 by 404 Error (Talk)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Note: Draft for an experiment in progress. Accuracy here is random!


Information here may vary from day to day and hour to hour. It is a "pad" to help us to take various notes on a future and more complete tutorial on how produce netboot images for SPARC machines. Free feel to annotate if you wish.

Building a tftpboot image


  • Tilo (seems a bit buggy especially with large image => segfaults)
  • Linux kernel in itself

The Linux kernel way

  • Magic command (/in /usr/src/linux) : make tftpboot.img
    • Scans to get ELF entries (espcially _star and _end)
  • Requires a root.img file in /usr/src. This file is a ramdisk image (!= initrd ?). The smaller the better, so cramfs can be used therem of course busybox is required.
  • cramfs must be included built-in
  • Some Sun machines does not initialize their MMU so everything must fit in 4 Mb in their case (1 page)


  • Designed for having a small footprint, ideal (to check with rw mount points ? The Fs is readonly and limited around 272Mb in size, no possibility to remount it rw...).
  • Must be built in in kernel !
  • Basic structure:
 ├── bin
├── dev
├── etc
├── lib
├── lib64 -> lib
├── mnt
│   ├── cdrom
│   ├── floppy
│   └── funtoo
├── proc
├── sbin
├── sys
├── tmp
├── usr
│   ├── bin
│   └── sbin
└── var
  • Creation (mkdir and cd into it first) :
# mkdir -p bin sbin lib usr/bin usr/sbin usr/lib etc var sys proc sys dev etc mnt/floppy mnt/cdrom mnt/funtoo
# chmod -R 755 *
# chmod 1777 tmp
# ln -s lib64 lib
  • Emerge busybox in this subtree and remove unwanted files (eg. /usr/share/doc, and such). Ok because we ask for a static build (this stuff can be built with ulibc also... see also buildroot)
# CFLAGS="-O2 -pipe -mcpu=v9" USE="static make-symlinks" emerge --nodeps --root=/path/to/ramdisk/tree busybox
  • Recompile a Linux kernel and put the modules in the cramfs directory structure (make modules_install INSTALL_MOD_PATH=/path/to/ramdisk/tree)
    • Don't forget to put a default argument init=... (if is is suitable to keet the init deployed by busybox as is)
    • Put something useful in the cutomized init (can be a script) like
echo "Hello world"
  • Build the cramfs, name it root.img and put it in /usr/src
  • Build the tftpboot image => cd /usr/src/linux && make tftpboot.img
  • Put the image on a tftpserver
  • The boot process ends with : Error -3 while decompressing! with some blocks (ramdisk is 4096 in size... too small ? overwriting problem ?) :-(


  • Same philosophy but a volume image must be created them mounted through a loopback device then formatted....
  • Tried with a ramdisk of 32 Mb, okay it boots :-)

Notes on busybox

Several defects or gotchas noted :

  1. When something taken care of by BB is replaced by a "real" counterpart (e.g. copying a "real" fdisk binary instead of having the fdisk symlink pointing to BB) is run from the BB shell (ash), BB assumes it must run the internal command except when the command is run with its absolute path. ->
  1. Busybox is emerged with "simplified" modutils activated by default with brings many issues with modules dependencies (e.g. symbols not found when dealing with the ext3 module).
  1. BB mksf.ext2 overwrites the first 1024 bytes of a partition with zeros, thus killing the Sun disklabel on it the case of the first partition starting at sector 0 (required to be bootable from OpenBoot). Core utils mkfs.ext2 leave those 1024 first bytes untouched.

Documented in :