Install OpenFiler on USB stick

December 4, 2007 – 16:51 by Hannes Van de Vel

Why?

Installing OpenFiler on a USB stick allows you to seperate your NAS system and config from the data. You don’t have to waste a seperate disc for this purpose. Furthermore, a Flash memory is less sensitive for ‘crashes’ than hard discs. Certainly in my case, where I needed alot of storage space but the data on it was not really crucial. Losing data was less of an issue than losing the config and time to setup OpenFiler. So we went for stand-alone discs with an USB stick for the system and config. When having a redundant RAID storage setup you might want to put OpenFiler on the RAID anyway, because it is redundant enough on it’s own for both the data and system/config.

How?

Basically I used the procedure described on the OpenFiler forum (http://www.openfiler.com/community/forums/viewtopic.php?pid=4265#p4265).I used OpenFiler 2.2 64bit, a 1Gb USB stick (from Transend 1GB USB 2.0 JetFlash V30, only € 5,99 ;) ), and a recent server which allows you to boot from the USB stick (set the boot order in the BIOS, first CD, then USB flash).

I repeat the steps with my adjustments;

  • Insert your USB stick, and disconnect or disable all of your harddrives / RAID volumes
  • Boot from the OpenFiler installation CD
  • At the boot prompt, type expert (for text mode type expert text, I used graphical mode)
  • Manually configure your partitions. I just had one 1Gb partition (ext3) on /. I’ve read some people having a swap and boot partition, but since I doubted the amount of storage needed for the system, I just used the full size for the / partition, which ended up working fine. After the install I noticed that something between 600 and 700 Mb was used for the system, so you might be able to use about 200-300Mb for swap or boot partition (however, I doubt the use for a swap partition, as USB storage is really slow). The installer also gave me alot of cryptic error messages which seems like a calculation for the storage amounts (heads*cylinders etc). You can ignore these messages (by pressing ignore several times). I’ve never read about other people with this problem, so could be specificly on my config.
  • Continue with the install as usual. Note that it is realllyyy slow. It took more than an hour on my config.
  • Reboot at the end, Openfiler tries to boot but ends op in panic mode.
  • Reboot again and boot from the install disc again.
  • Type linux rescue
  • Mount USB stick;
    mount /dev/sda1 /mnt/source
    chroot /mnt/source
  • Fix fix fix
    cp /boot/initrd-2.X.X.img /tmp/initrd.gz
    gunzip /tmp/initrd.gz
    mkdir /tmp/a
    cd /tmp/a
    cpio -i < /tmp/initrd
    vi init

    (find the line with ‘insmod /lib/sd_mod.ko’)
    (insert the following beneath it)

    insmod /lib/sr_mod.ko
    insmod /lib/ehci-hcd.ko
    insmod /lib/uhci-hcd.ko
    sleep 5
    insmod /lib/usb-storage.ko
    sleep 8

    (save)

    cd /lib/modules/`uname -r`/kernel/drivers
    cp usb/storage/usb-storage.o /tmp/a/lib
    cp usb/host/ehci-hcd.ko /tmp/a/lib
    cp usb/host/uhci-hcd.ko /tmp/a/lib
    cd /tmp/a
    find . | cpio -c -o | gzip -9 > /boot/usbinitrd.img
  • Adjust grub config (/boot/grub/grub.conf) to reflect the change to initrd filename. You should also repeat this on kernel upgrades (but then again, never touch a working system ;) ).
  • Reboot. On my system it complains about not finding sr_mod. I checked the contents of the initrd and it’s not there. However, I doesn’t seem to harm cause Openfiler booted from the USB stick normally. You might just not want to add this line in init if you get this error.
  • The Openfiler forum thread also added some suggestions to move some parts like /var/tmp and /var/log etc to tempfs for increasing performance. I tried this but moving lock, run and log to tempfs caused alot of troubles with me (services ended up not starting up etc..). I just moved /tmp and /var/tmp to tempfs, nothing else (so I also didn’t need the preinit script anymore).
    So my changes to /etc/fstab;
    tmpfs /tmp tmpfs defaults,noatime 0 0
    tmpfs /var/tmp tmpfs defaults,noatime 0 0
    I didn’t add the noatime attribute on /.


Admire the USB stick’s flashing blue light, working hard, as if it were a full blown grown up 500Gb hard disc ;)

