7.8 KiB
iSCSI Connection Instructions
Overview
AtlasOS provides iSCSI connection instructions to help users connect initiators to iSCSI targets. The system automatically generates platform-specific commands for Linux, Windows, and macOS.
API Endpoint
Get Connection Instructions
GET /api/v1/iscsi/targets/{id}/connection
Returns connection instructions for an iSCSI target, including platform-specific commands.
Query Parameters:
port(optional): Portal port number (default: 3260)
Response:
{
"iqn": "iqn.2024-12.com.atlas:target1",
"portal": "192.168.1.100:3260",
"portal_ip": "192.168.1.100",
"portal_port": 3260,
"luns": [
{
"id": 0,
"zvol": "tank/iscsi/lun1",
"size": 10737418240
}
],
"commands": {
"linux": [
"# Discover target",
"iscsiadm -m discovery -t sendtargets -p 192.168.1.100:3260",
"",
"# Login to target",
"iscsiadm -m node -T iqn.2024-12.com.atlas:target1 -p 192.168.1.100:3260 --login",
"",
"# Verify connection",
"iscsiadm -m session",
"",
"# Logout (when done)",
"iscsiadm -m node -T iqn.2024-12.com.atlas:target1 -p 192.168.1.100:3260 --logout"
],
"windows": [
"# Open PowerShell as Administrator",
"",
"# Add iSCSI target portal",
"New-IscsiTargetPortal -TargetPortalAddress 192.168.1.100 -TargetPortalPortNumber 3260",
"",
"# Connect to target",
"Connect-IscsiTarget -NodeAddress iqn.2024-12.com.atlas:target1",
"",
"# Verify connection",
"Get-IscsiSession",
"",
"# Disconnect (when done)",
"Disconnect-IscsiTarget -NodeAddress iqn.2024-12.com.atlas:target1"
],
"macos": [
"# macOS uses built-in iSCSI support",
"# Use System Preferences > Network > iSCSI",
"",
"# Or use command line (if iscsiutil is available)",
"iscsiutil -a -t iqn.2024-12.com.atlas:target1 -p 192.168.1.100:3260",
"",
"# Portal: 192.168.1.100:3260",
"# Target IQN: iqn.2024-12.com.atlas:target1"
]
}
}
Usage Examples
Get Connection Instructions
curl http://localhost:8080/api/v1/iscsi/targets/iscsi-1/connection \
-H "Authorization: Bearer $TOKEN"
With Custom Port
curl "http://localhost:8080/api/v1/iscsi/targets/iscsi-1/connection?port=3261" \
-H "Authorization: Bearer $TOKEN"
Platform-Specific Instructions
Linux
Prerequisites:
open-iscsipackage installediscsidservice running
Steps:
- Discover the target
- Login to the target
- Verify connection
- Use the device (appears as
/dev/sdXor/dev/disk/by-id/...) - Logout when done
Example:
# Discover target
iscsiadm -m discovery -t sendtargets -p 192.168.1.100:3260
# Login to target
iscsiadm -m node -T iqn.2024-12.com.atlas:target1 -p 192.168.1.100:3260 --login
# Verify connection
iscsiadm -m session
# Find device
lsblk
# or
ls -l /dev/disk/by-id/ | grep iqn
# Logout when done
iscsiadm -m node -T iqn.2024-12.com.atlas:target1 -p 192.168.1.100:3260 --logout
Windows
Prerequisites:
- Windows 8+ or Windows Server 2012+
- PowerShell (run as Administrator)
Steps:
- Add iSCSI target portal
- Connect to target
- Verify connection
- Initialize disk in Disk Management
- Disconnect when done
Example (PowerShell as Administrator):
# Add portal
New-IscsiTargetPortal -TargetPortalAddress 192.168.1.100 -TargetPortalPortNumber 3260
# Connect to target
Connect-IscsiTarget -NodeAddress iqn.2024-12.com.atlas:target1
# Verify connection
Get-IscsiSession
# Initialize disk in Disk Management
# (Open Disk Management, find new disk, initialize and format)
# Disconnect when done
Disconnect-IscsiTarget -NodeAddress iqn.2024-12.com.atlas:target1
macOS
Prerequisites:
- macOS 10.13+ (High Sierra or later)
- iSCSI initiator software (third-party)
Steps:
- Use GUI iSCSI initiator (if available)
- Or use command line tools
- Configure connection settings
- Connect to target
Note: macOS doesn't have built-in iSCSI support. Use third-party software like:
- GlobalSAN iSCSI Initiator
- ATTO Xtend SAN iSCSI
Portal IP Detection
The system automatically detects the portal IP address using:
- Primary Method: Parse
targetclioutput to find configured portal IP - Fallback Method: Use system IP from
hostname -I - Default:
127.0.0.1if detection fails
Custom Portal IP:
If the detected IP is incorrect, you can manually specify it by:
- Setting environment variable
ATLAS_ISCSI_PORTAL_IP - Or modifying the connection instructions after retrieval
LUN Information
The connection instructions include LUN information:
- ID: LUN number (typically 0, 1, 2, ...)
- ZVOL: ZFS volume backing the LUN
- Size: LUN size in bytes
Example:
"luns": [
{
"id": 0,
"zvol": "tank/iscsi/lun1",
"size": 10737418240
},
{
"id": 1,
"zvol": "tank/iscsi/lun2",
"size": 21474836480
}
]
Security Considerations
Initiator ACLs
iSCSI targets can be configured with initiator ACLs to restrict access:
{
"iqn": "iqn.2024-12.com.atlas:target1",
"initiators": [
"iqn.2024-12.com.client:initiator1"
]
}
Only initiators in the ACL list can connect to the target.
CHAP Authentication
For production deployments, configure CHAP authentication:
- Set up CHAP credentials in target configuration
- Configure initiator with matching credentials
- Use authentication in connection commands
Note: CHAP configuration is not yet exposed via API (future enhancement).
Troubleshooting
Connection Fails
- Check Target Status: Verify target is enabled
- Check Portal: Verify portal IP and port are correct
- Check Network: Ensure network connectivity
- Check ACLs: Verify initiator IQN is in ACL list
- Check Firewall: Ensure port 3260 (or custom port) is open
Portal IP Incorrect
If the detected portal IP is wrong:
- Check
targetcliconfiguration - Verify network interfaces
- Manually override in connection commands
LUN Not Visible
- Check LUN Mapping: Verify LUN is mapped to target
- Check ZVOL: Verify ZVOL exists and is accessible
- Rescan: Rescan iSCSI session on initiator
- Check Permissions: Verify initiator has access
Best Practices
1. Use ACLs
Always configure initiator ACLs to restrict access:
- Only allow known initiators
- Use descriptive initiator IQNs
- Regularly review ACL lists
2. Use CHAP Authentication
For production:
- Enable CHAP authentication
- Use strong credentials
- Rotate credentials regularly
3. Monitor Connections
- Monitor active iSCSI sessions
- Track connection/disconnection events
- Set up alerts for connection failures
4. Test Connections
Before production use:
- Test connection from initiator
- Verify LUN visibility
- Test read/write operations
- Test disconnection/reconnection
5. Document Configuration
- Document portal IPs and ports
- Document initiator IQNs
- Document LUN mappings
- Keep connection instructions accessible
Compliance with SRS
Per SRS section 4.6 iSCSI Block Storage:
- ✅ Provision ZVOL-backed LUNs: Implemented
- ✅ Create iSCSI targets with IQN: Implemented
- ✅ Map LUNs to targets: Implemented
- ✅ Configure initiator ACLs: Implemented
- ✅ Expose connection instructions: Implemented (Priority 21)
Future Enhancements
- CHAP Authentication: API support for CHAP configuration
- Portal Management: Manage multiple portals per target
- Connection Monitoring: Real-time connection status
- Auto-Discovery: Automatic initiator discovery
- Connection Templates: Pre-configured connection templates
- Connection History: Track connection/disconnection events
- Multi-Path Support: Instructions for multi-path configurations