Cisco Unified IP Phone 7912G – SIP to SCCP

As stated in my last post, I received my CCNP Lab Kit in the post last week.

In my excitement, I decided to switch my IP Phones from the SCCP firmware (which was the software originally on the phones) to the SIP firmware so that I could connect to VoIPTalk.

Now that the excitement has died down a little, I wanted to switch back to SCCP as, from what I can tell, it provides more features than SIP.

As I’m not too familiar with Cisco IP Phones, I started Googling for instructions on how to switch back, but I couldn’t really find any instructions on how to do so.

In the end I tried the same way I had originally upgraded to the SIP firmware. I edited my gkdefault.txt which originally contained the following line:

upgradecode:3,0x601,0x0400,0x0100,0.0.0.0,69,0x060111a,CP7912080000SIP060111A.sbin

And replaced it with:

upgradecode:3,0x601,0x0400,0x0100,0.0.0.0,69,0x070409a,CP7912080003SCCP070409A.sbin

You can read what the values mean on the Cisco site, but all I had to change was two last values of the line:

0×060111a -> 0×070409a

CP7912080000SIP060111A.sbin -> CP7912080003SCCP070409A.sbin

The first value I had to change was the build ID/date, which is (from what I can tell) the last few characters in the file name after the “SIP” or “SCCP” bit.

The second value is pretty self explanatory, its just the file name of the firmware file you have.

Next, I used cfgfmt to convert the file into a .cfg file compatible with the phones, and put it on my TFTP server.

I then restarted the phones, and behold! They were downloading the SCCP firmware image. :)

I’m not sure if this is the “correct” way to switch back to the SCCP firmware, but it worked for me and I don’t see why it wouldn’t be correct, it seems pretty obvious. The only reason I am a little confused is the fact that while searching for instructions to switch back, I found a lot of people having difficulties switching back and even some companies offering a “recovery” service for people in this situation.

Hopefully my post will help other people who are in this situation.

Now I just need to figure out how to get the CTU ringtone onto the phone. :D

Cisco CCNP Lab Kit

Cisco CCNA Lab Kit

As I have pretty much completed my studies for CCNA, I decided I would build up my lab so I could “practice” for CCNP. A lot of people recommend using a simulator/emulator such as dynamips, but I don’t think that works out to be just as good as using real hardware but that’s a different matter. :)

I had originally bought my CCNA Lab Kit from the nice people at ITelligentsia so I decided I would buy the rest of my equipment from them as well.

My current lab consists of the following:

  • Cisco 1800 Series : 1x Cisco 1841 (I bought this separately from someone else)
  • Cisco 2600 Series: 1x Cisco 2610, 2x Cisco 2511XM, 1x Cisck 2621XM
  • Cisco 2500 Series: 2x Cisco 2501, 1x Cisck 2509
  • Cisco 1700 Series: 1x Cisco 1721 (I bought this separately from someone else)
  • Cisco Catalyst 3550 Series: 2x WS-C3550-24 SMI
  • Cisco Catalyst 2950 Series: 3x WS-C2950-12
  • Catalyst 2900 Series XL: 2x Cisco 2924XL
  • Cisco 2000 Series Wireless LAN Controller: AIR-WLC2006-K9
  • Cisco Aironet 1200 Series: Cisco Aironet 1231 (AIR-LAP1231G-E-K9)
  • 3x Cisco Unified IP Phone 7912G

Hopefully this should be enough to allow me to get going, although I REALLY need a new rack. My 24U rack is already full, so my UPS (4U), Server (4U) and new lab equipment are sitting on the floor, and being very difficult to get access to.

Hopefully I will be able to get two (better be prepared for CCIE Equipment too!) from work in March as we will be moving offices, and from what I can tell, they will be getting new server racks. :)