Bookmark and Share
  1. 15 Responses to “Install OpenFiler on USB stick”

  2. As an addition to my article above I wanted to tell that we had a serious crash (beyond repair) of OpenFiler running from a USB stick. It seemed the USB stick ran out of available space, which seriously corrupted the whole OpenFiler installation (even had problems with existing VG’s after reinstall). You should make sure you have 1/ enough available space (probably more than 1GB is advised!) and 2/ that you don’t increase the usage of available space by log files (this was the problem in my case). You should purge logs an a very regular base to prevent such problems I experienced!

    By h@nnes on Feb 19, 2008

  3. As an addition to my article above I wanted to tell that we had a serious crash (beyond repair) of OpenFiler running from a USB stick. It seemed the USB stick ran out of available space, which seriously corrupted the whole OpenFiler installation (even had problems with existing VG’s after reinstall). You should make sure you have 1/ enough available space (probably more than 1GB is advised!) and 2/ that you don’t increase the usage of available space by log files (this was the problem in my case). You should purge logs an a very regular base to prevent such problems I experienced!

    By Hannes Van de Vel on Feb 19, 2008

  4. Hi, was it possible to you to install directly on the USB drive? i tried that (with 2.3 RC though) and it refuses to install to the USB drive.

    By Morten on Jun 5, 2008

  5. You need to start the installer in expert mode.

    In the openfiler boot loader screen, enter

    linux text expert

    By wolfy on Jul 27, 2008

  6. google pulled up your post double-quick on a search for the terms openfiler+usb

    anyway using your guidelines I’ve gone from Openfiler not seeing my 2GB flash to the error messages you described, complaints about low RAM and no Swap, etc… sounds like everything’s going smoothly. if this thing -needs- to swap with 512MB of RAM installed.. something is seriously wrong, heh. Anyway thanks for the helpful post!

    By Alex on Aug 20, 2008

  7. openfiler is junk. In FREENAS all you do is go through a menu item, click and it formats your new bootable usb drive. You never have to go through that vi POS editor.

    By JimC on Oct 19, 2008

  8. I use both freenas and open filer and where as i’d say the install is simpler with freenas on CF or USB and possibly easier to configure as a simple NAS, Open filer rocks for everything else and is much easier to use.

    My 2p

    By Alex on Jan 9, 2009

  9. I really appreciate this information, and wish USB was handled by the OpenFiler installer. I’ve prepaired several OpenFiler USB sticks without issue.

    However, I have an issue with some servers (HP DL350 G3) that can only emulate USB as Floppy, not Hard Drive. I proved this by using HP’s Drive Key Boot Utility (cp006049.exe). It can createa a DOS USB Hard Drive or USB Floppy DIsk. The server only boots when configured as Floppy. OpenFiler won’t install to the floppy formatted USB as it prompts/forces to format as hard drive.

    Can anyone give instructions on how to prepare the USB key in such a way that it would boot in this situation? Or, how to prepare another USB Floppy, 3.5″ Floppy, or CD with GRUB?

    Incidentally, I believe this USB floppy emulation is the same cause of FreeNAS not booting with “Error 1 lba #####” “No /boot/kernel/kernel”

    By Chris on Feb 10, 2009

  10. I followed your instructions, but I’m stuck on the grub.conf file. I copied the existing boot options and added “initrd /usbinird.img” to the end.
    Here is the error I get when I boot from the USB:

    root (hd0,0)
    Filesystem type is ext2fs, partition type 0×83
    kernel /vmlinuz-2.6.26.8-1.0.11.smp.gcc3.4.x86_64 ro
    [ Linux-bzImage, setup=0x3000, size=0x219300]
    root=LABEL=/1 quiet
    ERROR 11: Unrecognized device string
    Press any key to continue…

    Next screen is both boot options. (One I created a top.)
    I setup the partitions on the USB with ext3. Does it need to be ext2?

    By Carlton on Apr 27, 2009

  11. I must admit, freeNAS is a lot simpler to install on a USB or CF card/drive however after many many stability issues I have decided to run with openfiler. Thanks for the guide though, from this I have decided to simply stick a 5th small hard drive in and forget using openfiler from a USB drive afterall :P

    By PsyMan on May 12, 2009

  12. Hi,

    Thanks for your article. I use a low cost Imation USB stick. With help of your writings I was up and running in minutes. (After the initials install which indeed takes a long time.)

    By Robin on Oct 4, 2009

  13. This does not want to work for me. When I try to chroot /mnt/source I get an error:

    chroot: cannot execute /bin/sh: no such file or directory

    By Scott on Nov 19, 2009

  14. for scott and because googling openfiler+usb give yur page as a first:
    chroot does not work if bash is not on the filesystem where you chroot, this is the case if you have created a /boot partition (the standard with openfiler)
    in this case two things have to be done:
    1st: mount /dev/sda2 instead of /dev/sda1
    2nd: you also have to mount /dev/sda1 as /mnt/source/boot/
    then chroot to /mnt/source

    good luck for others

    By viknet on Jan 30, 2010

  1. 2 Trackback(s)

  2. Dec 30, 2007: How to install openfiler on USB stick « Mymytti’s Weblog
  3. Jan 8, 2008: Openfiler on USB stick « Noppatech Weblog

Post a Comment