Update mount scripts

This commit is contained in:
2022-11-25 12:51:51 +00:00
parent 3368fd71ec
commit 2a57a0766d
2 changed files with 9 additions and 8 deletions
Executable
+33
View File
@@ -0,0 +1,33 @@
#!/bin/bash
IQN=$1
HOST=$2
if [[ -z "${IQN}" || -z "${HOST}" ]]; then
echo "usage: $0 TargetIQN Host"
echo ""
exit
fi
iscsiadm -m discovery -t sendtargets -o update -p ${HOST} &> /dev/null
iscsiadm -m node -T ${IQN} -p ${HOST} -l
sleep 0.5
SESSIONID=$(iscsiadm -m session | grep "${IQN}" | head -n 1 | sed -e 's/.*\[\(.*\)\].*/\1/g')
DEVICE=$(iscsiadm -m session -r ${SESSIONID} -P 3 | grep "Attached scsi disk" | sed -e 's/.*Attached scsi disk \([^\t]*\).*/\/dev\/\1/g')
mkdir -p /mnt/iSCSI_${IQN}
FILESYSTEM=$(blkid ${DEVICE})
if [ -z "${FILESYSTEM}" ]; then
echo "No Filesystem found, initialize using following command:"
echo "mkfs.ext4 ${DEVICE}"
echo ""
echo "And mount afterwards using:"
echo "mount ${DEVICE} /mnt/iSCSI_${IQN}"
else
mount ${DEVICE} /mnt/iSCSI_${IQN}
fi