Network and Storage Protocols

Script for NFS volume create and export

GERNETAPP
3,946 Views

Hi to all,

   I just want to know if someone could give me a hand or a tip or maybe someone has already done a script in Linux for creating a NFS volume and also to add the entry to the /etc/exports file in the FAS.

Thanks in advance,

Best regards,

German

1 REPLY 1

bulent_goktas
3,946 Views

Hi mate

Here is the example script

host files should be right config on where its running script

#!/bin/bash

# Create the NFS volumes for the first 2 nodes on the storage systems $STORAGE1 and $STORAGE2

#

STATUS=false

SPACE=6000000000

SPACE1=0

SPACE2=0

STORAGE1="NETAPP-1"

STORAGE2="NETAPP-2"

ping -c 1 $STORAGE1 >/dev/null 2>&1

if [ $? != 0 ]; then

    echo "Cannot ping the filer $STORAGE1"

    exit 8

fi

ping -c 1 $STORAGE2 >/dev/null 2>&1

if [ $? != 0 ]; then

    echo " Cannot ping filer $STORAGE2"

    exit 8

fi

echo "ping to both filer is okay"

SPACE1=`ssh $STORAGE1 aggr show_space |grep "Total space      " |awk '{print $5}' | cut -d"K" -f1`  >/dev/null 2>&1

SPACE2=`ssh $STORAGE2 aggr show_space |grep "Total space      " |awk '{print $5}' | cut -d"K" -f1`  >/dev/null 2>&1

echo "Available Space in aggr0 on $STORAGE1 = $SPACE1 KB"

echo "Available Space in aggr0 on $STORAGE2 = $SPACE2 KB"

if [ $SPACE1 -lt $SPACE ] ; then

    echo "Filer $STORAGE1 does not have enough space exiting here!!!"

#    exit 8

fi

if [ $SPACE2 -lt $SPACE ] ; then

    echo "Filer $STORAGE2 does not have enough space exiting here!!!"

#    exit 8

fi

echo " Creating NFS Volumes on $STORAGE1"

ssh $STORAGE2 vol create TEST_VOL_01 aggr0 50g

ssh $STORAGE2 vol options TEST_VOL_01 nosnapdir on

ssh $STORAGE2 vol options TEST_VOL_01 nosnap on

ssh $STORAGE2 exportfs -p sec=sys,rw=[fec0::]/64,root=[fec0::192:168:201:6],anon=0 /vol/TEST_VOL_01

ssh $STORAGE2 vol create TEST_VOL_02 aggr0 50g

ssh $STORAGE2 vol options TEST_VOL_02 nosnapdir on

ssh $STORAGE2 vol options TEST_VOL_02 nosnap on

ssh $STORAGE2 exportfs -p sec=sys,rw=[fec0::]/64,root=[fec0::192:168:201:6],anon=0 /vol/TEST_VOL_02

Public