Difference between revisions of "Netboot-scratchpad"

From Funtoo Linux
Jump to: navigation, search
(Notes on busybox)
 
(3 intermediate revisions by one user not shown)
Line 77: Line 77:
 
* Tried with a ramdisk of 32 Mb, okay it boots :-)
 
* Tried with a ramdisk of 32 Mb, okay it boots :-)
  
= Minimalistic uclibc environment =
+
== Notes on busybox ==
  
Having BusyBox statically linked is cool but it has a drawback : adding additional programs requires thing to be statically linked as well... So let's try to build a minimalistic netboot environment with uClibc.
+
Several defects or gotchas noted :
  
== Getting and compiling Buildroot ==
+
# 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. ->
  
[[http://buildroot.uclibc.org Buildroot]] is a cool thing is a set of patches and scripts that help to build environment for embedded devices. Download the latest revision (no SPARC v9 support, removed for some reasons). So Config.in.arch in ./targets should read for sparc :
+
# 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).  
  
<pre>
+
# 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.
  
config BR2_sparc_v7
+
Documented in :
        bool "v7"
+
config BR2_sparc_cypress
+
        bool "cypress"
+
config BR2_sparc_v8
+
        bool "v8"
+
comment "SPARC v9 variants"
+
config BR2_sparc_v9
+
        bool "v9 generic"
+
config BR2_sparc_ultrasparc
+
        bool "UltraSPARC I/II"
+
config BR2_sparc_ultrasparc3
+
        bool "UltraSPARC III"
+
config BR2_sparc_niagara
+
        bool "Niagara"
+
comment "LEON SPARC needs gcc = 4.4.x"
+
config BR2_sparc_sparchfleon
+
        bool "hfleon"
+
config BR2_sparc_sparchfleonv8
+
        bool "hfleonv8"
+
config BR2_sparc_sparcsfleon
+
        bool "sfleon"
+
config BR2_sparc_sparcsfleonv8
+
        bool "sfleonv8"
+
config BR2_sparc_supersparc
+
        bool "supersparc"
+
config BR2_sparc_sparclite
+
        bool "sparclite"
+
config BR2_sparc_f930
+
        bool "f930"
+
config BR2_sparc_f934
+
        bool "f934"
+
config BR2_sparc_hypersparc
+
        bool "hypersparc"
+
config BR2_sparc_sparclite86x
+
        bool "sparclite86x"
+
config BR2_sparc_sparclet
+
        bool "sparclet"
+
config BR2_sparc_tsc701
+
        bool "tsc701"
+
endchoice
+
 
+
config BR2_SPARC_TYPE
+
        string
+
        default V7      if BR2_sparc_v7 || BR2_sparc_cypress || BR2_sparc_sparclite || BR2_sparc_f930 || BR2_sparc_f934 || BR2_sparc_sparclite86x || BR2_sparc_sparclet || BR2_sparc_tsc701 || BR2_sparc_sparchfleon || BR2_sparc_sparcsfleon
+
        default V8      if BR2_sparc_v8 || BR2_sparc_supersparc || BR2_sparc_hypersparc || BR2_sparc_sparchfleonv8 || BR2_sparc_sparcsfleonv8
+
        default V9      if BR2_sparc_v9 || BR2_sparc_v9a || BR2_sparc_v9b || BR2_sparc_ultrasparc || BR2_sparc_ultrasparc3 || BR2_sparc_niagara
+
</pre>
+
 
+
<pre>
+
 
+
<pre>
+
config BR2_GCC_TARGET_TUNE
+
        string
+
        default i386            if BR2_x86_i386
+
        default i486            if BR2_x86_i486
+
        default i586            if BR2_x86_i586
+
        default pentium-mmx    if BR2_x86_pentium_mmx
+
        default i686            if BR2_x86_i686
+
...
+
 
+
 
+
        default sparclite86x    if BR2_sparc_sparclite86x
+
        default sparclet        if BR2_sparc_sparclet
+
        default tsc701          if BR2_sparc_tsc701
+
        default v9              if BR2_sparc_v9
+
        default v9              if BR2_sparc_v9a
+
        default v9              if BR2_sparc_v9b
+
        default ultrasparc      if BR2_sparc_ultrasparc
+
        default ultrasparc3    if BR2_sparc_ultrasparc3
+
        default niagara        if BR2_sparc_niagara
+
 
+
</pre>
+
 
+
<pre>
+
config BR2_GCC_TARGET_CPU
+
        string
+
        default sparchfleon    if BR2_sparc_sparchfleon
+
        default sparchfleonv8  if BR2_sparc_sparchfleonv8
+
        default v9              if BR2_sparc_v9
+
        default v9              if BR2_sparc_v9a
+
        default v9              if BR2_sparc_v9b
+
        default ultrasparc      if BR2_sparc_ultrasparc
+
        default ultrasparc3    if BR2_sparc_ultrasparc3
+
        default niagara        if BR2_sparc_niagara
+
</pre>
+
 
+
* When compiling buildroot, gmp is not configured properly and its compilation will fail, just reconfigure it with CFLAGS="-mcpu=v9" dans --host=sparc-unknown-linux-gnu (sparc64-unknown-linux-gnu is dedicated to the kernel only => kgcc64). TODO : A way to set that correcly ?
+
  
 +
# http://bugs.busybox.net/show_bug.cgi?id=3241
 +
# http://bugs.busybox.net/show_bug.cgi?id=3247
  
 
[[Category:Labs]]
 
[[Category:Labs]]

Latest revision as of 13:31, 15 February 2011

Draft for an experiment in progress. Accuracy here is random!


Contents

[edit] Warning

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.

[edit] Building a tftpboot image

[edit] Tools

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

[edit] The Linux kernel way

  • Magic command (/in /usr/src/linux) : make tftpboot.img
    • Scans System.map 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)

[edit] Cramfs

  • 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
#!/bin/ash
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 ?) :-(

[edit] ext2

  • 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 :-)

[edit] 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 :

  1. http://bugs.busybox.net/show_bug.cgi?id=3241
  2. http://bugs.busybox.net/show_bug.cgi?id=3247
Personal tools
Namespaces

Variants
Actions
Categories
Toolbox
Stuff