IScsi Target ( with tgt ) and Sheepdog

From Proxmox VE
Jump to: navigation, search


In this article we'll try to explain how to create an iScsi target from a Sheepdog VDI, on a Sheepdog node. We'll be using the tgt version from git, because the tgt version, on debian repository, is too old and doesn't support sheepdog. This HowTo is for Debian Wheezy only.

WARNING: sheepdog is experimental on Proxmox VE and not officially supported.


* SO : Debian Wheezy
* Sheepdog >= 0.8
* Packets : xsltproc, libconfig-general-perl
* Git
* tgt from git

Installation of tgt from Git

It's recommended to have an up-to-date system:

aptitude update
aptitude safe-upgrade

First we need to install xsltproc for the tgt documentation and libconfig-general-perl for the tgt tools:

aptitude install xsltproc libconfig-general-perl

Then, we can download, build and install tgt :

cd /opt/
git clone
cd tgt
make install

We need to check if this directory have been created:


If not, we need to create them manually:

mkdir -p /usr/lib/tgt/backing-store

At this point, if there wasn't any problems, we have successfully installed the latest version of tgt.

Exporting an Sheepdog VDI

We need a sheepdog vdi, and if we don't have one, we can create it :

dog vdi create tgt_test_0 10G

Note: 10G = 10GB

For the first execution, I recommend to have two shells. In the first shell we launch:

tgtd -f

I'll start the tgt daemon in foreground, so we can see directly what's happening in case of prolems/errors. On the second shell, we are using the commands .2 and .3 .


You can simply use :

tgtd -f &> /var/log/tgtd.tmp.log &
tail -f /var/log/tgtd.tmp.log

With this, we are ready to proceed:

# start tgt daemon
 .1 tgtd # or tgtd -f &> /var/log/tgtd.tmp.log &

# create the target
 .2 tgtadm --op new --mode target --tid 1 --lld iscsi --targetname

# connect iScsi
# NOTE: tgt_test_0 is the vdi name
( unix socket method )
 .3 tgtadm --op new --mode lu --tid 1 --lun 2 --bstype sheepdog --backing-store unix:/var/lib/sheepdog/sock:tgt_test_0

Or ( tcp/ip method )

# NOTE:  --backing-store tcp:[node ip]:[node port]:[vdi name]
 .3 tgtadm --op new --mode lu --tid 1 --lun 2 --bstype sheepdog --backing-store tcp:

# last, bind to an interface ( in this case all )
 .4 tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL


Short list of some encountered problems, on the relative commands :

 Command .2 : 
  - tgtadm: failed to send request hdr to tgt daemon, Transport endpoint is not connected

The tgtd daemon is not running or it's having some problem. Need to be started/restarted.
 Command .3 : 
  - tgtadm: can't find the target

Retype command .2 . If persist, see next problem suggestion.
 Command .3 : 
  - tgtadm: invalid operation

Check if sheepdog is online and running, check the sheepdog log ( default /var/lib/sheepdog/sheep.log ) then check for tgtd error messages, if you have used tgtd -f or tgtd -f &> /var/log/tgtd.tmp.log & , else relaunch it with one of those methods.