facebooktwitterskypeRSS Feed
telephone: (920) 215-1842
facsimile: (866) 456-2115

Install Openfiler to boot off USB Flash Drive

email

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?

I used openfiler 2.3 32bit, a 2Gb USB stick (from SanDisk U3 Cruzer Micro 2GB USB 2.0 ), 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 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 text, I used graphical mode)
        $ expert
        
  • Manually configure your partitions. I just had one 2Gb 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
        
  • Update the following so the system can boot from the USB flash drive.
        $ 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 should be as follows.
        $ vi /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 /.
  • After making the USB key I used dd to make a exact copy of the key. For some reasons to copy booted but had problems starting services and ultimately didn’t work correctly. I’m not sure why.

Related posts:

  1. Cacti – Web-based Monitoring Tool
  2. Reduce the size of VMware VMDK files

Post a Comment

Do you have a question or comment about this post. Please share! Your email address will not be published. Required fields are marked *

*