I also bought a UPS a few weeks ago, but I’ve been having some trouble with it. The UPS is a PowerWare 5119 RM 3000VA UPS. I have connected a few of my routers to it, and left it charging for over 24 hours, but when I kill the power the UPS goes into a strange state in which it seems to keep switching on and off and lighting up random lights on the front. From Googling a bit, I found that I might need to change some settings using the management serial port. Unfortunately, the UPS does not use a “standard” serial pin out, so I will have to build a cable when I have a chance to. Hopefully I will be able to sort the issue, otherwise I will have to send it back to the place I bought it from for repair. :(

Nginx, Varnish, HAProxy, and Thin/Lighttpd

Over the last few days, I’ve been playing with Ruby on Rails again and came across Thin, a small, yet stable web server which will serve applications written in Ruby.

This is a small tutorial on how to get Nginx, Varnish, HAProxy working together with Thin (for dynamic pages) and Lighttpd (for static pages).

I decided to take this route as from reading in many places I found that separating static and dynamic content improves performance significantly.

Nginx

Nginx is a lightweight, high performance web server and reverse proxy. It can also be used as an email proxy, although this is not an area I have explored. I will be using Nginx as the front-end server for serving my rails applications.

I installed Nginx using the RHEL binary package available from EPEL.

Configuration of Nginx is very simple. I have kept it very simple, and made Nginx My current configuration file consists of the following:

user nginx;
worker_processes 1;

error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    log_format main '$remote_addr - $remote_user [$time_local] $request "$status" $body_bytes_sent "$http_referer" "$http_user_agent" "$http_x_forwarded_for"';

    sendfile on;
    tcp_nopush on;
    tcp_nodelay off;

    keepalive_timeout 5;

    # This section enables gzip compression.
    gzip on;
    gzip_comp_level 2;
    gzip_proxied any;
    gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    # Here you can define the addresses on which varnish will listen. You can place multiple servers here, and nginx will load balance between them.
    upstream cache_servers {
      server localhost:6081 max_fails=3 fail_timeout=30s;
    }

    # This is the default virtual host.
    server {
        listen 80 default;
        access_log /var/log/nginx/access.log main;
        error_log /var/log/nginx/error.log;
        charset utf-8;

        # This is optional. It serves up a 1x1 blank gif image from RAM.
        location = /1x1.gif {
          empty_gif;
        }

        # This is the actual part which will proxy all connections to varnish.
        location / {
          proxy_pass http://cache_servers/;
          proxy_redirect http://cache_servers/ http://$host:$server_port/;

          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
    }
}

Varnish

Varnish is a high performance caching server. We can use Varnish to cache content which will not be changed often.

I installed Varnish using the RHEL binary package available from EPEL as well. Initially, I only needed to edit /etc/sysconfig/varnish, and configure the address on which varnish will listen on.

DAEMON_OPTS="-a localhost:6081 \
             -T localhost:6082 \
             -f /etc/varnish/default.vcl \
             -u varnish -g varnish \
             -s file,/var/lib/varnish/varnish_storage.bin,10G"

This will make varnish listen on port 6081 for normal HTTP traffic, and port 8082 for administration.

Next, you must edit /etc/varnish/default.vcl to actually cache data. My current configuration is as follows:

backend thin {
  .host = "127.0.0.1";
  .port = "8080";
}

backend lighttpd {
  .host = "127.0.0.1";
  .port = "8081";
}

sub vcl_recv {
    if (req.url ~ "^/static/") {
        set req.backend = lighttpd;
    } else {
        set req.backend = thin;
    }

    # Allow purging of cache using shift + reload
    if (req.http.Cache-Control ~ "no-cache") {
        purge_url(req.url);
    }

    # Unset any cookies and autorization data for static links and icons, and fetch from catch
    if (req.request == "GET" && req.url ~ "^/static/" || req.request == "GET" && req.url ~ "^/icons/") {
        unset req.http.cookie;
        unset req.http.Authorization;
        lookup;
    }

    # Look for images in the cache
    if (req.url ~ "\.(png|gif|jpg|ico|jpeg|swf|css|js)$") {
        unset req.http.cookie;
        lookup;
    }

    # Do not cache any POST'ed data
    if (req.request == "POST") {
        pass;
    }

    # Do not cache any non-standard requests
    if (req.request != "GET" && req.request != "HEAD" &&
        req.request != "PUT" && req.request != "POST" &&
        req.request != "TRACE" && req.request != "OPTIONS" &&
        req.request != "DELETE") {
        pass;
    }

    # Do not cache data which has an autorization header
    if (req.http.Authorization) {
        pass;
    }

    lookup;
}

sub vcl_fetch {
    # Remove cookies and cache static content for 12 hours
    if (req.request == "GET" && req.url ~ "^/static/" || req.request == "GET" && req.url ~ "^/icons/") {
        unset obj.http.Set-Cookie;
        set obj.ttl = 12h;
        deliver;
    }

    # Remove cookies and cache images for 12 hours
    if (req.url ~ "\.(png|gif|jpg|ico|jpeg|swf|css|js)$") {
        unset obj.http.set-cookie;
        set obj.ttl = 12h;
        deliver;
    }

    # Do not cache anything that does not return a value in the 200's
    if (obj.status >= 300) {
        pass;
    }

    # Do not cache content which varnish has marked uncachable
    if (!obj.cacheable) {
        pass;
    }

    # Do not cache content which has a cookie set
    if (obj.http.Set-Cookie) {
        pass;
    }

    # Do not cache content with cache control headers set
    if(obj.http.Pragma ~ "no-cache" || obj.http.Cache-Control ~ "no-cache" || obj.http.Cache-Control ~ "private") {
        pass;
    }

    if (obj.http.Cache-Control ~ "max-age") {
        unset obj.http.Set-Cookie;
        deliver;
    }

    pass;
}

HAProxy

HAProxy is a high performance TCP/HTTP load balancer. It can be used to load balance almost any type of TCP connection, although I have only used it with HTTP connections.

We will be using HAProxy to balance connections over multiple thin instances.

HAProxy is also available in EPEL. My HAProxy configuration is as follows:

global
  daemon
  log 127.0.0.1 local0
  maxconn 4096
  nbproc 1
  chroot /var/lib/haproxy
  user haproxy
  group haproxy

defaults
  mode http
  clitimeout 60000
  srvtimeout 30000
  timeout connect 4000

  option httpclose
  option abortonclose
  option httpchk
  option forwardfor

  balance roundrobin

  stats enable
  stats refresh 5s
  stats auth admin:123abc789xyz

listen thin 127.0.0.1:8080
  server thin 10.10.10.2:2010 weight 1 minconn 3 maxconn 6 check inter 20000
  server thin 10.10.10.2:2011 weight 1 minconn 3 maxconn 6 check inter 20000
  server thin 10.10.10.2:2012 weight 1 minconn 3 maxconn 6 check inter 20000
  server thin 10.10.10.2:2013 weight 1 minconn 3 maxconn 6 check inter 20000
  server thin 10.10.10.2:2014 weight 1 minconn 3 maxconn 6 check inter 20000
  server thin 10.10.10.2:2015 weight 1 minconn 3 maxconn 6 check inter 20000
  server thin 10.10.10.2:2016 weight 1 minconn 3 maxconn 6 check inter 20000
  server thin 10.10.10.2:2017 weight 1 minconn 3 maxconn 6 check inter 20000
  server thin 10.10.10.2:2018 weight 1 minconn 3 maxconn 6 check inter 20000
  server thin 10.10.10.2:2019 weight 1 minconn 3 maxconn 6 check inter 20000

Thin

My Thin server is actually run on a separate Gentoo box. I installed Thin using the package in Portage.

To configure Thin, I used the following command:

thin config -C /etc/thin/config-name.yml -c /srv/myapp --servers 10 -e production -p 2010

This configures thin to start 10 servers, listening on port 2010 to 2019. If you want an init script for Thin, so you can start it at boot, run

thin init

This is will create the init script, and you can set it to start up at boot using the normal method (rc-update add thin default or chkconfig thin on).

You should now be able to access your rails app through http://nginx.servers.ip.address

Next, we must configure the static webserver.

Lighttpd

I decided to go with Lighttpd as it is a fast, stable and lightweight webserver which will do the job perfectly with little configuration.

You could also use nginx as the static server instead of using lighttpd, but I decided to separate it.

I decided to use the package from EPEL for Lighttpd, and found that most of the default configuration was as I wanted it to be. The only thing I needed to change was the port and address the server was listening on:

server.port = 8081
server.bind = "127.0.0.1"

And thats pretty much it! Now you just have to dump any static content into /var/www/lighttpd/ (the default location that the Lighttpd package in EPEL is configured to use) and reference any static links using “/static/document_path_of_file”, for example if I put an image into /var/www/lighttpd/images/ called “bg.png”, I can access it using http://servers_hostname/static/images/bg.png.

I have not really done any performance tests onto how well this works, and there are probably many things which I could have done better. This is the first time I made any attempt HTTP performance tuning, and so I am always looking for feedback or tips on how to make this better, so please do contact me if you have any suggestions! :)

