Mirrored Root on ZFS on Linux on iSCSI on Root on ZFS on FreeBSD …yo dawg! – Act 1: iSCSI

Dear diary…

…today I tried to configure a live offsite-backup for my laptop with ZFS, a remote server and iSCSI – this is (a rough schematic of) what came out:

In words this means:
I have a local RAID1 made out of 3 backing disks:

  • TRION150 – my internal SATA3 240GB SSD
  • SDSSDHP-256G – a SATA3 256GB SSD, connected via a USB3.0 SATA adapter
  • offsite-backup – a „virtual“ disk, brought to me by iSCSI

On every raw device is a cryptsetup-layer to encrypt my precious data.

offsite-backup is a block device connected via iSCSI, the Internet Small Computer Systems Interface.
It’s real backing device is a zvol, a ZFS Volume, residing on a FreeBSD server, on another RAID1 made out of two 2TB HDDs (which also stores the servers root-filesystem)

In this (and the following posts…) I will show you how I did this and maybe how it performs.

Disclaimer: I have no idea what I’m doing!

I don’t know if this works good enough to have it enabled most of the time.
I don’t know if it breaks as soon as your internet is flaky.
I don’t even know if it’s secure (enough).

Please don’t blindly copy anything from the web!

Let’s get to the meat of this right away, the other parts are less interesting but will/may follow in seperate posts…

Act 1 Part 1: Linux

On the linux side we only need to install open-iscsi, since I’m on Archlinux (yeah yeah, hate me for it. I do it too. :c) it’s as simple as:

on Ubuntu/Debian it’s also really simple:

for all other distributions: I have no clue. What the actual fuck even is „Hannah Montana Linux“ and why do you use it as a daily driver?!

…uhm, after installing open-iscsi you need to edit /etc/iscsi/iscsid.conf to contain the following things (please read the examples/manpages/etc. for your distribution for more details):

Line 1 is totally optional AND probably different on other distros than Archlinux. It allows you to open the iSCSI-connection without manually starting iscsid first.

And with that, we are done with the linux-stuff. 🎉 Yay! 🎉

Act 1 Part 2: FreeBSD

Now over to our FreeBSD server, first of all we need to create a zvol that we want to serve over iSCSI:

This creates a 300GB sparse zvol with a 4K blocksize (which is the most performant blocksize on modern disks), identifying itself like a real harddisk.
Sparse zvol means it is allowed to grow until it reaches 300GB but won’t pre-allocate that space.

Now we can configure the server, just create /etc/ctl.conf with the following content (and replace with your own values…):

after this add the line

to your /etc/rc.conf and finally run:

(Make sure tcp port 3260 is opened in any firewall in front of this server.)

and we are also done with FreeBSD. 🎉🎉🎉

Act 1 Part 3: Back on Linux. Using the stuff.

After configuring all of this, we still need to connect the disk.

First you need to ask the server what disks they serve:

Then you can connect the disk (replace $targetstring with one of the targets from previous command):

Now you have an additional block device in /dev. Use it to your needs/liking. 🎉🎉🎉

When you are done with the device you can disconnect (like hot-swapping SATA) it with:

(again, replace $targetstring with one of the targets from previous command)

PS: the resilvering on my 200/50 MBit/s connection will be finished in…

One hundred and one hours! Yep. 😐

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.