unix:iscsi:advanced
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| unix:iscsi:advanced [2026/02/02 01:44] – removed - external edit (Unknown date) 127.0.0.1 | unix:iscsi:advanced [2026/02/02 01:44] (current) – ↷ Page moved from unix:advanced to unix:iscsi:advanced rodolico | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Advanced iSCSI Procedures ====== | ||
| + | |||
| + | This article covers non-trivial iSCSI procedures that require careful execution to avoid data loss or service disruption. | ||
| + | |||
| + | ===== Resizing an iSCSI Target ===== | ||
| + | |||
| + | ==== Overview ==== | ||
| + | |||
| + | When an iSCSI target needs to be expanded, the process varies depending on the underlying storage technology. This guide covers both LVM2 and ZFS-based targets. | ||
| + | |||
| + | ==== General Approach (LVM2) ==== | ||
| + | |||
| + | For LVM2-backed exports: | ||
| + | - Unmount and disconnect the target on all initiators | ||
| + | - Expand the logical volume on the target server | ||
| + | - Restart the iSCSI target service (recommended for consistency) | ||
| + | - Reconnect initiators and resize the filesystem | ||
| + | |||
| + | ==== ZFS-Based Targets (FreeBSD) ==== | ||
| + | |||
| + | The following procedure assumes: | ||
| + | * **Target:** FreeBSD with ZFS volumes (zvols) | ||
| + | * **Initiator: | ||
| + | |||
| + | <WRAP center round alert 60%> | ||
| + | **⚠ Warning:** Ensure no applications or services are accessing the target volume during this process. Options: | ||
| + | * **Minimum: | ||
| + | * **Recommended: | ||
| + | </ | ||
| + | |||
| + | === Step 1: Expand the ZFS Volume (Target Server) === | ||
| + | |||
| + | <code bash> | ||
| + | # Set the new size on the ZFS volume | ||
| + | # Example: storage/ | ||
| + | # newsize format: 500G, 2T, etc. | ||
| + | zfs set volsize=500G storage/ | ||
| + | |||
| + | # Notify ctld of the configuration change | ||
| + | # ' | ||
| + | service ctld restart | ||
| + | </ | ||
| + | |||
| + | === Step 2: Rescan from Initiator (Linux) === | ||
| + | |||
| + | After expanding the target, initiators must rescan to detect the new size. | ||
| + | |||
| + | **Option A: Rescan all sessions (not recommended for production)** | ||
| + | <code bash> | ||
| + | # Rescans ALL iSCSI sessions - use with caution in production | ||
| + | iscsiadm -m session --rescan | ||
| + | </ | ||
| + | |||
| + | **Option B: Rescan specific target only (recommended)** | ||
| + | |||
| + | <code bash> | ||
| + | # Method 1: Find the Session ID (SID) for your specific target | ||
| + | # Replace ' | ||
| + | SID=$(iscsiadm -m session -P 0 | grep thing1 | cut -d' | ||
| + | |||
| + | # Rescan only that specific session | ||
| + | iscsiadm --mode session --sid=$SID --rescan | ||
| + | |||
| + | # Alternatively, | ||
| + | # iscsiadm -m session | ||
| + | # iscsiadm --mode session --sid=15 --rescan | ||
| + | |||
| + | # Verify the new size has been detected | ||
| + | fdisk -l / | ||
| + | # Or use lsblk for a cleaner view | ||
| + | lsblk / | ||
| + | </ | ||
| + | |||
| + | === Step 3: Resize the Filesystem === | ||
| + | |||
| + | After the initiator recognizes the new size, expand the filesystem: | ||
| + | |||
| + | **For ext4:** | ||
| + | <code bash> | ||
| + | resize2fs /dev/sdX | ||
| + | </ | ||
| + | |||
| + | **For XFS:** | ||
| + | <code bash> | ||
| + | xfs_growfs / | ||
| + | </ | ||
| + | |||
| + | **For LVM:** | ||
| + | <code bash> | ||
| + | pvresize /dev/sdX | ||
| + | lvextend -l +100%FREE / | ||
| + | resize2fs / | ||
| + | </ | ||
| + | |||
| + | **For virtual machines:** Consider booting from [[https:// | ||
| + | |||
| + | ===== Removing an iSCSI Target ===== | ||
| + | |||
| + | ==== Overview ==== | ||
| + | |||
| + | Removing an iSCSI target requires cleanup on both the target server and all initiators. The initiator maintains a local database of discovered targets that must be explicitly cleaned. | ||
| + | |||
| + | <WRAP center round important 60%> | ||
| + | **Critical: | ||
| + | </ | ||
| + | |||
| + | ==== Procedure: Remove a Single Target ==== | ||
| + | |||
| + | <code bash> | ||
| + | # Step 1: Logout from the iSCSI session | ||
| + | # Replace with your actual target IQN and portal address | ||
| + | iscsiadm -m node \ | ||
| + | --target=' | ||
| + | --portal " | ||
| + | --logout | ||
| + | |||
| + | # Step 2: Remove the target from the local database | ||
| + | iscsiadm -m node \ | ||
| + | --target=' | ||
| + | --portal " | ||
| + | -o delete | ||
| + | |||
| + | # Verify removal | ||
| + | iscsiadm -m node | ||
| + | </ | ||
| + | |||
| + | ==== Procedure: Remove All Targets (Complete Cleanup) ==== | ||
| + | |||
| + | When decommissioning an entire iSCSI infrastructure or target server: | ||
| + | |||
| + | === Method 1: Service Shutdown and Manual Cleanup === | ||
| + | |||
| + | <code bash> | ||
| + | # Stop the iSCSI initiator service | ||
| + | # sysV (Devuan, other good Linux systems) | ||
| + | service start iscsiadm | ||
| + | service stop open-iscis # or iscsid on some systems | ||
| + | |||
| + | # systemd (RedHat, other Linux systems which have drunk the Kool-aid) | ||
| + | systemctl stop iscsiadm | ||
| + | systemctl stop open-iscsi | ||
| + | |||
| + | # Remove iSCSI configuration databases | ||
| + | # Debian/ | ||
| + | rm -rf / | ||
| + | rm -rf / | ||
| + | |||
| + | # RHEL/ | ||
| + | rm -rf / | ||
| + | rm -rf / | ||
| + | |||
| + | # Restart the service | ||
| + | service start open-iscis # sysV | ||
| + | systemctl start open-iscsi # systemd | ||
| + | </ | ||
| + | |||
| + | === Method 2: Programmatic Logout === | ||
| + | |||
| + | <code bash> | ||
| + | # Logout from all active sessions | ||
| + | iscsiadm -m node --logoutall=all | ||
| + | |||
| + | # Remove all node records | ||
| + | iscsiadm -m node -o delete | ||
| + | |||
| + | # Verify all targets are removed | ||
| + | iscsiadm -m node | ||
| + | </ | ||
| + | |||
| + | ==== Distribution-Specific Notes ==== | ||
| + | |||
| + | ^ Distribution ^ Configuration Path ^ | ||
| + | | Debian/ | ||
| + | | RHEL/ | ||
| + | | SUSE | ''/ | ||
| + | |||
| + | ===== Additional Resources ===== | ||
| + | |||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | |||
| + | ===== Best Practices ===== | ||
| + | |||
| + | * Always test resize operations in a non-production environment first | ||
| + | * Maintain backups before performing any resize operations | ||
| + | * Document your target IQNs and portal addresses | ||
| + | * Use '' | ||
| + | * Monitor initiator logs (''/ | ||
| + | |||
| + | ---- | ||
| + | |||
| + | //Last updated: February 2, 2026// | ||
| + | |||
