A year or so I got a piece of hardware. This piece of hardware, the Quad SATA kit for Raspberry Pi , allows a person to attach 4 SATA laptop drives to a Raspberry Pi. These drives are connected to the Raspberry Pi via the two USB 3 ports. This opens up a lot of possibilities of things to do with the Raspberry Pi. At the time I filmed a video on how to turn a Raspberry Pi into network attached storage (NAS) part 1 part 2 and part 3 . Now, though, I use it as an iSCSI target. How did I set this up? Well that’s what this blog is about.
Set up the Raspberry Pi
The first thing you need to do is assemble the hardware. I won’t describe how to do that. If you need help please see the part 1 video linked above. Next you need to configure the software. Setting up the Raspberry Pi is a hodge podge of commands in Linux. For this experiment I used Ubuntu 20.04 as the operating system. You can use Raspberry Pi OS also if you want, but I prefer to use Ubuntu. On Ubuntu the default login is: username ubuntu password ubuntu
Ubuntu is great in that it forces you to change the password on the first login, and then it logs you out so you are forced to use the new password right away.
Then we want to do some housekeeping. First I remove unattended-updates and wpa_supplicant:
sudo systemctl stop unattended-upgrades.service sudo systemctl disable unattended-upgrades.service sudo systemctl stop wpa_supplicant.service sudo systemctl disable wpa_supplicant.service sudo apt remove unattended-upgrades
I change the hostname of the computer by changing what’s listed in the
/etc/hostname file and a corresponding change in the
/etc/hosts file to add a line:
127.0.1.1 machinename.domain.local machinename
Next I update the system with everyone’s favorite command:
sudo apt update && sudo apt upgrade -y. Finally we reboot and we are ready for the next step.
Next you need to install the software for the Quad SATA kit. This can be accomplished with this command:
curl -sL https://rock.sh/get-rockpi-sata | sudo -E bash -
Unless you have the Argon EON, in which case you’ll want to run this command:
curl https://download.argon40.com/argoneon.sh | bash
After a reboot this will enable all the different components of the SATA HAT. THis includes the fan, the OLED Scree, the button (that I’m still not clear what it does), and, importantly, all four SATA drives. There was a problem with early models where only two of the drives would be discovered due to the way that serial numbers were handled across the two lanes of USB. This was fixed in a software update from the company that makes the Quad SATA kit. I don’t have the URL anymore. So, if you find it let me know.
Setup The RAID
Creating the RAID array was a straight forward process. First you need to install
mdadm. This is done with the following command:
sudo apt install mdadm
Then we’ll make sure that all 4 drives are seen by the OS. This is done by listing the block level devices
lsblk this will show the four drives as sda, sdb, sdc, and sdd. It’s important that you don’t see any partitions listed here. You’ll know partitions if you see a number after the sda, sdb, sdc, or sdd (like sda1). If you see a number after one of them you should erase that partition, and create a blank partition You erase a partition with these commands: WARNING This will erase all the data on the drive I’ve specified as sdx below
sudo fdisk /dev/sdx d n w
d deletes existing partitions
n creates a new partition
w writes the information to disk
Next we’ll create the RAID array with the
mdadm command. In here I am naming the volume vol1 and it is mounted to /dev/md/vol1. The Vol1 part can be anything you like (as long as it’s a valid Unix file name). It also specifies that I want RAID level 5. I’m not going to explain the different RAID levels here, but this is the one I’ve picked because it gives us the most amount of usable disk space when compared to raid 10
sudo mdadm --create --verbose /dev/md/vol1 --level=5 --raid-devices=4 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1
Next let’s confirm that the RAID array was created by issuing the next command:
sudo mdadm --detail /dev/md/vol1
You should get something that ends like this:
Number Major Minor RaidDevice State 0 8 1 0 active sync /dev/sda1 1 8 17 1 active sync /dev/sdb1 2 8 33 2 active sync /dev/sdc1 4 8 49 3 active sync /dev/sdd1
Now for some reason this won’t survive a reboot. so the next set of commands will ensure that the RAID array will survive the reboot:
sudo -i mdadm --detail --scan >> /etc/mdadm/mdadm.conf cat /etc/mdadm/mdadm.conf exit
The first line puts you in interactive sudo mode. Next we take the detailed scan of mdadm and output it to a file called mdadm.conf. Then we
cat the output to make sure that the file exists and has valid information in it. Finally we exit the interactive sudo mode. Simple enough, right?
From here we have several paths we can choose. On the one hand we can format this drive with something like btrfs or ext4, mount it, and use it for a SAMBA share for a self hosted NAS. We could install some NAS software like Open Media Vault to help us with the task of configuring the NAS. Or we can expose the whole thing as an iSCSI target.
There are pros and cons for each of these, and ultimately it depends on your use case. For me I found the best use of this little device was to use it as a large drive attached to my main computer using iSCSI. I have a Synology NAS , and it works well. So I wanted to play with a new technology (not new but new to me) like iSCSI. If you are interested I’ll write a post on how to setup an iSCSI target on this device.
Either way let me know what you thought of this. Send me a message on Twitter @spatacoli . Thanks!