Initial commit: Adastra VTL Linux Distribution- Complete build system for VTL-focused Linux distro- mhvtl integration with 4 LTO drives and media changer- iSCSI target configuration for network connectivity- Automated installation and configuration scripts- Comprehensive documentation (architecture, installation, configuration)- Systemd service files and kernel tuning- Quick start wizard for easy setup
This commit is contained in:
104
scripts/configure-iscsi.sh
Executable file
104
scripts/configure-iscsi.sh
Executable file
@@ -0,0 +1,104 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
echo "=========================================="
|
||||
echo " iSCSI Target Configuration Script"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo "Error: This script must be run as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TGT_CONFIG_DIR="/etc/tgt/conf.d"
|
||||
ISCSI_IQN_BASE="iqn.2024-01.com.vtl-linux"
|
||||
|
||||
echo "[1/4] Installing iSCSI target software..."
|
||||
apt-get update
|
||||
apt-get install -y tgt
|
||||
|
||||
echo "[2/4] Configuring iSCSI targets..."
|
||||
mkdir -p "$TGT_CONFIG_DIR"
|
||||
|
||||
cat > "$TGT_CONFIG_DIR/vtl-targets.conf" << 'EOF'
|
||||
<target iqn.2024-01.com.vtl-linux:vtl.lun0>
|
||||
backing-store /dev/sg1
|
||||
initiator-address ALL
|
||||
incominguser vtl-user vtl-password
|
||||
write-cache on
|
||||
</target>
|
||||
|
||||
<target iqn.2024-01.com.vtl-linux:vtl.lun1>
|
||||
backing-store /dev/sg2
|
||||
initiator-address ALL
|
||||
incominguser vtl-user vtl-password
|
||||
write-cache on
|
||||
</target>
|
||||
|
||||
<target iqn.2024-01.com.vtl-linux:vtl.lun2>
|
||||
backing-store /dev/sg3
|
||||
initiator-address ALL
|
||||
incominguser vtl-user vtl-password
|
||||
write-cache on
|
||||
</target>
|
||||
|
||||
<target iqn.2024-01.com.vtl-linux:vtl.lun3>
|
||||
backing-store /dev/sg4
|
||||
initiator-address ALL
|
||||
incominguser vtl-user vtl-password
|
||||
write-cache on
|
||||
</target>
|
||||
|
||||
<target iqn.2024-01.com.vtl-linux:vtl.changer>
|
||||
backing-store /dev/sg0
|
||||
initiator-address ALL
|
||||
incominguser vtl-user vtl-password
|
||||
device-type changer
|
||||
</target>
|
||||
EOF
|
||||
|
||||
echo "[3/4] Configuring firewall..."
|
||||
if command -v ufw &> /dev/null; then
|
||||
ufw allow 3260/tcp
|
||||
ufw reload
|
||||
elif command -v firewall-cmd &> /dev/null; then
|
||||
firewall-cmd --permanent --add-port=3260/tcp
|
||||
firewall-cmd --reload
|
||||
else
|
||||
iptables -A INPUT -p tcp --dport 3260 -j ACCEPT
|
||||
iptables-save > /etc/iptables/rules.v4
|
||||
fi
|
||||
|
||||
echo "[4/4] Starting iSCSI target service..."
|
||||
systemctl enable tgt
|
||||
systemctl restart tgt
|
||||
|
||||
sleep 2
|
||||
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo " iSCSI Target Configuration Complete!"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
echo "Available targets:"
|
||||
tgt-admin --show
|
||||
echo ""
|
||||
echo "Connection information:"
|
||||
echo " - Port: 3260"
|
||||
echo " - IQN Base: $ISCSI_IQN_BASE"
|
||||
echo " - Username: vtl-user"
|
||||
echo " - Password: vtl-password"
|
||||
echo ""
|
||||
echo "Client connection examples:"
|
||||
echo ""
|
||||
echo "Linux:"
|
||||
echo " iscsiadm -m discovery -t st -p <SERVER_IP>:3260"
|
||||
echo " iscsiadm -m node --login"
|
||||
echo ""
|
||||
echo "Windows:"
|
||||
echo " iscsicli QAddTargetPortal <SERVER_IP>"
|
||||
echo " iscsicli ListTargets"
|
||||
echo " iscsicli LoginTarget <target_name> T * * * * * * * * * * * * * * * <username> <password>"
|
||||
echo ""
|
||||
Reference in New Issue
Block a user