Monday, July 12, 2010

Configure FreeNAS - iSCSI untuk ESXi

Hari ini berbeza sket , sebab selalunya dalam ni cite pasal ubuntu tapi kali ni aku nak setkan satu storage yang dipanggil iSCSI untuk digunakan oleh ESXi untuk host server-server Ubuntu aku. Sorry aku cut and paste dulu takut lupa , dia dalam bahasa inggeris ok. So aku dapat tutorial ni setelah pueh mencarinya di google.

FreeNAS 0.7 – Add an iSCSI Target for beginners

Since the graphic interface in FreeNAS 0.7 has changed, finding some good tutorials on how to mount an iSCSI target prooved imposible. Neither Google nor http://sourceforge.net/apps/phpbb/freenas/ helped. And just because I was missing bits of information, I was getting various errors. Like this one:

Mar 22 08:28:51 freenas root: Failed to start service iscsi_target
Mar 22 08:28:51 freenas istgt[3194]: istgt.c:1247:main: ***ERROR*** istgt_lu_init() failed
Mar 22 08:28:51 freenas istgt[3194]: istgt_lu.c:1513:istgt_lu_init: ***ERROR*** LU1: lu_disk_init() failed
Mar 22 08:28:51 freenas istgt[3194]: istgt_lu_disk.c: 407:istgt_lu_disk_init: ***ERROR*** LU1: LUN0: open error
Mar 22 08:28:51 freenas istgt[3194]: istgt version 0.2 (20090428)

So here is my “prooved-to-work” step-by-step tutorial.

A. Prerequisites:

-FreeNas 0.7 is installed and running on a hard-drive or USB thumb-drive (I prefer this one). I am using revision 4919.

- Web interface is up and running.

- At least one empty HDD, preferably with no previous partitions of any kind.

- Patch the FreeNAS machine with the updated file “iscsi_target.sh” and add it to both /etc/rc.d/ and /cf folders. See http://sourceforge.net/apps/phpbb/freenas/viewtopic.php?f=53&t=4561&start=10#p22148 for details. Do not skip this patch!

B. Initialize the Hard Drive.

1. In the web interface go to Disks -> Management . (In my screenshot I already have two disks installed). Click on “plus” sign to add the harddrive:

Add new disk - step 1

2. In the next screen, choose the target disk from the drop-down menu (if it is not listed, there is either a hardware problem or disk may have some partitions on it – try Rescan disks); and choose the Preformated file system as “UFS (GPT and Soft Updates). The other two marked fields are optional (for S.M.A.R.T. you need to have the service enabled). Then click Add button.

Add New Disk - step 2

3. Click Apply changes (see bellow). The status of the newly added disk should be “Initializing”. One thing I found is that this status will not change to ONLINE by pressing again Apply Changes or Rescan disks. Only a complete restart will do. I do not recommend going further unless the disk is listed ONLINE. Therefore, reboot the FreeNAS machine.

Add New Disk - step 3

Once the machine is up and running again, login into web interface and check the ONLINE status of the disk in Disks->Management.

4. Go to Disks->Format and (carefully) choose your disk from the drop down list , use “UFS (GPT and Soft Updates)” as File system and type in a Volume label. Click Format disk (this will erase all data on that disk) . Confirm it.

Add New Disk - Step 4

5. Go to Disks->Mount Point and click on the “plus” sign to mount the newly added disk.

Add New Disk - Step 5

6. In this window choose Type=”Disk”, Disk=”Your disk “, Partition Type=”GPT Partition”, Partition number=”1″, File System “UFS” and Mount point name=”Some name” (I chose MyiSCSI). You can add a description if you like. For simplicity leave everything else at default (not recommended in production). When done, click Add.

Add New Disk - Step 6

7. Click Apply changes in next screen. This will do two things: change the Status of the disk from “Initializing” to “OK” and mount it in the /mnt/MyiSCSI directory (or whatever you named your Mount Point at step 6):

Add new disk - Step 7

Optional, you can now go into FreeNAS console and create subdirectories in /mnt/MyiSCSI/ directory - should you need a more structured layout for future targets.

C. iSCSI Target Preinitialization.

Before adding a new iSCSI target there are few steps to initialize iSCSI service and other parameters.

1. Go to Services->iSCSI Target and enable the iSCSI target. For simplicity, leave all parameters at default value. Click Save and Restart. You can verify if the iSCSI service started properly in Services->Status. Both columns should be checked.

Enable iSCSI service - Step 1

2. In Services->iSCSI Target click on Portals tab. Click on the “plus” sign.

Enable iSCSI service - Step 2

3. In here, change the IP address from 0.0.0.0:3260 to the IP address of your machine (the one that the iSCSI initiators will look for). Port number should stay the same (3260) Then click Add.

Enable iSCSI Service - Step 3

Click Apply changes button to commit changes (screenshot not available)

4. In Services -> iSCSI Target go to Initiators Tab and click the “plus” sign.

Enable iSCSI service - Step 4

5. You can leave everything at default values. If you want to implement some security (advisable) add the IP Addreses for your initiators ( format is 192.168.1.1) and/or the network where they belong (format 192.168.1.0/24). Click Add button.

Enable iSCSI service - Step 5

Click Apply changes button to commit changes (screenshot not available)

D. Adding an iSCSI Target

1. In Services iSCSI Target click on Targets Tab. Click on the “plus” sign in Extent section.

Add a Target - Step 1

2. In the Add extent window leave Extent name at default and select Type as “File”. Path is where it gets tricky. Using the browse button, you can browse to /mnt/MyiSCSI directory (or whatever your mountpoint name is) and to its subdirectories (if created at step B7) but YOU HAVE TO MANUALLY TYPE the file name for the extent. I named mine “Target1″. Choose a file size that can go up to the disk’s capacity (I chose 40 GB on a 80 GB disk). If it is smaller you can use the difference for additional iSCSI targets on the same disk. When done click Add.

Add Target - Step 2

Click Apply changes button to commit changes. You should see the extent listed there (see next screenshot).

3. In Services iSCSI Target click on Targets Tab. Click on the “plus” sign in Target section.

Add Target - Step 3

4. Leave the target name as default, Type as “Disk”. Flags should be changed by preference but I would stick to either read-only or read-write. Storage should have the extent you created at step 2 (verify the path). Everything else can be left as default. Click Add button when done (not shown).

Add Target - Step 4

5. Click Apply changes button to commit changes (screenshot not available). This is normally the step when you get errors if something went wrong. Otherwise you should see something similar to this:

Add Target - Final

Verify that iSCSI service is still running (in Services->Status or Diagnostics -> Log menus). Also, you can use Windows iSCSI Initiator to quickly prove that is functional.

If you get errors check the error message (obviously) and also check the System Log in Diagnostics ->Log menu.

6. (optional) For more targets on same physical disk repeat steps D1 to D5. Make sure you don’t overlap with disk space allocation.

No comments:

Post a Comment