Mounting iSCSI LUNs: Difference between revisions
DrEdWilliams (talk | contribs) |
DrEdWilliams (talk | contribs) |
||
| Line 63: | Line 63: | ||
The ''_netdev'' specifies that the device is network-based and must wait for the network to be up and stable before the mount can succeed. Now you can mount the device or just reboot the system: | The ''_netdev'' specifies that the device is network-based and must wait for the network to be up and stable before the mount can succeed. Now you can mount the device or just reboot the system: | ||
mkdir <mount point> | |||
mount <mount point> | mount <mount point> | ||
Definitely more work than it should have taken ... | Definitely more work than it should have taken ... | ||
Revision as of 22:18, 14 August 2021
As much as it would be nice to have it the same across the different OS distributions, it seems there are differences -- some of which are rather annoying.
Pre-requisites
It is assumed that you already have your storage server configured with LUNs (Volumes in the Dell EquaLogic vocabulary) as desired for the application. These instructions assume that no passwords are needed to access the LUNs, but the ID/password stuff is straightforward enough in the config files that it shouldn't be an issue.
You will need to install the client software (it's not installed by default, though it is in the basic distributions):
- Debian/Ubuntu: open-iscsi
- RHEL/CentOS/Fedora: iscsi-initiator-utils
There is one change that needs to be made to the iscsi config file /etc/iscsi/iscsi.conf: the node startup must be set to automatic (if it isn't already set that way). Search for the node.startup parameter in the file and set it to 'automatic':
node.startup = automatic
Restart the service for this to take effect:
sudo systemctl restart iscsid
Establishing Sessions
Mounting the LUN on the storage server to the client system is a two-part process. First, you have to establish a session between the client (initiator in iSCSI vocabulary) and the target (server). The first step is to connect to the server to see what LUNs it has available:
iscsiadm -m discovery -t st -p <SERVER-IP>
This will produce output similar to:
10.2.0.201:3260,1 iqn.2001-05.com.equallogic:0-8a0906-52b816708-021a01fa52261173-shared 10.2.0.201:3260,1 iqn.2001-05.com.equallogic:0-8a0906-85f816708-38832e635165c2b0-files
The first part is the server IP and port (should be the same as specified in the command), but the last part of each line is the iqn for the LUN being advertised. The last part of the iqn should be the name of the LUN/volume ... if there is a problem identifying which one, look back at the storage server. Establishing a session for a LUN should be as simple as:
iscsiadm -m node -T <iqn from above> -p <SERVER-IP> -l
Once this is done (and if you set the node startup to 'automatic' above), it will persist across reboots and you should not have to do this again.
Mounting the LUN
This is where things diverge for different Linux distributions. The differences include the sequence during boot where multiple things have to happen before the mount is successful:
- the basic device structure is created
- the network devices are created
- the network devices are configured and connect to a network
- the iscsi subsystem starts and tries to connect to the storage server
- the mount process takes the device created by the iscsi session and mounts it
Getting these activities to happen in the right order is what gets challenging; the process for doing this under RHEL-style distributions uses systemd and is described here.
With Debian-based distributions, the process only involves adding an entry to the /etc/fstab file. First, however, you need to create the filesystem and get the needed data for mounting. Get the device assigned to your LUN:
ls -l /dev/disk/by-path
This will show all your drives -- the one for the LUN will actually contain the iqn for the LUN in the path. Now you make the filesystem (I prefer XFS):
sudo apt install -y xfsprogs sudo mkfs.xfs /dev/sdX
Now you get the UUID for the filesystem to create the entry in /etc/fstab. Mounting by UUID is safer than using the device name since if you add more iSCSI LUNs or add other disk devices, the device name can change.
ls -l /dev/disk/by-uuid
Find the UUID for the iSCSI device. Now you can add a line to /etc/fstab:
UUID=<uuid from the last step> <mount point> xfs _netdev,auto,defaults 0 0
The _netdev specifies that the device is network-based and must wait for the network to be up and stable before the mount can succeed. Now you can mount the device or just reboot the system:
mkdir <mount point> mount <mount point>
Definitely more work than it should have taken ...