Sunday, October 16, 2011

Configuring Fedora as an iSCSI target for VMware ESXi

My Experience:


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)


Procedure:

 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.

pvcreate /dev/sdb1  

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:

nano /etc/tgt/targets.conf

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:

<target iqn.2011-10.local.iscsi:target00>
backing-store /dev/vg_target00/lv_target00
initiator-address 192.168.1.1
</target>

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

/etc/rc.d/init.d/tgtd start
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.


Thursday, October 6, 2011

SSH on CISCO Router

Here are the steps required to install SSH on a Cisco Router:
First you need to determine if you have the required IOS - IOS images with "K9" in the name will do. Not all routers support SSH. I am using the 2600 series.
Second log into your router and give it a host name with:

hostname R1

You will also need to configure a domain name:

ip domain name your-domain.com

Then use ip ssh to change the version to 2 if possible. You will not always be able to rely on ssh v2, but even version 1 will provide substantially better protection then telnet:

ip ssh version 2

Once you have that done go ahead and enter:

crypto key generate rsa

Then you have the option to choose how many bits the keys will be anywhere between 360 and 2048, I choose 1024 since it is very secure and the router can create the key quickly. The default is 512.
Then the final step. Create a user for ssh login and secure the vty lines:

user username privilege level 15 password yoursupersecrepassword

R1(config)#line vty 0 ?
  <1-181>  Last Line number
  <cr>

R1(config)#line vty 0 181
R1(config-line)#login local
R1(config-line)#trans
R1(config-line)#transport input ssh
R1(config-line)#exit
R1(config)#exit


That is pretty much it! You can now login through putty or other ssh clients.