User Tools

Site Tools



iSCSI Target

I am moving our iSCSI target over to FreeBSD. Our iSCSI servers are generally used as the “disk drives” for Xen virtual servers. NFS with File Backed Devices (FBD) is really too slow when several virtuals are running at the same time, but iSCSI appears to fix this issue.

This document will describe how it is built.

Basic Requirements

  • NFS service used for common files
    • xen-configs stores the Xen configuration files shared by all DOM0's. It is generally mounted under /etc/xen/iscsi-configs
    • xen-store stores common files for all DOM0's. This includes ISO images (for install and/or maintenance).
    • xen-images stores FBD's, allowing quick and dirty testing where necessary.
  • iSCSI exports for the virtual images. Each virtual may have one or two images exported by the iSCSI target. In many cases, I use a small image for the operating system, then a larger image for the data. The second image for Linux is usually set up as a Physical Volume for LVM2 during installation. For FreeBSD, it would be ZFS. For Windows, we generally use only one image.

The Setup

  1. Do a basic install with any utilities you might commonly need. My personal choices are in the article Basic FreeBSD Installation, which is still a work in progress.
  2. Install NFS
    1. Create a directory tree under /media/nfs
    2. Populate NFS directory tree
  3. Install iSCSI
  4. Create some ZFS volumes to store the images and configure iSCSI to export them
  5. Start the iSCSI service



Most of this was taken from

#! /usr/bin/env bash
# Note that this is a BASH script. The looping instructions
# in this script will not work under sh, which is the default
# for FreeBSD.
# Change the following two options for your system
# enable (but don't start) NFSv4 daemon
echo nfs_server_enable="YES" >> /etc/rc.conf
echo nfsv4_server_enable="YES" >> /etc/rc.conf
echo nfsuserd_enable="YES" >> /etc/rc.conf
# create a place to store the NFS exported data
mkdir /media/nfs
zfs create storage/nfs
zfs set mountpoint=/media/nfs storage/nfs
# build the exported directory structure, and insert each
# export into the /etc/exports file
for subdir in xen-store xen-configs xen-images
   mkdir /media/nfs/$subdir
   echo '/media/nfs/$subdir $SUBNET($NFS_OPTIONS)' >> /etc/exports
# start (or restart) the service
service nfsd restart

Set up iSCSI server

Create iSCSI volumes and export them


unix/freebsd/system_builds/iscsi_target.txt · Last modified: 2016/09/08 00:58 by rodolico