After much extensive testing, head scratching, and late nights I have figured it out. You would not think setting up an iSCSI target in linux would be that big of a thing, but I was fortunate to have nearly every problem in the book. The frustration started out with a box that for some reason would not let me install things on it. NOTHING. I was originally going to go with OpenFiler, to make things simple. I needed to configure iSCSI because ESXi 5 was not seeing my hard drive. In retrospect, the controller was being seen, just not the hard drive, which leads me to believe with some tweaking I could have made it work, but I guess I just took it as an opportunity to set up iSCSI.
Anyway, this box hated openfiler. The first disk I used had corrupted tar files, others would not get back the initial screen. Installs would fail and drop to intramfs, etc. So I decided to try Ubuntu. Ubuntu was the same story. This machine hated it as well. Dropped to intramfs, wouldn't install (referenced here)
Eventually I got Ubuntu 11.04 server installed and followed the iSCSI setup procedure here but to no avail. In retrospect, it might have been a firewall issue, since I could not get ESXi to see my Fedora iSCSI volumes until turning the firewall completely OFF, but in the end it didn't work and I decided to see whether Fedora 15 would install. I am more familiar with Red Hat anyway since I had a class on it.Fedora 15 xfce desktop installed beautifully without a hitch. Now to getting iSCSI set up. Note I always update on new installs. (yum update)
Foreword: It is important to understand the LVM. LVM stands for Linux Logical Volume manager and is composed of
- PV's (Physical Volumes) - unused partitions on hard disks the LVM can use to store information.
- VG's (Volume Groups) - contains one or more physical volumes. Represents a pool of hard disk storage space that is available to the LVM for creating volumes. Additional physical volumes can be added to a volume group after creation.
- LV's (Logical Volumes) - useable volumes that are created by the LVM from the available space in the volume group. They contain a filesystem and are mounted to a directory in the Linux filesystem hierarchy. Logical volumes can be re-sized to use more or less space.
Step 1: Create a physical volume. In this instance we are creating a physical volume out of the second SATA drives first partition. I usually use CFDISK (cfdisk /dev/sdb) to partition the disk to the appropriate size I need. Note that you can list physical volumes with pvdisplay.
Step 2: Create the volume group:
vgcreate -s 32M vg_target00 /dev/sdb1
This command creates a volume group. The -s tack denotes physical extent size (PE). A large PE size results in larger write operations and larger max filesystem size for the logical volumes. In this example we have chosen 32MB which will allow for a max logical volume size of 2TB, which should be sufficient for most users.
vg_target00 is simply the name of the volume group and /dev/sdb1 is the target physical volume.
Step 3: Create the logical volume:
lvcreate -L 100G -n lv_target00 vg_target00
This command creates a logical volume of 100G with the name of lv_target00 (once again, you can make this whatever you want as long as you reflect that in your config files) in the volume group of vg_target00 we created earlier.
Step 4: Install the iSCSI target program:
yum -y install scsi-target-utils
Step 5: Edit the config file:
There is a lot of garbage in this file, worth reading if you are clueless, but all you really need to look for is the part that starts with #<target and un-comment it. It should look like this:
iqn looks complicated but it is really just iqn.year-month.domain name reversed:pick a name
Save and exit..
Step 6: Start your server
Step 7: Configure iscsi service to start at boot
chkconfig tgtd on
Note: You can check the status with:
tgtadm --mode target --op show
# make sure status
Note: You may have to disable Fedora's Firewall. If you are in a command line environment issue:
service iptables stop
Now all you have to do is set it up on the ESXi server:
And that's it! Hope this post was helpful.