Server Upgrade / Disk Failure

Last month I had a disk failure which caused most of my data to become inaccessible which is the main reason for my blog being down for so long.
I have three 1TB hard drives in a LVM VG…. without any RAID. This means if one drive fails, it is very unlikely I will be able to recover any data. It was very stupid of me, and I regret it VERY much. :(
The drives I was using in the LVM VG were Seagate Barracuda 7200.11 1TB (ST31000333AS) drives.
I originally bought these drives January 2009, but since then I’ve had multiple issues with the drives and so I don’t actually have the drives I originally bought, I sent them back for replacement as they all showed sign of failure sooner or later. Luckily, I was able to catch those failures pretty early, thanks to “SMARTmon Tools”. This time I was unable to do so, as I upgraded my SATA controller to a Adaptec 2820SA which does not allow SMART commands to be passed through to the drive.
After a bit of Googling, I discovered that there have been quite a few reports of these drives failing, unfortunately in January these reports were not available.
This frustrated me quite a bit, as not only did I lose 500GB worth of important data, I will now have to scrap these drives and buy new drives if eBuyer or Seagate is unwilling to give me a different model of 1TB drives – I don’t think it should be an issue for them to give me the Barracuda 7200.12 which seem to have much better reports, but I don’t think they will agree to this.
At the moment, I’ve sent the drives to Seagate’s i365 Data Recovery service, and they are building a list of files which they will be able to recover.
During the time the drives failed, I decided it would be a good idea to upgrade my server too. My new servers specs are as follows:
Intel Quad-Core Xeon E5405 2 GHz
2×4 GB DDR2 PC2-5300 RAM
Tyan Tempest i5100X (S5375)
Norco RPC-4220 case
The Norco RPC-4220 case is a 4U rack-mountable server case and has 20 hot-swappable hard drive bays, which allows quite a of room for storage expansion. When I first powered on the machine, I noticed that the fans which cool the hard drives are amazily loud and so switch them for quiter ones (relax! they are quck provide enough air flow to cool six drives!). The case comes with five SAS/SATA backplanes, which have a Mini-SAS connector. As I don’t have a SAS controller, I had to buy Mini-SAS reverse breakout cables which allowed me to connect the backplanes to my standard SATA cards. This was quite a pain, as I had no idea that there are two types of Mini-SAS to SATA cables, one for Mini-SAS on Backplane side to SATA on the controller, like I needed, and SATA on the backplane, to Mini-SAS on the controller. It was a pain that I discovered this after I had already bought the wrong cables.
The Tempest i5100X supports two Quad Core XEON processors, although I only bought one for the time being. The board also takes upto 32GB worth of RAM which also allows alot of room for expansion.
Thanks to this upgrade, I was finally able to play with XEN’s full-virtulization (HVM) functionality as the E5405 has the Intel VT-x extension.
When I get my drives back from i365, I will be sure to use RAID5 on the drives AND make regular backups….. although I haven’t really found a feasible solution (price wise, and time to actually do it) for backing up 500GB worth of data, so if anyone has any suggestions, please let me know!
I have looked at Bacula, and I really like it, but I still need media onto which I can backup the data.
I have lost my trust in hard drives for keeping my backups, and burning to DVDs or Bluray would not be very feasible as I would require 63 dual layer DVDs or 10 dual-layer bluray discs to backup 500GB worth of data, and both are not very reliable either (they are easily scratched!).
I also looked at online backup services, but this too I think is not a feasible idea as backing up 500GB over a connection with only 1.3mbit upload would take way too long.

Last month I had a disk failure which caused most of my data to become inaccessible which is the main reason for my blog being down for so long.

I have three 1TB hard drives in a LVM VG…. without any RAID. This means if one drive fails, it is very unlikely I will be able to recover any data. It was very stupid of me, and I regret it VERY much. :(

The drives I was using in the LVM VG were Seagate Barracuda 7200.11 1TB (ST31000333AS) drives.

I originally bought these drives January 2009, but since then I’ve had multiple issues with the drives and so I don’t actually have the drives I originally bought, I sent them back for replacement as they all showed sign of failure sooner or later. Luckily, I was able to catch those failures pretty early, thanks to “SMARTmon Tools”. This time I was unable to do so, as I upgraded my SATA controller to a Adaptec 2820SA which does not allow SMART commands to be passed through to the drive.

After a bit of Googling, I discovered that there have been quite a few reports of these drives failing, unfortunately in January these reports were not available.

This frustrated me quite a bit, as not only did I lose 500GB worth of important data, I will now have to scrap these drives and buy new drives if eBuyer or Seagate is unwilling to give me a different model of 1TB drives – I don’t think it should be an issue for them to give me the Barracuda 7200.12 which seem to have much better reports, but I don’t think they will agree to this.

At the moment, I’ve sent the drives to Seagate’s i365 Data Recovery service, and they are building a list of files which they will be able to recover.

During the time the drives failed, I decided it would be a good idea to upgrade my server too. My new servers specs are as follows:

The Norco RPC-4220 case is a 4U rack-mountable server case and has 20 hot-swappable hard drive bays, which allows quite a of room for storage expansion. When I first powered on the machine, I noticed that the fans which cool the hard drives are amazily loud and so switch them for quieter ones (relax! they are quck provide enough air flow to cool six drives!). The case comes with five SAS/SATA backplanes, which have a Mini-SAS connector. As I don’t have a SAS controller, I had to buy Mini-SAS reverse breakout cables which allowed me to connect the backplanes to my standard SATA cards. This was quite a pain, as I had no idea that there are two types of Mini-SAS to SATA cables, one for Mini-SAS on Backplane side to SATA on the controller, like I needed, and SATA on the backplane, to Mini-SAS on the controller. It was a pain that I discovered this after I had already bought the wrong cables.

The Tempest i5100X supports two Quad Core XEON processors, although I only bought one for the time being. The board also takes upto 32GB worth of RAM which also allows alot of room for expansion.

Thanks to this upgrade, I was finally able to play with XEN’s full-virtulization (HVM) functionality as the E5405 has the Intel VT-x extension.

When I get my drives back from i365, I will be sure to use RAID5 on the drives AND make regular backups….. although I haven’t really found a feasible solution (price wise, and time to actually do it) for backing up 500GB worth of data, so if anyone has any suggestions, please let me know!

I have looked at Bacula, and I really like it, but I still need media onto which I can backup the data.

I have lost my trust in hard drives for keeping my backups, and burning to DVDs or Bluray would not be very feasible as I would require 63 dual layer DVDs or 10 dual-layer bluray discs to backup 500GB worth of data, and both are not very reliable either (they are easily scratched!).

I also looked at online backup services, but this too I think is not a feasible idea as backing up 500GB over a connection with only 1.3mbit upload would take way too long.

The Official Myers-Briggs Personality Test

Shhh! I was bored! – It describes me pretty well though imo :)


Your result for The Official Myers-Briggs Personality Test…

ISTP

1% Extraversion, 20% Introversion, 14% Sensing, 12% Intuition, 23% Thinking, 1% Feeling, 8% Judging and 14% Perceiving!

Introverted Intuition with Extraverted Thinking

Approximately 5.4% of persons in the United States are ISTPs.

Summary:

Tolerant and flexible, quiet observers until a problem appears, then act quickly to find workable solutions. Analyze what makes things work and readily get through large amounts of data to isolate the core of practical problems. Interested in cause and effect, organize facts using logical principles, value efficiency.

At Their Best

People with ISTP preferences carefully observe what is going on around them. Then, when the need arises, they move quickly to get to the core of a problem and solve it with the greatest efficiency and the least effort. They are interested in how and why things work but find abstract theories uninteresting unless they can quickly apply them. They often function as troubleshooters.

ISTPs resist regimentation and rules, thrive on variety and novelty, and enjoy the challenge of solving a new, concrete, extensive problem.

Characteristics of ISTPs

ISTPs use their Thinking primarily internally to see the essential structure underlying the facts. Their minds seem to work almost like computers, organizing data, reasoning impersonally and objectively. They make rational decisions based on a great deal of concrete data. ISTPs are likely to be

· Detached and objective critics

· Analytical and logical problem solvers

ISTPs are realists, focusing on what is and what can be done with it, rather than on theoretical possibilities. They are often creative at dealing with the immediate problems and good at hands-on tasks. ISTPs are likely to be

· Practical and realistic

· Factual and pragmatic

ISTPs are expedient and believe in economy of effort doing only what is needed with the least possible discussion and fuss. Their focus is on getting the desired results.

How Others May See Them

ISTPs are egalitarian and generally tolerant of a wide range of behavioruntil their ruling logical principles are attacked. At that point, they can surprise others by expressing their firm and clear judgments. ISTPs listen and seem to agree because they are not disagreeing; later, others may find the ISTP was analyzing and making internal judgments.

With their constant scanning for information and focus on results, ISTPs will change course readily if they see another, more efficient way. Because of this, others some- times have trouble “reading” them. They tend to be quiet and reserved, though they can be quite talkative in areas in which they have a lot of knowledge. Others usually see ISTPs as

· Adaptable, action-oriented risk takers

· Confident, independent, and self-determined

Potential Areas for Growth

Sometimes life circumstances have not supported ISTPs in the development and expression of their Sensing and Thinking preferences.

· If they have not developed their Sensing, ISTPs may have no reliable way of getting accurate data about the external world or of translating their thoughts into action.

· If they have not developed their Thinking, they may get caught up in the realities around them. and not take time to do the internal logical processing they need to make good decisions. Then their actions may be haphazard responses to immediate needs

If ISTPs do not find a place where they can use their gifts and be appreciated for their contributions, they usually feel frustrated and may

· Become cynical and negative critics

· Withdraw their attention and energy

· Postpone decisions

It is natural for ISTPs to give less attention to their non- preferred Feeling and Intuitive parts. If they neglect these too much, however, they may

· Overlook others’ emotional needs and values

· Not give sufficient weight to the impacts of their decisions on others

· Focus so intently on immediate results that they lose track of the long-term ramifications of their decisions and actions

Under great stress, ISTPs may erupt outwardly in inappropriate displays of emotion. The resulting explosive anger or hurt tearfulness is quite unnerving to others and embarrassing to the usually calm and controlled ISTP.


Take The Official Myers-Briggs Personality Test
at HelloQuizzy

PSP Video Encoding

I often use my PSP to watch Anime and Movies on the way to work, or any long trip on the train/bus.

I found Tristan’s Blog post which gives the settings required to make mencoder convert video to the perfect version for watching on the PSP.

To make mencoder hardcode subtitles into the video at the same time as it encodes for the PSP, just append -slang eng -alang jap to the command. This tell mencoder to use the english subtitles, and japaneese audio (Not required if the file only has one audio track).

PowerVault 120T DLT-7000 Autoloader

For the last month or so, I’ve been using Bacula to backup the important data on my machine/servers and my dads computer. Although it works great with my PowerVault 100T DDS4 drive, I got fed up of having to constantly change tapes every they got filled up.

To solve this problem I decided to buy a Dell PowerVault 120T DLT-7000 Autoloader from eBay.

I receieved the PV a few days ago, but I was unable to test it as I did not have the neccicary terminator or cable required to connect it to my server.

After looking on eBay, I found both items from a single seller (the same seller I bought the autoloader infact!), and I received both items in the post today.

I hooked everything up very excitedly, and found that the DLT-7000 drive in the PV-120T was faulty! :( The LCD displays “Drive POST Error”. I’ve emailed the seller of the autoloader, and I really hope he will be able to repair or send me a new one of these devices.

RHEL5 iSCSI Target/Initiator

iSCSI is a protocol that allows you to use a disk in a remote machine, locally as a block device. It is a very popular SAN protocol, which allows the consolidation of storage into one large storage pool.

In iSCSI terminology, a target is a storage resource located on an iSCSI server and an initiator is a client which will be connecting to a target.

In this post I will demonstrate how to setup an iSCSI target and initiator on RedHat Enterprise Linux 5.

Target

RHEL5 has the stgt target daemon included with it. This is the server which allows initiators (clients) to connect to the disks using the iSCSI protocol. It is installable using yum:

yum install scsi-target-utils

To share a disk over iSCSI, you can either use a disk image, or a block device. I prefer to use LVM logical volumes as LVM allows easy management of free space.

Stgt’s configuration file lives in /etc/tgt/targets.conf, although most configuration can be done using the command line (although this is not persistant across reboots, so I prefer to use the configuration file).

To create a target, just add the following lines:

backing-store /dev/DiskArray/Archive1

Please note that you must replace iqn.2009-02.com.hamzahkhan:archive1 with your own domain name, and resource name. It must be in the iSCSI Qualified Name (IQN) format, iqn.yyyy-mm.{reversed domain name}:an_easy_to_remember_lablel.

The second line, backing-store /dev/DiskArray/Archive1 specifies the disk/disk image that is to become the target, I am using LVM logical volume although the procedure is exactly the same for disk images, and real physical disks.

By default, stgt will allow all IPs to connect to the target, which is highly insecure! To change this behaviour, it is possible to specify IP addresses which are allowed to use the targets. To do this, just place the following line under backing-store:

initiator-address 10.1.0.4

This will allow 10.1.0.4 to access the target.

Now, use chkconfig to make stgt start at boot, and start up the daemon.

/etc/init.d/tgtd start

chkconfig tgtd on

Thats all there is to it on the server side! All done :)

You can now connect to the target using any initiator, such as the one built into Windows Vista (although I have never tried using Windows).

Initiator

RedHat have included an iSCSI daemon which is also installable using yum:

yum install iscsi-initiator-utils

To connect to the target, edit /etc/iscsi/initiatorname.iscsi and change InitiatorName to something you prefer (Remember! it must be in the IQN format, iqn.yyyy-mm.{reversed domain name}:an_easy_to_remember_lablel. I usually use iqn.2009-02.com.hamzahkhan:hostname_of_box). Next start up iSCSId:

/etc/init.d/iscsid start

and use iSCSI target descovery to find the targets on the server:

iscsiadm -m discovery -t st -p $SERVERS_IP

If all is well, it should output the names of all the targets that the initiator is allowed to connect to!

Next, we need to create the disk nodes. To do this, RedHat have provided a nice start up script. This script will login to all the targets that the iSCSI daemon knows about. We have already used the iscsiadm command to tell the iSCSI daemon which targets exist on the server, so using the script is all that is left:

/etc/init.d/iscsi start

Thats all there is to it! :)

