Linux – How to make disk available through ISCSI target on Ubuntu 16.04

iscsilinuxstorage-area-networkUbuntuubuntu-16.04

I am trying to have some disk available to a Windows Core Server through a ISCSI on Ubuntu 16.04. I tried NFS but it is not available for Core edition and samba is not what I need.

The thing is, I have disks available /dev/sdb and /dev/sdc for this purpose and I cannot figure out how to make them available. All the info I seem to find is for windows or by making an image of X size but then it will only take as much space as wherever the OS is.

I first tried iscsitarget but after looking more into it, one of the modules is not build for my kernel and I cannot seem to find any info on how to make it work. I really thought I could use it at first since almost all the tutorials use this so if it ever starts to work I'd still like to know. Here is the conf file with an img as path :

Target iqn.2015-05.com.exemple:storage.sys0
        Lun 0 Path=/storage/volume0/lun0.bin,Type=fileio

If I go with targetcli, I find myself with the same problem (how to add a disk instead of image). Here is how to create the img, I cannot seem to find what the conf file is :

create disk01 /var/iscsi_disks/disk01.img 10G 

For now these are the only two options I found on how to do a iscsi target and both only simply say how to make an img. How would I make them use a whole disk ?

EDIT: as asked in comments

lsblk

NAME                        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sdb                           8:16   0  1,7T  0 disk 
└─sdb1                        8:17   0  1,7T  0 part 
sr0                          11:0    1 1024M  0 rom  
sdc                           8:32   0  3,3T  0 disk 
└─sdc1                        8:33   0  3,3T  0 part 
sda                           8:0    0 67,8G  0 disk 
├─sda2                        8:2    0    1K  0 part 
├─sda5                        8:5    0 67,3G  0 part 
│ ├─serveur--nas--vg-swap_1 253:1    0   32G  0 lvm  [SWAP]
│ └─serveur--nas--vg-root   253:0    0 35,3G  0 lvm  /
└─sda1                        8:1    0  487M  0 part /boot

cat /proc/partitions

major minor  #blocks  name

   8        0   71041024 sda
   8        1     498688 sda1
   8        2          1 sda2
   8        5   70539264 sda5
   8       16 1756495872 sdb
   8       17 1756493824 sdb1
   8       32 3513778176 sdc
   8       33 3513776128 sdc1
  11        0    1048575 sr0
 253        0   36999168 dm-0
 253        1   33505280 dm-1

Best Answer

To use a whole disk as an iSCSI target, just specify the disk in your configuration file:

Target iqn.2015-05.com.exemple:storage.sys0
    Lun 0 Path=/dev/sdb,Type=fileio
Related Topic