Dashboard > Arts & Crafts > SlimServer on FreeNAS > Minimize Startup Time

View Info

Minimize Startup Time

Overview

Using Wake on LAN the user must wait for the SlimServer to startup after powering on the Squeezebox. Anything that can be done to minimize this delay is desirable.

Some startup time results with variety of interfaces (mostly CF cards). Measurement is time from cold start to availability of FreeNAS web interface:

Bootloader Interface PNY Optima Sandisk Extreme III Transcend Indust 100x Transcend Indust 45x Kingston CF/96 Lexar Plat II 80x A-Data OEM Kingston Data Traveler
BTX IDE         48.15 64.27 64.27  
BTX UDMA 44.66     45.87        
BTX SATA 43.77   53.83 43.48        
BTX USB               82.64
Grub4DOS SATA     45.27          
SYSLINUX IDE 44.29              
SYSLINUX SATA 41.31 37.03 41.07 36.03        
  • Did not do much testing with non-DMA IDE interface as this requires the kernel to disable DMA for all ATA/IDE devices (hw.ata.ata_dma=0), including the SATA hard drive, which significantly degrades disk performance once the system is running
  • Did not boot directly from hard drive as I don't consider this this maintainable/reliable strategy over the long term
  • Tests done with FreeNAS 0.686b2 and SlimServer 6.5.4

Creating an initial FreeNAS environment

If you do not have an working FreeNAs environement you will need to create one. This can be accomplished using a virtual machine (e.g. VMWare, Qemu) or on a spare PC capable of booting from a CDROM.

You can download a pre-made FreeNAS VMWare appliance and run it using the no-cost VMWare Player

Remastering FreeNAS for SYSLINUX bootloader

Preparation

  1. Download desired release of FreeNAS embedded. Be sure it's the embedded version, for example FreeNAS-i386-embedded-0.686b3.img
  2. Download the workon.sh script
  3. Place both in a working directory within FreeNAS, for this example the this will be in /mnt/remaster
  4. Login to console, SSH can make this easy and convenient
    • Be sure FreeNAS has SSH service enabled, or use the system's console
  5. Select appropriate shell in workon.sh
    cd /mnt/remaster
    sed -i .orig -e "s/^SHELL=.*/SHELL=\/bin\/sh/" workon.sh

    Execute workon.sh, which will spawn a sub-shell used for making changes. When you exit the sub-shell the script will re-pack the image

    sh workon.sh FreeNAS-i386-embedded-0.686b3.img

Configure FreeBSD BTX loader

Documentation for the FreeBSD BTX loader is in the man pages: loader, loader.4th, loader.conf, and boot

  1. Edit boot loader to remove startup menu delay
    sed -i .orig -e "s/^\(menu-start\)/\\ \1/" ../mnt1/boot/loader.rc
    echo boot >> ../mnt1/boot/loader.rc
  2. Remove bitmap
    sed -i .orig -e "s/^\(bitmap_load=\"YES\"\)/\# \1/" \
      -e "s/^\(splash_bmp_load=\"YES\"\)/\# \1/" ../mnt1/boot/loader.conf
  3. (optional) Disable DMA for IDE/SATA disks. This results in poor disk performance, but non-DMA CF cards require this to boot
    cp -a ../mnt1/boot/loader.conf ../mnt1/boot/loader.conf.orig
    echo hw.ata.ata_dma="0" >> ../mnt1/boot/loader.conf

Allow FreeNAS to load config.xml from MSDOS formatted CF card

  1. Preserve original file
    cp -a ./etc/inc/config.inc ./etc/inc/config.inc.orig
  2. Comment out the following two lines in /mnt/remaster/mnt2/etc/inc/config.inc (use nano editor to prefix each line with //)
    if (FALSE === ereg("da[0-9]*", $disk))
    	continue;
  3. Add the following lines immediately following
    // This enables embedded FreeNAS system to use config.xml on ATA disk
    // Skip mfs mounted filesystems. 
    if (TRUE === ereg("md[0-9]*", $disk))
    	continue;
  4. Now FreeNAS will find and maintain the configuration file on your FAT formatted CF card in the config/config.xml file

Re-pack Image

  1. Exit the shell and the workon.sh script will re-pack the firmware image
    exit
  2. I generally rename the firmware file to identify what features it has enabled
    Filename config.xml on MSDOS ATA? DMA Description
    freenas.cf yes no for non-DMA CF cards
    freenas.cfd yes yes normally use this image
    freenas.img no yes original FreeNAS distribution

Install new image

  • Assume new image is freenas.cfd in /mnt/remaster
  1. Remount CF card for writing
    umount /cf && mount -w /cf
  2. Backup old FreeNAS image and replace it with the newly packed file
    mv /cf/freenas.cfd /cf/freenas.cfd-`date +%Y%m%d%H%M%S`
    cp /mnt/remaster/freenas.cfd /cf/
  3. If you have not installed the SYSLINUX bootloader already you should do so. If there is a file called ldlinux.sys in the root directory of the card then SYSLINUX is probably installed (assuming the MBR is intact). SYSLINUX only needs do be installed once after formatting the card.
    1. Installing SYSLINUX requires a single command. For Windows users it is (at the Windows command prompt, for CF as F:). SYSLINUX.EXE is in the win32 directory of the SYSLINUX package
      syslinux -maf f:
    2. Be sure to also copy the memdisk binary to the root directory as well. MEMDISK is included as part of the SYSLINUX package in the memdisk directory
  4. Reboot system (note: as usual, /cf will be mounted read-only after reboot)

Other Approaches

DOS

DOS loads very quickly from a CF card and can be used to load both Linux and BSD. This was popular many years ago, but is now uncommon as few users have DOS installed on their PC. Nonetheless, this is a promising idea because there are DOS UDMA drivers that load quickly and yield much faster performance than INT13 (used by BTX, Grub4DOS, and maybe SYSLINUX as well)

  • Loadlin can load Linux kernels and initial ramdisk. MEMDISK emulates a Linux kernel, so it could be used the same way it is by SYSLINUX
  • BSDBOOT.COM loads OpenBSD, NetBSD, and FreeBSD kernels

Have tested both Loadlin and BSDBOOT, and neither works as of 2007-December. Loadlin relies on calling special hooks in the Linux kernel which MEMDISK does not support. In practice this means it will load MEMDISK and the entire FreeNAS image into memory (very quickly) but never actually execute MEMDISK.

BSDBOOT can be made to load the kernel, but it also fails to start. Not sure why-- it appears to load, but hangs afterward. Cannot even make it load the kernel alone, without MD image.

Both Loadlin and BSDBOOT appear to be legacy solutions, so it's unlikely that they will evolve to work with FreeNAS.

Suspend to RAM or Hibernation

Windows does this fairly well, but FreeBSD has only limited support for the power savings modes that could be used to avoid (re)booting.


Browse Space
- Pages
- Labels
- Attachments
- Mail
- Bookmarks
- News
- Activity
- Advanced

Explore Confluence
- Popular Labels
- Notation Guide

Your Account
Log In

 

Other Features

View a printable version of the current page.

Add Content
- Add Comment


Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.6.2 Build:#919 Nov 26, 2007)
Bug/feature request - Contact Administrators