VM specifically for iSCSI Target


Recommended Posts

I would like to use iSCSI, however this is not a request for that support in unraid, it's obvious from the 9 years or so of posts from people asking for it that it's not happening. Neither am I looking for a discussion of isci vs smb/nfs (enough of those threads).

 

Instead what I have tried so far is running xpenology in a vm and using drive passthrough to get a iscsi target. It generally works fine and as I have recently moved from all xpenology/synology systems to unraid I at least know what I am doing with synology os. Being able to have the iscsi target on a raid array of disks is also important.

 

Problem is the qemu emulation of the drives for some reason causes xpenology to register hdds as ssds, which is not ideal (trim etc running on hdd, likely due to lack of virtio support), plus it seems like unnecessary overhead to run a full synology vm just for iscsi.

 

So, here are my questions. 

Has anyone set up a vm specifically for iSCSI target use with hdd passthrough?

Can anyone recommend a good os that would use the minimum amount of cpu (got plenty of ram) and also be suitable to run in a vm with virio (due to physical setup hba passthrough not possible) and iscsi support?

 

Hoped that there might be others that have gone down a similar road as me that might be able to share their wisdom.

Link to comment
  • 2 weeks later...

If anyone cares or finds this useful, I ended up going with a minimal ubuntu server vm running iscsitarget ontop of a mdadm array with native virtio passthrough.

 

Works great, got a nice 400mb/s network drive that i can install and run stuff from without any issues and is completely separate from my unraid data array.

Link to comment
  • 2 months later...
2 hours ago, Magoogle said:

 I care. Could you provide steps? Also how minimal did you get the ubuntu server?

 

I only have 4GB of ram on my Unraid box so I don't want to run VM's but looks like I have to for this to work out.

Sure thing, on my way out so will have to do it later today. I'll also provide some info of system resources used.

Link to comment

Ok, here goes, I may miss something as I did it all a while ago and it's pretty late here, but this is what I did. 

 

First off I installed Ubuntu LTS with the minimum install iso to a standard Ubuntu VM in undraid, didn't install any extra packages during the install process. 

You could get away with only a 5gb image for the install but I would recommend closer to 10gb if you have the space, just to be on the safe side, atmo my install only uses up about 3gb (4.6gb including swap/efi etc). 

 

Set the configuration you want, I set it to use my 10gbe bridged NIC with 256mb ram and only one cpu core/thread.

 

Edit the VM XML and copy the disk name/identification from unassigned devices into the xml as a new disk (just put 'ata-' infront of the name), you will want to make sure the disk type is block, the device is disk and the driver is raw. Also I found the best performance and stability was using no cache and native io. Here is an example from my config xml:

 

    <disk type='block' device='disk'>
      <driver name='qemu' type='raw' cache='none' io='native'/>
      <source dev='/dev/disk/by-id/ata-Hitachi_HDS722020ALA330_JK2938562935963'/>
      <target dev='hdd' bus='virtio'/>

    </disk>

 

Repeat for each disk, make sure to change target dev to hde, hdf, hdg etc.

Be aware, if you change any setting using the UI, ie not directly in xml, after this then it will reset some stuff like io. So if you want to set up bridges etc do that before adding the disks to the xml.

 

If you have a raid/sas/hba card you can just use passthrough and skip adding each disk, but I haven't tried doing passthrough with pcie cards in unraid yet so you will need to ask someone else for accurate instructions (though it looks much easier to do it that way).

 

Run the VM and install iscsitarget:

sudo apt-get install iscsitarget 

 

Also install mdadm if you are going to run software raid.

 

Check iscsitarget is enabled with 'sudo nano /etc/default/iscsitarget' and make sure enable is set to true.

 

Now for the most important bit, setting up iscsi target config.

 

sudo nano /etc/iet/ietd.conf

 

At the bottom of that file add in your device details, I forget if there is already an example there, if so just edit it to your liking. Mine looks like this:

 

Target iqn.2017-01.local.iSCSI:iscsi.sys0

             Lun 0 Path=/dev/md0,Type=fileio,ScsiId=lun0,ScsiSN=lun0

 

Obviously the most important bit is to change '/dev/md0' for the disk you want to use (probably /dev/vdb if you aren't doing raid).

 

Now just run:

 

sudo service iscsitarget restart

 

Go to your Windows machine and add the target device as your would any other iscsi target.

 

I think that's pretty much it, I know it's a pretty poor tutorial but I need to sleep and I think I covered most of it. I left out the raid stuff but happy to cover that too if you need.

 

In terms of resources, it practically uses nothing, on average the ram usage is about 60-65mb, which doesn't really change much when idle vs full r/w access. You could probably set the VM ram to only 128mb, I went for 256mb for a bit of room just in case, and I have plenty of ram anyways.

 

CPU usage in the vm (running on only 1 thread of a 8 threaded 2ghz cpu) sometimes spikes to 40% usage when I do stuff like disk benchmarks, most of the time with normal use it sits around 0-5% cpu.

On unraid itself the cpu usage barely hit's 2% for the iscsi vm.

 

Overall, I think the only resource use will be with mdadm, not iscsi target itself as that seems to use barely anything. Either way, it's super light, doesn't impact the system and works great.

 

Run my entire steam/origin/uplay library from it and haven't had a problem with any gaming.

 

Edit: Btw, just a reminder, I did not use Ubuntu server install, used the minimal that's like 70mb download or something.

Edited by Iormangund
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.