Installing Openfiler 2.3 onto a USB Flash Drive

3rd August 2011 1 By Simon

Having played with a number of different flavours of NAS\SAN software on my HP MicroServer one of the limiting factors I found with Openfiler was the fact you had to install it onto a fixed disk, for the most part this isn’t an issue but when you’re talking about the MicroServer and it’s 4 fixed SATA drives (actually 5 if you want to use the single SATA port designed for a CD\DVD drive) then you can find yourself limited on disk usage if you need to dedicate one of the four drives for the Openfiler OS rather than using it as a RAID member.

I started looking around at the possibility of installing Openfiler onto a USB drive, something that isn’t openly supported on 2.3 and managed to find enough information out there to put together a USB device that can be used for booting Openfiler.

There are a few decisions that need to be made at the offset, mainly on the size USB flash drive to be used, using something too small will cause issues later on, using something too large will obviously just waste space.

For my testing I used a 4GB SanDisk Cruzer Blade which has been a great little device that’s already being used in my vSphere hosts successfully and it fits into the MicroServer very nicely.

To start the installation process the first thing you need to do is disconnect your data drives, leaving just your CD\DVD drive and USB flash drive connected. On the MicroServer you have two options, simply pull the 4 drive carriers or disconnect the multilane connector from the board. This ensures that you’re only installing Openfiler to the USB drive and nothing else.

Now boot up the Openfiler CD.

201

Instead of using the default installation we need to run the expert one, as in the picture above type linux expert to start.

345

Once you have chosen your keyboard configuration you need to choose Manually partition with Disk Druid, this will allow us to create the right sized partitions based on the size of the USB flash drive.

678910

We need to create four disk partitions for our USB installation.

  1. "/boot" is where the kernel will reside and the system will boot from and should be set to 100MB in size, also set it to be a primary partition

  2. "/" is the system root partition where all system applications and libraries will be installed to, depending on the size of USB flash drive you’re using this can be sized from 1024 to 2048MB.

  3. "swap" is the swap partition for memory swapping to disk, again depending on the size of the drive you can use 1024 or 2048MB of space.

  4. “/var/logs” is a separate partition which will house the log files, this protects the “/” partition from running out of space, I have set this to 512MB.

Once you have completed the disk setup press Next.

1112

Here we are going to configure our Network settings, Openfiler can use both DHCP and Static IP entries, obviously you’re better off using a static address but the choice is yours. Once you enter the IP address you will also have to enter the Gateway and DNS settings on the first screenshot directly above.

131415

Choose your time zone settings and enter your Root password. Click next and wait for the installation to finish, because you’re installing to a USB device you can expect the installation to take a while (between 40 – 50 minutes). Once the installation is complete reboot the server but DON’T remove the CD\DVD media as we’re going to use it again.

Once the server has rebooted into the boot menu you need to type Linux Rescue

1617181920

Choose the Language and Keyboard layout, choose no to loading the Network and Skip.

Now comes the fun part as this is all CLI driven.

Once you’re at the CLI you’re going to have to create a couple of directories, type the following.

mkdir /mnt/system

mkdir /tmp/1

You now need to mount both the “/” and “/boot” partitions.

First we’re going to mount the / partition.

mount /dev/sda2 /mnt/system 

Next we’re going to mount the /boot partition.

mount /dev/sda1 /mnt/system/boot

Next we’re going to change the system root to the /mnt/system directory, this will allow us to work from there as if it’s the root filesystem.

chroot /mnt/system

Next we’re going to extract the initrd image.

cp /boot/initrd-2.6* /tmp/initrd.gz && gunzip /tmp/initrd.gz

Next change to the /tmp/1 directory

cd /tmp/1

Next we’re going to extract the initrd files.

cpio -i </tmp/1

Now we’re going to edit the init file using Nano.

nano init

Directly below the line “mount -t proc /proc /proc” insert the following lines

insmod /lib/scsi_mod.ko
insmod /lib/sr_mod.ko
insmod /lib/sd_mod.ko
insmod /lib/ehci-hcd.ko
insmod /lib/uhci-hcd.ko
insmod /lib/ohci-hcd.ko
sleep 5
insmod /lib/usb-storage.ko
sleep 5

Next search the rest of the file and remove any duplicate entries as we won’t need to load these up twice. Once all the duplicate entries are removed exit and save the file. (Ctrl X, Y and Enter to save using the same name).

Next we’re going to copy all of the modules mentioned above into the /tmp/1/lib folder.

cd /lib/modules/*/kernel/drivers (* at this point hit tab to fill out the folder name instead of typing it all out).

cp scsi/scsi_mod.ko /tmp/1/lib
cp scsi/sr_mod.ko /tmp/1/lib
cp scsi/sd_mod.ko /tmp/1/lib
cp usb/host/ehci-hcd.ko /tmp/1/lib
cp usb/host/uhci-hcd.ko /tmp/1/lib
cp usb/host/ohci-hcd.ko /tmp/1/lib
cp usb/storage/usb-storage.ko /tmp/1/lib

Next we’re going to package up the contents of the /tmp/1 directory to create the new ramdisk we’re going to boot from later on.

cd /tmp/1

find . | cpio -c -o | gzip -9 >/boot/usb-initrd.img

Finally we’re going to edit the boot loader menu so that we use the new ramdisk img.

nano /boot/grub/menu.lst (important to realise that the extension is an L not a 1).

Change the following entry.

initrd /vmlinux*

to

initrd /usb-initrd.img

and exit (Ctrl X, Y and Enter to save using the same name).

Reboot and you’re good to go.

** Important thing to note, if you update your Openfiler installation on the USB key you’re going to have to re-do the CLI work again because it will overwrite the boot img.