You should have a new disk node in /dev/. You can use lsscsi (yum install lsscsi) to find the exact name if you have a lot of USB/SATA/SCSI drives connected to the machine already.

Now all you have to do is partition the disk, and dump your files onto it :)

Please remember, you must NEVER mount a partition on two machines at the same time. Doing so will cause data loss!

It IS possible to mount the same disk on multiple machines, but this requires a special clustered filesystem such as GFS.

OpenSWAN

Lately I’ve been playing with OpenSWAN and IPSec in general.

For the last few years I’ve been using OpenVPN as my home VPN server, but recently I bought a few Intel PRO/100 S Server Ethernet adaptors. From looking on the Intel site the only big difference I could see between these and regular Intel PRO/100 cards was that it has IPSec offloading, which I also remembered seeing IPSec support on my iPhone. So that got me looking into replacing OpenVPN with OpenSWAN on my home router.

In the past, I have come across IPSec quite often, but I never really looked into it. After a bit of reading, I decided to buy “Building And Integrating Virtual Private Networks With OpenSWAN“. I haven’t finished reading the book, but I can say that it is a very well written book for people looking to get started with IPSec. It has quite a nice introduction on the internet and why encryption is so important on the internet. It also explains how encryption was originally only used by the military and how governments around the world tried to stop encryption being used widely across the internet.

