OpenFiler repair exercise


At our local radio station (Omroep Groesbeek) we use OpenFiler version 2.3 for our storage solution.

Yesterday, however, we didn’t have a storage solution but a storage problem. None of the exported disks could be accessed, neither through Samba nor NFS. Further investigation showed that the operating disk was completely kaputt. I tried to make a clone of the disk with CloneZilla but the clone failed and the new file systems where unusable as well.

Well, after whining for some time, I decided it was time for a complete re-install to save as much data as possible. Installation went superb and I saw and could mount our data volumes. Hurray, the data was save. Now I only needed to reimport the volumes into OpenFiler. Problem was that the OpenFiler GUI does not have a function for this. With all original config files gone I even didn’t have an example how to fix them.

Surely Google is your friend and searching showed that Nathan Jones created a script just for this type of situation. Clicking the link gave a 404', crap! Not all was lost, however, because I now knew the name of the script he made, `remake_vol_info and again Google to the rescue. I found a sample script that should do what I need. I tweaked it a little and executed it.

This is the script

#!/bin/bash

# strip the /mnt lines from fstab as we will be rebuilding them
grep /mnt /etc/fstab -v > _fstab

# create the new volumes.xml file
echo -e "<?xml version=\"1.0\" ?>\n<volumes>" > _volumes.xml

# find all logical volumes and loop
for i in `lvdisplay | grep "LV Name" | sed 's/[^\/]*//'`
do
    fstype=`vol_id $i -t 2> /dev/null`;
    mntpoint=`echo $i | sed 's/\/dev\//\/mnt\//'`/
    vgname=`echo $i | cut -d '/' -f3`
    volid=`echo $i | cut -d '/' -f4`

    args="";
    if [ "$fstype" == "" ]
    then
        # assume iscsi since filesystem is unknown
        fstype="iscsi"
        mntpoint=""
    fi
    if [ $fstype == ext3 ]
    then
        args=",acl,user_xattr"
    fi

    if [ $fstype == reiserfs ]
    then
        args=",acl"
    fi

    if [ $fstype != "iscsi" ]
    then
        echo "$i $mntpoint $fstype defaults,usrquota,grpquota$args 0 0" >> _fstab
        echo "  <volume id=\"$volid\" name=\"$volid\" mountpoint=\"$mntpoint\" vg=\"$vgname\" fstype=\"$fstype\" />" >> _volumes.xml

        echo "Mounting $mntpoint"
        mkdir -p $mntpoint > /dev/null 2> /dev/null
        umount $mntpoint 2> /dev/null
        mount $mntpoint
    else
        echo "$i - assuming iSCSI"
        echo "  <volume id=\"$volid\" name=\"$volid\" mountpoint=\"\" vg=\"$vgname\" fstype=\"$fstype\" incominguser=\"\" incomingpassword=\"\" outgoinguser=\"\" outgoingpassword=\"\" />" >> _volumes.xml
    fi
done;
echo "</volumes>" >> _volumes.xml

mv -f _fstab /etc/fstab
mv -f _volumes.xml /opt/openfiler/etc/volumes.xml
chown openfiler.openfiler /opt/openfiler/etc/volumes.xml

Reboot and all volumes where visible in the OpenFiler GUI. Just needed to add the network and Samba and NFS exports and everything was up and running again.

Whoever posted the script: Thanks, it saved me a lot of time.

Old 

See also