iSCSI has become something of a staple in the world of Linux block storage. It’s quick, it’s reliable I wouldn’t consider it the most secure option but it does “just work”.
I often use iscsi block storage for persistent container storage, as well as a cheap way to add more disk to my VM.
This used to be something of a chore, with iscsiadm and manually copying and pasting long target names, trying to keep track of what is where. Remembering what order to do things, and testing over and over. The Cockpit package within Fedora makes this totally simple now.
This walkthrough will show you how to use your Synology NAS with Fedora 31 to mount remote storage within minutes. NOTE: I’m not using CHAP authentication, as this is just for my own vm’s. In a production environment, you should be using “at least” CHAP.
Ok, what you will need – a volume on your NAS and a local area network. Ideally a Fedora (https://getfedora.org/) vm to test.
Configure the LUN on the NAS
The LUN is the block of storage you want to present. The target is the device that will present that storage to the rest of the network.
Create the LUN
Log into the Synology NAS as an administrator and select the iscsi manager icon.
Click on LUN, and create.
Give your LUN a meaningful name, and select how much space you want to allocate from the Synology Volume.
In order to access the LUN you are creating, you’ll need a target. This can be done at the same time by selecting “Create a new iscsi target”.
Here you can give your target a sensible name, and the complex “iqn” name will be generated automatically. If you were running a production system you would enable chap authentication at this point on the target.
Now that is finished, we can see our target with a mapped LUN. How simple was that?
Configuring the client (the Linux box)
In your web browser, connect to your Fedora server with your administrative user. I’m connecting as root for testing, but ideally, this should be your user with SUDO privileges,
Once logged in, click on the storage tab and scroll down to iscsi targets. This is a list of iscsi targets that your Linux box is aware of. As we don’t have any, we’ll need to add a target and scan for available LUNS.
To scan for LUNS on a target, click the + button and you’ll be asked for a server address. This is the IP, or hostname of your synology server. Click Next to start scanning.
Here you can see a list of targets that it’s found. You are probably wondering why we see 3 targets when we only created 1 ? Well, we have IPv6 enabled so they all present the same lun, it’s just a mixture of ipv4 and ipv6 interfaces. As I use ipv4, i’ll be selecting that one and clicking add.
When we now look at our storage drivesin cockpit, we can see a new disk drive. This is the LUN we selected in the previous step. It can be formatted and treated like any other disk.
Click on the new Synology drive and you can create a partition table on that disk.
Personally, I like ext4 and I’ve chosen to zero the disk. I’ll be mounting it on /home/iscsi
When this completes, you’ll have a 1gb drive mounted from your synology server to the directory /home/iscsi of 1gb. As seen below.
That’s it. A really simple, effective way to add more disks to a VM or physical hosts without having to touch a screwdriver.
Please let me know if you have any comments or feedback.