On Linux, there are two IPSec stacks, NETKEY and KLIPS. KLIPS is currently the more stable one, and from what I understand, the one which is easier to use. NETKEY on the other hand, is quite a new stack, but due to various reasons, KLIPS was not allowed to be included in the Linux kernel by default, where as NETKEY is.

Since my router machine is running RedHat Enterprise Linux 5, which only includes support for NETKEY, I have been using the NETKEY IPSec stack. So far, the only problem with the NETKEY stack is that creating firewall rules for encrypted packets is much more difficult than it would be using KLIPS, although I was not too disapointed by this since the KLIPS does not have IPv6 support, which, since I like IPv6 so much, is a must for me! :)

Although I had a bit of a problem with the OVH kernel, after a bit of tweaking and compiling and a lot of rebooting, I was able to create an encryted tunnel between my OVH RPS and my home router. If it had not been for all the trouble I had with the OVH kernel (it took quite a while to get the RPS to boot from the iSCSI disk using my custom kernel, rather than use netboot to fetch an OVH kernel), the tunnel would have been set up within a few minutes, which I found amazing as it takes a bit more time and effort to do with OpenVPN.

So far, I haven’t managed to figure out how to use the IPSec offloading feature of my ethernet cards, but I don’t think thats is really a problem considering my router machine is powerful enough to handle the few IPSec connections that I  have setup (Its a 2.4GHz Pentium 4 machine with 1GB ECC Reg RAM).

