Login to All Discovered Targets and Enable Automatic Startup
After discovery populates the node database, iscsiadm -m node --login establishes an iSCSI session for every known target on the default portal, performing full login negotiation, creating a session ID, and triggering the SCSI mid-layer to probe LUNs. Setting node.startup to automatic in the same operation instructs iscsid to re-login on daemon start, which means the session survives reboots and systemd restarts. Internally, this writes the startup mode into /var/lib/iscsi/nodes/[target]/[portal]/default, and the iscsid.service unit depends on iscsi.service to replay those entries at boot.
This is the canonical post-discovery step in every SAN provisioning runbook: discovery, login, then multipath confirmation. It is used in ESXi-on-Linux labs, database clusters that need block devices before the DB daemon starts, and Kubernetes nodes that mount persistent volumes over iSCSI via the iscsi CSI driver. In automated deployments, you combine the --login and -o update calls so a reboot never leaves a host without its LUNs, which is critical for Pacemaker or Corosync clusters that fence on missing storage.
Security-wise, enabling automatic startup means the initiator will attempt login on every boot, so if the target enforces CHAP and credentials were rotated without updating the node DB, boot will hang on iscsid timeouts. Performance impact is limited to the login handshake, but on large fabrics with hundreds of targets, parallel logins can spike iscsid CPU. The most common pitfall is logging in before the network is ready, especially with bonding or VLAN interfaces; use systemd network-online.target ordering or udev rules to delay iscsi.service. Also verify with iscsiadm -m session that each login produced a distinct session ID.
> System.Execute()
sudo iscsiadm -m node -T iqn.2024-01.com.example:storage.lun0 -p 10.20.30.40:3260 --login
sudo iscsiadm -m node -T iqn.2024-01.com.example:storage.lun0 -p 10.20.30.40:3260 -o update -n node.startup -v automatic
sudo iscsiadm -m session -P 3 | grep -E 'Target:|State:|SID:'
sudo systemctl enable --now iscsid iscsi
> Architecture & Security Context
Verified for Valters IT Hub. When deploying this configuration in a production homelab or enterprise environment, ensure that you monitor system resources and implement strict access controls. Administrator privileges are required.
ID: VALTERSIT-E70F38C66706