How to Configure iSCSI Target with Targetcli on AlmaLinux
Categories:
4 minute read
How to Configure iSCSI Target Using Targetcli on AlmaLinux
The iSCSI (Internet Small Computer Systems Interface) protocol allows users to access storage devices over a network as if they were local. On AlmaLinux, configuring an iSCSI target is straightforward with the targetcli tool, a modern and user-friendly interface for setting up storage backends.
This guide provides a step-by-step tutorial on configuring an iSCSI target using Targetcli on AlmaLinux. We’ll cover prerequisites, installation, configuration, and testing to ensure your setup works seamlessly.
Understanding iSCSI and Targetcli
Before diving into the setup, let’s understand the key components:
- iSCSI Target: A storage device (or logical unit) shared over a network.
- iSCSI Initiator: A client accessing the target device.
- Targetcli: A command-line utility that simplifies configuring the Linux kernel’s built-in target subsystem.
Benefits of iSCSI include:
- Centralized storage management.
- Easy scalability and flexibility.
- Compatibility with various operating systems.
Step 1: Prerequisites
Before configuring an iSCSI target, ensure the following:
AlmaLinux Requirements:
- AlmaLinux 8 or later.
- Root or sudo access.
Networking Requirements:
- A static IP address for the target server.
- A secure and stable network connection.
Storage Setup:
- A block storage device or file to be shared.
Software Packages:
- The targetcli utility installed on the target server.
- iSCSI initiator tools for testing the configuration.
Step 2: Installing Targetcli
To install Targetcli, run the following commands:
Verify the installation:
Step 3: Configuring the iSCSI Target
Start Targetcli: Launch the Targetcli shell:
Create a Backstore: A backstore is the storage resource that will be exported to clients. You can create one using a block device or file.
For a block device (e.g.,
/dev/sdb
):For a file-based backstore:
Create an iSCSI Target: Create an iSCSI target with a unique name:
The IQN (iSCSI Qualified Name) must be unique and follow the standard format (e.g.,
iqn.YYYY-MM.domain:identifier
).Add a LUN (Logical Unit Number): Link the backstore to the target as a LUN:
Configure Network Access: Define which clients can access the target by setting up an ACL (Access Control List):
Replace
initiator1
with the IQN of the client.Enable Listening on the Network Interface: Ensure the portal listens on the desired IP address and port:
Replace
192.168.1.100
with your server’s IP address.Save the Configuration: Save the current configuration:
Step 4: Enable and Start iSCSI Services
Enable and start the iSCSI service:
Check the service status:
Step 5: Configuring the iSCSI Initiator (Client)
On the client machine, install the iSCSI initiator tools:
Edit the initiator name in /etc/iscsi/initiatorname.iscsi
to match the ACL configured on the target server.
Discover the iSCSI target:
Log in to the target:
Verify that the iSCSI device is available:
Step 6: Testing and Verification
To ensure the iSCSI target is functional:
On the client, format the device:
Mount the device:
Test read and write operations to confirm connectivity.
Step 7: Troubleshooting
Issue: Targetcli Fails to Start
Check for SELinux restrictions and disable temporarily for testing:
Issue: Client Cannot Discover Target
Ensure the target server’s firewall allows iSCSI traffic on port 3260:
Issue: ACL Errors
- Verify that the client’s IQN matches the ACL configured on the target server.
Conclusion
Configuring an iSCSI target using Targetcli on AlmaLinux is an efficient way to share storage over a network. This guide has walked you through the entire process, from installation to testing, ensuring a reliable and functional setup. By following these steps, you can set up a robust storage solution that simplifies access and management for clients.
Whether for personal or enterprise use, mastering Targetcli empowers you to deploy scalable and flexible storage systems with ease.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.