After a bit more reading, I decided it would be fun to try and get my iPhone connected to my IPSec Server, so over the next few days, hopefully thats what I will be doing! :)

Western Digital 1TB Hard Drive

A few months ago, I bought a Western Digital 1TB Hard Drive (http://www.wdc.com/en/products/products.asp?DriveID=336) for my server.

Since every WD drive I have bought in the past has served me very well, I assumed this drive would do the same…. but VERY annoyingly, I just got an email from smartmon tools telling me that there are an increasing number of bad sectors on the drive! :(

eBuyer has agreed to replace the drive since it is still under warrenty, but the problem is that I have the drive in an LVM volume group, so backing up the data is a little difficult.

It would be easy if I had another 1TB Hard Drive to add to the volume group, the pvmove all the data off the broken one, but I do not have a spare 1TB drive, and eBuyer (naturally), didn’t agree to sending me the new drive before I give the old drive back to them.

I also have 1TB Seagate drive in the volume group, which is performing very well, so very reluctantly, I might just ask eBuyer if they would let me switch it for a Seagate one.

Oh well, I guess for now, my only option would be to buy another 1TB drive, move all the data onto that drive, remove the old drive from the VG, get it replaced, then if I feel brave enough, add the new one to the VG. I’ll have quite a large volume group if I do that (3TB!).

Speaking of which, if anyone has any tips for boosting LVM performance when using large volume groups, please tell me! :)