ZFS over iSCSI on Debian Jessie

Hi, this article is under construction. However, I never seem to find time to do it.
Maybe somebody finds it helpfull. Probably these packages can be found in the Debian repository by now.


The SCSI Target Framework (STGT/TGT) was the standard before linux 2.6.38.
The current standard is the LIO target.
The iSCSI Enterprise Target (IET) is an old implementation and SCSI Target Subsystem (SCST) is the successor of IET and was a possible candidate for kernel inclusion before the decision fell for LIO.

lio-utils are deprecated and have been superseded by targetcli.

LIO target is included in the kernel since 2.6.38. However, the iSCSI target fabric is included since linux 3.1.

Marc Fleischmann DATERA v.s. Andy Grover. Mediated by Ritesh Raj Sarraf for Debian.


There is a reported issue with LIO in Linux kernel 4.2.x, will be fixed in 4.3, so all distros using this kernel will have the same issue. I don’t know if 4.2.x will get the fix so I’d recommend 4.1 until 4.3 comes out.

In debian backports!

Installing targetcli

Getting some prerequisites

We’re kicking off the installation with python3-rtslib-fb. Make sure you get the bpo version from the backports repository. This will also pull in the Python 2.x version python-rtslib-fb and python3-six, so make sure you get the bpo versions from these as well.

The other packages are not currently included with Debian Jessie. To compile them from source, we need a few packages: git, build-essential, fakeroot, debhelper, python-setuptools, python3-setuptools, python-epydoc, python-pyparsing, python3-pyparsing, python3-urwid, dbus, python3-dbus.

Getting started with GitHub

If you’ve never been to GitHub.com before, you’ll need to set up an account.

git config –global user.name “your_github_username”
git clone https://github.com/agrover/configshell-fb.git
git clone https://github.com/agrover/targetcli-fb.git

Building and installing configshell-fb

cd configshell-fb/
make deb
dpkg -i dist/*.deb

You can ignore the ImportError messages.

Building and installing targetcli-fb

cd ../targetcli-fb
make deb
dpkg -i dist/*.deb


Writing a Twitter bot


Using Twitter to log automatically generated messages is very easy. Since you don’t have to deal with human users, you can skip a large part of the authentication process.

A Twitter bot

Twitter uses the OAuth protocol to authenticate it’s users and messages. It works by signing every HTTP message between Twitter and the user with a cryptographic key. The signature is then added to the message, which allows the receiver to verify if it really originated from the sender.

To receive this cryptographic key, normally the user would go through a lengthy authentication procedure designed to check the username and password in a secure manner, part of which happens by sending the user to a website on Twitter’s own servers. But, if at this point you’d like to stop reading and download some fancy Twitter library, there is an easier way.

Since we are writing a bot, we have no users (well, except your bot of course), so we can take a shortcut and get the key directly from Twitter. This key, called an access token, works as some sort of permanent authentication and we can use it to sign all of our messages.

Getting started

To start tweeting, you first need an account for your bot, so get one. Of course you can also have the bot tweet from your own account if you want.

Second, at the Twitter developers site, go to My applications to register a new application for your bot. Hint: You don’t need a Callback URL.

The first thing you have to do is change the Access level to Read and Write. It can be found on the Settings pane and allows your bot to tweet. It has to be changed first because it is stored in your access token, which we are going to generate next.

Back on the Details pane, generate your access token and verify that its Access level indeed mentions Read and write. You can save the Access token and Access token secret to your source file, because we will need both in the code. Also save the Consumer key and Consumer secret from this page for the same reason.

Writing the program

To simplify things a little, we use a minimal OAuth library already available with Ubuntu and Debian Linux. Install liboauth-php and we can begin:

$tweet = 'Hello world!';

Every Twitter action can be taken by accessing a specific URL. This is called the REST API and, in this case, updating our status is what we normally call tweeting.

$consumer = new OAuthConsumer('ConsumerKey', 'ConsumerSecret', NULL);
$acc_token = new OAuthToken('AccessToken', 'AccessTokenSecret');
$sig_method = new OAuthSignatureMethod_HMAC_SHA1();

These objects are used to sign your requests. Enter the secrets, key and token you noted earlier. Now it’s time to send our first request, an update status request.

$options = array('status' => $tweet, 'trim_user' => 'true');
$twitter_req = OAuthRequest::from_consumer_and_token($consumer,
$acc_token, 'POST', TWITTER_UPDATE_STATUS_URL, $options);
$twitter_req->sign_request($sig_method, $consumer, $acc_token);

In the options we tweet our new status, and set trim_user to limit the amount of data Twitter sends back to us after tweeting. Then we create a new Request object and sign it using all our keys.

There are many ways to get our request to Twitter. Some people, even libraries, use the cURL library. To me, that seems overly complicated and below I’ll show you how to simply use file_get_contents() to submit a HTTP POST request.

$context = stream_context_create(array(
'http' => array(
'method' => 'POST',
'header' => 'Content-Type: application/x-www-form-urlencoded',
'content' => $twitter_req->to_postdata()
$result = file_get_contents(TWITTER_UPDATE_STATUS_URL, false, $context);

And there you have it, your first automated tweet!

The stream context stores the HTTP headers and POST data, which are sent when we request the update_status page. The Twitter server will respond with some feedback you can check. Note that Twitter doens’t allow you to submit the same tweet twice.

Happy tweeting!