So yeah, we're going to get some practice now setting up an
iSCSI Initiator using the Ubuntu 20.04 system.
Okay, and I'm using a fresh vagrant Ubuntu box, so this is brand‑new,
fresh out of the box, as it were.
We can see that we've got a few disks that they've
added in. It has its own loop devices.
Ubuntu uses those quite a lot in any case, and then we see that we've got sda
and sdb disk with nothing being used on the sdb disk at the moment 10 MB. Now
we're going to leave this as is, but we want to make use of that 1 GB target
that we created on our iSCSI target on RHEL 8. We need to make sure that
we've got the package installed, so let's go through and just check. So sudo
and apt update to make sure our package cache is up to date. So that's good.
We're up to date on this. And then I'm going to go through and do, let's move
this to the top, apt install, and then it's open‑iscsi, and again, it looks
like we've already got the latest version available.
Now I'm going to go through and echo. And I'm just going to put
it in quotes, and I'm putting InitiatorName= and then iqn.2015,
the name that we used on the iSCSI target. But we just have
InitiatorName= in front of this.
I can then go through and pipe this to sudo and tee. We need
administrative privileges to be able to write to the file,
and we can overwrite the file, I don't need to worry about appending it.
I'm writing through to /etc/ and then through to our iSCSI directory, and then
the file initiatorname.iscsi. And once we're happy with that, we can then go
through and hit Enter. Tee will write to the screen and through to the file, but
if we want to double‑check, if I do a sudo and cat, Escape and dot will bring up
the last argument, which is the file name, and you can see now that we've
written that through to our file. As it was already installed, the package, we
can go through and restart our services. So I'm going to do a sudo and systemctl
restart, and then we've got iscsiid and then our open‑iscsi.services. With that
said and done, we should now match the access control list. I can go through and
use sudo, and we can go through and run our iscsiadm, and we want to then
specify our mode, which is going to be discovery.
Let's take a look at what's out there. We want to
then go through and set our target.
Well, okay you send me the targets, so sendtargets as a command
to the portal 192.168.33.11, the AlmaLinux system. So you can
see that we're getting then from that system the IQN coming
back, so that's our target.
I've only got one to connect to, so it becomes very easy, where I can
then go through and specify with my iscsiadm command,
we can specify that I want to now act in the mode of a
node. I want to connect. And then ‑‑login.
So we're up and running as far as this is concerned, and what that's
going to show to me, if I now go through and look at our ls block
command, it's that I've now got the additional device sdc, the 1 GB disk
device that's being shared out on the remote system, and then I can
obviously use this in any way, shape, or form that I want.
So if I want to go through and put a file system on this,
I can go through and do a mkfs.xfs, let's say, /dev/sdc.
And of course, I need to go through and run with
administrative privileges, but we've now formatted it,
I can then mount this locally and use it as a local file system, and this is
really what the idea of our storage area networks are all about is that we can
have one device where we concentrate all of our disk devices in that, and we
make those disk devices available perhaps even to diskless workstations on the network. But there you go, a quick introduction to iSCSI.