@@ -12,21 +12,20 @@ VOLUME_NAME=[Fsx volume name, e.g. iscsiVol]
1212VOLUME_SIZE=[volume size in GB, e.g 100g]
1313# Default value is fsx, but you can change it to any other value according to yours FSx for ONTAP SVM name
1414SVM_NAME=fsx
15+ # Default value is fsxadmin, but you can change it to any other value according to yours FSx for ONTAP admin user name
16+ ONTAP_USER=fsxadmin
1517# end - user data
1618
17-
1819min=100
1920max=999
2021LUN_NAME=${VOLUME_NAME} _$(( $RANDOM % ($max - $min + 1 )+ $min ))
2122
2223# defaults
23- # All FSxN instances are created with the user 'fsxadmin' which can't be changed
2424# The script will create a log file in the ec2-user home directory
25- ONTAP_USER=fsxadmin
2625LOG_FILE=/home/ec2-user/install.log
2726
2827VOL_SIZE=$( echo $VOLUME_SIZE | sed ' s/.$//' )
29- LUN_SIZE=$( bc -l <<< " 0.85 *$VOL_SIZE" )
28+ LUN_SIZE=$( bc -l <<< " 0.90 *$VOL_SIZE" )
3029
3130echo " # Uninstall file" >> uninstall.sh
3231chmod u+x uninstall.sh
@@ -76,6 +75,7 @@ addUndoCommand "yum remove -y device-mapper-multipath iscsi-initiator-utils"
7675commandDescription=" Set multisession replacment time from default 120 sec to 5 sec"
7776logMessage " ${commandDescription} "
7877sed -i ' s/node.session.timeo.replacement_timeout = .*/node.session.timeo.replacement_timeout = 5/' /etc/iscsi/iscsid.conf; cat /etc/iscsi/iscsid.conf | grep node.session.timeo.replacement_timeout
78+ cat /etc/iscsi/iscsid.conf | grep " node.session.timeo.replacement_timeout = 5"
7979checkCommand " ${commandDescription} "
8080addUndoCommand " sed -i 's/node.session.timeo.replacement_timeout = .*/node.session.timeo.replacement_timeout = 120/' /etc/iscsi/iscsid.conf; cat /etc/iscsi/iscsid.conf | grep node.session.timeo.replacement_timeout"
8181
@@ -86,7 +86,7 @@ systemctl start iscsid
8686checkCommand " ${commandDescription} "
8787
8888# check if the service is running
89- isIscsciServiceRunning=$( systemctl is-active --quiet iscsid.service && echo " 1" )
89+ isIscsciServiceRunning=$( systemctl is-active --quiet iscsid.service && echo " 1" || echo " 0 " )
9090if [ " $isIscsciServiceRunning " -eq 1 ]; then
9191 logMessage " iscsi service is running"
9292 addUndoCommand " systemctl --now disable iscsid.service"
@@ -152,7 +152,7 @@ sshpass -p $FSXN_PASSWORD ssh -o StrictHostKeyChecking=no $ONTAP_USER@$FSXN_ADMI
152152checkCommand " ${commandDescription} "
153153addUndoCommand " sshpass -p ${FSXN_PASSWORD} ssh -o StrictHostKeyChecking=no ${ONTAP_USER} @${FSXN_ADMIN_IP} volume delete -vserver ${SVM_NAME} -volume ${VOLUME_NAME} -force"
154154
155- commandDescription=" Create iscsi lun for vserver: ${SVM_NAME} volume name: ${VOLUME_NAME} and lun name: ${LUN_NAME} and size: ${LUN_SIZE} g"
155+ commandDescription=" Create iscsi lun for vserver: ${SVM_NAME} volume name: ${VOLUME_NAME} and lun name: ${LUN_NAME} and size: ${LUN_SIZE} g which is 90% of the volume size "
156156logMessage " ${commandDescription} "
157157sshpass -p $FSXN_PASSWORD ssh -o StrictHostKeyChecking=no $ONTAP_USER @$FSXN_ADMIN_IP " lun create -vserver $SVM_NAME -path /vol/$VOLUME_NAME /$LUN_NAME -size " ${LUN_SIZE} g" -ostype linux -space-allocation enabled"
158158checkCommand " ${commandDescription} "
@@ -306,4 +306,14 @@ cat /$directory_path/$mount_point/testIscsci.txt
306306
307307logMessage " Mounting the FSXn iSCSI volume was successful."
308308
309+ # Add the mount entry to /etc/fstab
310+ commandDescription=" Add the mount entry to /etc/fstab"
311+ logMessage " ${commandDescription} "
312+ echo " /dev/mapper/$ALIAS /$directory_path /$mount_point ext4 defaults,_netdev 0 0" >> /etc/fstab
313+ checkCommand " ${commandDescription} "
314+ addUndoCommand " sed -i '/\/dev\/mapper\/$ALIAS \/mnt\/$mount_point ext4 defaults,_netdev 0 0/d' /etc/fstab"
315+ # End of script
316+ logMessage " Script completed successfully."
317+
318+
309319rm -f uninstall.sh
0 commit comments