Please consider donating: https://www.corelan.be/index.php/donate/


1,731 views

Create a free SAN on Fedora Core 6

While setting up the basic infrastructure for my VMWare environment, I wondered if it would be possible to emulate a SAN on a Linux box, for free. And as a matter of fact, it is possible.

I stumbled across the iSCSI Target project on sourceforge which was built to do exactly that. In this post, I’ll try to describe the steps that I’ve performed to get it up and running. In a later phase, I’ll also show you how to connect to the SAN using VMWare ESX, or from within Windows.

My setup consists of a regular PC, with lots of RAM, fast processor, a big and fast harddrive and a Gigabit network card. This is a very minimal setup and does not offer any redundancy whatsoever, so if you want to do this yourself, make sure to add the missing redundancy pieces.

The PC was set up with a fairly default setup of Fedora Core 6. I’m not going to discuss the details about that in this post, and I will assume that you know the basics of the RedHat/Fedora OS and/or Linux in general. If you have problems setting it up and hardening it, let me know. There is something to remember. You may want to keep a separate disk or a separate partition on your harddrive, so you can assign it to the iSCSI Target software. If you’ve already set up Fedora using all of the diskspace and you don’t have any spare disks lying around, you can use the gparted tool to shrink your disk and create space for another partition.

Anyhow, after setting up the base OS, I wanted to make sure I have the latest version of all packages, so I ran a “yum update –v“. Check the iscsitarget website for any other prerequisites in terms of kernel version and development libraries. The only packages that looked important to me were the kernel-devel and openssl-devel rpm packages. You may want to verify that these packages exist prior to start the iscsitarget installation.

First of all, get the .tar.gz file from the sourceforge website. At the time of writing, the latest stable version is 0.4.15. Put the file somewhere in a folder and extract the zipped tarball

tar xvfz iscsitarget-0.4.15.tar.gz

Next, go in the unzipped folder

cd iscsitarget-0.4.15

 Before compiling the package, you need to check the kernel version of your system. You can do this by running uname –a. Next, export the correct path to the location where the kernel sources reside (for your kernel). In my example, I’m running kernel 2.6.20-1.2962.fc6, so this is what the command looks like on my system :

export KERNELSRC=/usr/src/kernels/2.6.20-1.2962.fc6

Now, you can compile and install the package :

make && make install

So far so good. Verify if the process ended without errors and you’re almost ready to start setting up the SAN.

In this tutorial, I’ve dedicated /dev/hda3 to be used as SAN storage.

Edit /etc/ietd.conf and modify the ‘Target’, ‘Lun’ and ‘Alias’ entries. You can find more information on what values to use for those 3 entries in the file itself. In my environment, these are the values that I’ve used :

Target iqn.2001-04.be.corelan:san1
        Lun 0 Path=/dev/hda3
        Alias iSCSI

You can, of course, add multiple targets, add multiple Lun’s to a target and so on. If, for example, you want to add another Target and corresponding lun of 100Gb, this is what you can do:

mkdir /san
dd if=zero bs=1M count=102400 > /san/100gb.file

This will create a big file of 100Gb, which can be used as a san lun as well.

Next, edit /etc/ietd.conf and add the following lines :

Target iqn.2001-04.be.corelan:san2
        Lun 0 Path=/san/100gb.file,Type=fileio
        Alias iSCSI2

 At this point, you are ready to start the service :

/etc/init.d/iscsi-target start

  You should get the following entries on your console or in the logfiles (/var/log/messages)

iSCSI Enterprise Target Software – version 0.4.15
iotype_init(92) register fileio
iotype_init(92) register blockio
iotype_init(92) register nullio

  If you want the iscsi-target daemon to start when your linux system boots, run the following command :

chkconfig iscsi-target on

In a next post, I will show you how to connect to the SAN using Windows and in another post, I’ll explain how to do this using VMWare (ESX)

© 2007 – 2008, Peter Van Eeckhoutte (corelanc0d3r). All rights reserved.

Comments are closed.

Corelan Training

We have been teaching our win32 exploit dev classes at various security cons and private companies & organizations since 2011

Check out our schedules page here and sign up for one of our classes now!

Donate

Want to support the Corelan Team community ? Click here to go to our donations page.

Want to donate BTC to Corelan Team?



Your donation will help funding server hosting.

Corelan Team Merchandise

You can support Corelan Team by donating or purchasing items from the official Corelan Team merchandising store.

Protected by Copyscape Web Plagiarism Tool

Corelan on Slack

You can chat with us and our friends on our Slack workspace:

  • Go to our facebook page
  • Browse through the posts and find the invite to Slack
  • Use the invite to access our Slack workspace
  • Categories