Connect your Raspberry Pi to a NAS using iSCSI
HTML-код
- Опубликовано: 21 авг 2024
- One way to expand the storage on your Raspberry Pi is to connect it to a NAS over protocols like SMB, or NFS. Those are file sharing protocols. However the Raspberry Pi (and Linux) also support block level access to remote storage, using iSCSI. Here is a tutorial on how to connect your Pi to a NAS using iSCSI.
HOWTO: github.com/gar...
How to Partition and Format a Disk in Linux: • How to Partition and F...
Synology DS420j Review, Hands-on, and Setup Guide: • Synology DS420j Review...
Synology NAS - Free Yourself From the Cloud: • Synology NAS - Free Yo...
Let Me Explain T-shirt: teespring.com/...
Twitter: / garyexplains
Instagram: / garyexplains
#garyexplains
ERRATA: You don't need to edit the /etc/iscsi/initiatorname.iscsi file and set the InitiatorName. Just leave the file as is. The iSCSI qualified name (IQN) of the Pi is defined in `/etc/iscsi/initiatorname.iscsi`. During installation the initial IQN will be generated automatically. If you wish to create a new IQN then use the `iscsi-iname` utility, it will print out a new IQN for you.
I like the speed at which you go through these.
I tend to be impatient and just want to get the major points before going off to do it myself.
Liked SCSI, I remember with CD-R drives came affordable for the home user, my friends had constant buffer under-runs with their IDE CD-R drives, I had an external SCSI one had no issues at all.
As mentioned in other comments. The initiator name and target should be different. Looking at Synology, there is a Custom option for the configuration where you can limit the advertisement of the LUN to a set of IP addresses or initiator names. When unspecified All imitators doing the connect to the target will see those LUN.
Great job getting folks started on the ISCSI path. I’ll also mention that one might have different sd drive letters assigned (like if you stick a USB in or have multiple targets responding). In this case, I use File System labels for my mount in fstab (or LVM2 on top of iScsi and leverage the Group and Logical Volume names in my mount.
netdev option in fstab was also mentioned earlier.
Thanks Gary -Now I get it!, simple when it has been explained to you -thank you. Cheers.
iSCSI is great stuff for certain applications, but you need to be sure that the network connection is rock solid or you may end up with corruption. The underlying subsystems are intended for use with locally attached drives and are much less forgiving than network file protocols like SMB or NFS.
Actually Gary, you can put an fstab entry in there and then add "_netdev,x-systemd.requires=iscsi.service" to the mount options. At least assuming you are using Raspbian, as I am, and my system is using systemd. This is even better since the sleep either wastes time, or isn't long enough and then it won't work.
Otherwise great video. Only suggestion might be to give some suggestions how this could be useful. I can see some uses for sure, but a lot of people might be asking why do this over just using the Synology. But then again not everybody might run lots of Pi boards running different services and wanting to co-locate the data onto a single NAS/SAN.
Thanks for the info. I will update my document in GitHub. 👍
Another tip in /etc/fstab is the Label of the Filesystem [LABEL=] (created with mkfs -L OR e2label) or disk UUID [UUID=] and not hardcode the /dev/sda, if you have multiple iSCSI targets for a single client you run the risk of different device assignment order.
I run
Raspberry Pi 3B
Raspberry Pi 4B 2GB
2x Raspberry Pi 4B 4GB
I have Lenovo M93p Tiny working as VLAN router, DHCP, DNS and kerberos server
I just managed to setup kerberised NFS (second time with 10 years between)
I am happy with that
I have Dell PowerEdge R715 and R815
I shall be downloading whole RHEL repository (definitely release 7 and 8, maybe 6 too)
I may end up at least trying downloading SLE too
Now I can make mirror for Ubuntu as well
I have full mirror of Debian already
Now I can access all of this as file not through http or ftp (surprisingly very slow)
Really useful video Gary. Thanks.
Glad it was helpful!
You stopped your Speed test G videos. I miss them a lot.
Are you going to test the S22 ultra ?
Love the background!
Wow!! Very useful video not just for iscsi not just for the pi. I wanted to do something similar for nfs mounts and your info near the end helps me with that too. I'll experiment with iscsi on other devices. I'll setup an iscsi server on another linux device.
absolutely brilliant explanation, thank you!
Glad it was helpful!
Technically correct and very well made video 👍
But for my home, this would be a novelty, fun project only.
Not sure iSCSI is advisable in a home lab or home network. Better for enterprise SAN.
Kindest regards, neighbours.
Well explained. Easy when you know how.(I didn't before!)
Very nice video, TNX.
I love this Gary.. thank you.
Excellent as always. Thanks -
Many thanks for this topic. I'm complete new and just started with the raspberry pi 4. I manage to install the iSCSI. The folders are visual 'lost + found' Only I have no acces to the folders ie. no permission. So something went wrong but i'm lost to find a solution.
😁
Hey there,
you did a small mistake: the initiatorname on the pi should not be changed! It's the name of the pi and not the targets name. The pi needs to have a unique iqn. I don't know DSM but if you have a look into the UI it should now show the client with the same iqn as the target. As stated before that might be problematic.
Other than that, great video, thank you very much! :)
Ah! Yes... I think you are right. I will edit my document on GitHub and leave a pinned comment on this video.
@@GaryExplains thank you :)
Shouldn't that InitiatorName be unique so you can distinguish between different initiators? Now what would happen if you had multiple initiators with same name?
Also don't think you can specify multiple InitiatorNames in case you have multiple targets.
Ah, I see what you mean. Yes, I think I made a mistake there. I will edit my document on GitHub and leave a pinned comment on this video.
@Gary Explains a better way to mount after boot-up by using a #systemd service that ensures the network is already up? Credit to @ Chris Titus Tech (CTT) for the idea.... Apologies for any inappropriate fields and/or errors ...
## example systemd file
[Unit]
Description=Mount iSCSI drives on boot-up
Wants=network-online.target
After=network-online.target
[Mount]
What=/dev/sda1
Where=/iscsimnt
Type=ext4
Options=defaults,rw,noatime
[Install]
WantedBy=mutli-user.target
You may want to change the file permissions for the /iscsimnt as it's owned by only root...
Thanks, Professor!
#question: If you have multiple drives across several Pis that your want to include in a muti/mass storage unit, is that doable via iSCSI commands? (I don't have a Synology bay. I do have several Pi 4Bs with SSD external storage.)
Yes, under ZFS. You might need GlusterFS if you want multi-host storage redundancy. Either way you lose quite a bit to redundancy. What do you think, Gary?
❤
Genius.
Hi, I already followed those instructions wrt initator name edits. My R pi hung and is not restarting. This happened just when I was filling up the '.sh' file. I am not sure if it was because of editing the isci/initiatorname. Anyone else encounter this?
scsi drives were parallel drives and there was a limit of how long the cables could be and had to have a termination plug to tell it the end of line. In a parallel cable all the bits have to arrive at the same time or it will not work, so the longer the cable the more chance of an imbalance between the lines of the cable. The irony now is the distance is no longer a problem or is it?
For direct attached drives there is a distance limit. Faster buses usually get smaller lengths. iSCSI and other SAN protocols increase these limits as they are networking protocols. However as the latency increases so does the chance of corruption. So while you could run iSCSI over the public internet people tend not to. Packet delays and dropouts make it challenging to run block level protocols. The filesystems that run on top of iscsi wouldn't handle networking issues very well. But you could run iSCSI over the internet if you wanted to.
Sir speed test g latest. Many new phones are out now with new soc
can you flash it to ntfs
Why greping using single pattern?
Why not grep 'scsi\|sd'
I use grep 'scsi\|sd\|ata' to show everything concerning drives
Not using basics of grep leads to nie being able to use sed and awk
I use sed on daily basis, usually to shorten my one-liners (which quickly becomes litany or rather prayer to not mess up)
Any reason why you didn't use crontab to run the script after boot?
You can use whatever you are comfortable with. For me when I did my Unix system admin training (many years ago) we used rc.local, and that is what I still use now.
i just want to be able to buy a RaspberryPi...
I haven't look in about a month, but I've been trying to get a couple also. I've seen them, just way overpriced.
Q: can iscsi abuse cloud storage?
If I understand your question correctly, iSCSI is quite chatty and not a WAN type protocol and requires a pipe BIG in both directions. It is best to have the Target available locally, if it chooses to leverage a .img file as the backing from a Cloud Provider, it would be interesting to measure the impact. As I see from my searches, ubuntu, at least, has a tgt package to playing the Target and can be configured to have a .img file be the Source of the LUN.
ipv6 is still a pain to setup.
Hobbyists ignore IPv6. Maybe it's time we were more friendly towards her.
Was anybody else shouting 'lsblk" at the screen?
That’s cherry pie in the thumbnail…
🤦♂️
Connecting through a block level protocol makes the storage device a SAN rather than a NAS.
Indeed which is why we use the SAN manager to create the Target. But it doesn't stop being a NAS. It isn't mutually exclusive.
@@GaryExplains well maybe not anymore since the advent of block level protocols over IP as iSCSI, but in the older days there was a clear distinction. A SAN was implemented over Fibre Channel using Fobre Channel switching equipment were required.
Well if "not anymore" why mention it?
The reason it hangs on ip6 is you are using link local address space (fe80::). Though I do not recommend using those, they will work if you specify the interface for the address, IE. fe80::1%eth0
The problem is that the ipv6 stuff is being discovered and used by the iscsiadm command, it isn't something I have explicitly setup.
@@GaryExplains right, and this in turn because iscsid assumes your network is properly set up. It's enterprise stuff; normally you would add fancy stuff like dm-multipath on top of that. Maybe a fix: turn off ip6 in your target daemon or better yet set your router to advertise FD:: private address/autoconf. Those will be global and work out of the box
Does that mean that ipv6 isn't setup correct by default on Raspberry Pi OS?
@@GaryExplains The OS (Synology Pi, ect) is doing the right thing: Falling back to link-local because it cannot get a global address. Your home network lacks correct ip6 advertisements. Since you likely get dual stack from your IP provider this topic might be worth a video?