yahoo2mbox.pl error: Unexpected title page format

The problem

c:\emails\yahoo2mbox-0.24>perl yahoo2mbox.pl --user=pooja13pandey --pass=<password>
1 --delay=5 desimasala
Logging in as pooja13pandey... ok.
Getting number of messages in group desimasala...
Unexpected title page format (DesiMasala).

The solution

This simply means that the user with which we are trying to archive the yahoo group’s messages locally, is not part of the yahoo group yet. So now I make pooja13pandey user a part of the desimasala yahoo group.

c:\emails\yahoo2mbox-0.24>perl yahoo2mbox.pl --user=pooja13pandey --pass=<password>
1 --delay=5 desimasala
Logging in as pooja13pandey... ok.
Getting number of messages in group desimasala...
Retrieving messages 1..12389:
Endless redirect loop detected while retrieving message 1.
This error is often due to using incorrect case in the group name.
Saved 0 message(s) in desimasala.

Hmm, so there is still some problem. Although, there is a yahoo group called Desimasala, Im not able to login to it through yahoo2mbox.pl script for some reason. On closer look, one can see that the group name is case-sensitive. It needs to be DesiMasala, instead of Desimasala or desiMasala or desimasala.

So, lets make that correction and try again.

c:\emails\yahoo2mbox-0.24>perl yahoo2mbox.pl --user=pooja13pandey --pass=<password>
1 --delay=5 DesiMasala
Will resume at message 1
Logging in as pooja13pandey... ok.
Getting number of messages in group DesiMasala...
Retrieving messages 1..12389:

.. And, Bingo! It worked.


quick script to extract email ids from a detailed mail header

Since my creative juices are flowing so much today, I thought of posting the simple, yet effective awk script to extract sender’s email ids from a detailed mail message (even though if the mail id be ecrypted).

A word of caution is that the file being processed should have a line with “EOF” value (without strings) ONLY at the end of file, otherwise the awk script will hang.

BEGIN { print FILENAME | "wc -l |cut -f1 -d' '" ; }
/^X-Sender:/ || /^From / { #print NR, $0;
           #
           # get the real userid from where the email came
           #
           m=split($0,b,"@");
           from=b[1];
           #print from;
           x=split(from,c," ");
           realfrom=c[x];
           gsub("<","",realfrom);
           #print realfrom;
           #
           # get the domain name of the smtp server now
           #
           while ($0 !~ /HELO/ && $0 != "EOF") getline;
           if ($0 == "EOF") exit;
           domain=$5; gsub(")","",domain); n=split(domain,a,".")
           #print n, domain;
           realdomain=a[n-1]"."a[n];
           if (n>1) print realfrom"@"realdomain;
           next;
         }

How to uninstall a CPAN module ?

CPAN module does not have the option of un-installing a perl module as of now. This can be especially frustrating for newbies (as it was for me). I struggled quite a bit on google and found this solution. For this, you need the CPANPLUS module, which needs to be first installed through CPAN.

C:\Users\Pooja Verma>perl -MCPAN -e shell

cpan> install CPANPLUS

cpan> exit

Unlike CPAN, you cannot invoke CPANPLUS by typing cpanplus on command prompt, even if its installed.

C:\Users\Pooja Verma>cpanplus
'cpanplus' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\Pooja Verma>perl -MCPANPLUS -e shell
CPANPLUS::Shell::Default -- CPAN exploration and module installation (v0.84)
*** Please report bugs to <bug-cpanplus@rt.cpan.org>.
*** Using CPANPLUS::Backend v0.84.  ReadLine support disabled.

*** Type 'p' now to show start up log

Did you know...
    The documentation in CPANPLUS::Module and CPANPLUS::Backend is very useful
CPAN Terminal> help

[General]
    h | ?                  # display help
    q                      # exit
    v                      # version information
[Search]
    a AUTHOR ...           # search by author(s)
    m MODULE ...           # search by module(s)
    f MODULE ...           # list all releases of a module
    o [ MODULE ... ]       # list installed module(s) that aren't up to date
    w                      # display the result of your last search again
[Operations]
    i MODULE | NUMBER ...  # install module(s), by name or by search number
    i URI | ...            # install module(s), by URI (ie http://foo.com/X.tgz)
    t MODULE | NUMBER ...  # test module(s), by name or by search number
    u MODULE | NUMBER ...  # uninstall module(s), by name or by search number
    d MODULE | NUMBER ...  # download module(s)
    l MODULE | NUMBER ...  # display detailed information about module(s)
    r MODULE | NUMBER ...  # display README files of module(s)
    c MODULE | NUMBER ...  # check for module report(s) from cpan-testers
    z MODULE | NUMBER ...  # extract module(s) and open command prompt in it
[Local Administration]
    b                      # write a bundle file for your configuration
    s program [OPT VALUE]  # set program locations for this session
    s conf    [OPT VALUE]  # set config options for this session
    s mirrors              # show currently selected mirrors

Now you can uninstall the module that you want to. If needed, you can use the –verbose and –force option with it.

CPAN Terminal> u MIME::Head --force --verbose

How to scrape emails for online marketing? — for free

Prologue – Is harmless marketing always Spam?

spam

Ok, so I had started a website and wanted to promote it. At some point, you might be in the same boat too.

Unfortunately, I did not have a while lot of contacts for sending emails to. Well, the website was not really spammy (it was actually a community related website for open source audio resources), and I was not going to solicit for money, so I did not have a lot of compunctions in telling people about it. If they wanted to listen to some audios, they could stick around, otherwise they could do anything else they pleased to.

I knew some owners of yahoo groups that had heavy audience. I thought maybe it was worth a shot explaining about the website and asking if they might be willing to share emails for targeted promotion. The results were quite disappointing, and somewhat expected.

After talking to a few of them, my general observation seemed that most group owners think that as long as they dont give out member emails to others, those emails would always be protected from spam. They tend to think of other groups/email distributions as spam! (as if those people WONT get any other SPAM in the future at all, huh?)

Whatever, I thought. As long as my intentions were pure, I did not need to have second thoughts.

So what are my options?

q-man-thinking-21

Hmph! What a Bummer. How long could I depend on google to make the website more popular? It was basically a deadlock.

So one fine day, I started thinking about how ELSE I could approach this problem. For example, could I not use a unix utility like wget or perl to simulate web clicks or use some robot utility to do clicks, web navigation and download information?

Then another thought was — could I not get emailids from specific yahoo groups or gmail groups that I was subscribed to, and whose target audience might be interested in knowing about a website? After further digging on google, I found that there IS a perl module called WWW::Yahoo::Groups that can programmatically fetch group messages to local PC drive.

WWW::Yahoo::Groups — Easier said than done..

I tried installing WWW::Yahoo::Groups on a unix box I had access to, but it seems that its easier said than done. It had a ton of dependent modules that wouln’t install properly (even with the force option) — I specifically had a lot of trouble with the Crypt::SSLeay module.

So what next?

This failure forced me to look for other options. And boy, there are quite a few of them available. fetchyahoo is one, then you have yahoo2mbox.

Now, An interesting point about yahoo2mbox is that there are a couple places where you can find it. Apparently, TT solutions has their own version at http://www.tt-solutions.com/en/Products/yahoo2mbox, while there is a debian version available at http://packages.debian.org/lenny/yahoo2mbox. I had problems with the debian version on Ubuntu and tried using the one from tt-solutions, which worked better.

So while fetchyahoo can fetch the contents of a single yahoo user, yahoo2mbox can do the same for a yahoogroup.

Fine, I thought, lets go for the jugular and get yahoo2mbox to work. The results were inconsistent: if you are a moderator of the group or if the group has really loose security setting for not masking email ids, only then can you see the email ids in the downloaded messages. Also, you get weird messages/errors if the group home page has photo and text (got some tag related errors with a yahoo group FHRS_USA).

Email masking on Yahoogroups and Google groups..

Anyway, I realized that both yahoogroups and google groups had elaborate email masking on. True, without it, the online world would NOT be a safe place to be in. Email harvesters would retrieve emails left, right and center and make big bucks.

This is an example from yahoo groups content fetched through yahoo2mbox:

From devendra999@8_ZAVFsOGj8FjcpG8_oA372HgMSEAl6ol8NKeUSx7VKOtZW8QZCRKJGqiqzqMU-GwjIpYZBzGXe2JmZrjCeniA.yahoo.invalid Sat Aug 05 14:41:35 2000
Return-Path: <devendra999@8_ZAVFsOGj8FjcpG8_oA372HgMSEAl6ol8NKeUSx7VKOtZW8QZCRKJGqiqzqMU-GwjIpYZBzGXe2JmZrjCeniA.yahoo.invalid>
Received: (qmail 6062 invoked from network); 5 Aug 2000 21:41:35 -0000

This is an example of detailed header fetched using a similar utility called gmail2mbox.pl:

Received: by 10.90.81.11 with SMTP id e11mr6036070agb.27.1237961013457;
        Tue, 24 Mar 2009 23:03:33 -0700 (PDT)
Return-Path: <raviraj.pe...@gmail.com>
Received: from mail-gx0-f164.google.com (mail-gx0-f164.google.com [209.85.217.164])
        by gmr-mx.google.com with ESMTP id 15si1362316gxk.4.2009.03.24.23.03.32;
        Tue, 24 Mar 2009 23:03:32 -0700 (PDT)

Again, what are my options?

So a couple days into the quest and no clear solution yet. Water, water everywhere and not a drop to drink. What an irony.

With these thoughts in mind, I was looking at individual emails (of the yahoo group that I was interested in) in my Yahoo! inbox. Quite absent mindedly, I opened one of the messages a view source and realized that it did not have email masking turned on. In fact, I realized, it could be on, because what would the reply-to address be then? In other words, the From Email id HAD to be available in the mail header of yahoo group email in my inbox.

Aha!

aha_moment

So then, the solution was plain and simple. I would extract the individual email messages for a yahoo group and then extract the email ids from there. Theoritically, it should work. In practice too, it did. Here is an example:

From v_ramesh00001@yahoo.com Thu Feb 10 16:59:16 2005
Return-Path: <v_ramesh00001@yahoo.com>
X-Sender: v_ramesh00001@yahoo.com
X-Apparently-To: sewausa_atl@yahoogroups.com
Received: (qmail 45652 invoked from network); 11 Feb 2005 00:59:15 -0000

So this meant that one would just need to be part of email distribution of a particular yahoo group that one is interested in. It is easier to extract emails if all yahoo group related emails are filtered into a specific folder (then you can utilize –folder option of fetchyahoo).

The quirks of making ‘fetchyahoo’ work..

For using perl, there are a couple options available, but the best option, in my humble opinion, seems to be Active Perl on windows, available at http://www.activestate.com/activeperl/ . The “other” options on windows are Cygwin or Virtualbox to simulate a unix environment in windows.

If you want to use Virtualbox, the easiest option is to install Ubuntu. You can find a lot of Virtualbox How to articles here. Another option is http://wubi-installer.org. Look at http://www.technobuzz.net/how-to-install-ubuntu-in-windows-with-wubi/

While Cygwin mostly works for simple unix stuff, I found that most of the perl package dependencies do not work out and you end up getting frustrated (I found that Crypt::SSLeay module had problems).

Installing ActivePerl and required modules for fetchyahoo

So activeperl .msi is installed, the perl executable is automatically aded to the windows PATH:

c:\emails\fetchyahoo-2.13.3>perl -version

This is perl, v5.10.0 built for MSWin32-x86-multi-thread
(with 5 registered patches, see perl -V for more detail)
..
..

Also, we will assume that the latest version of fetchyahoo is downloaded and extracted to c:\emails\fetchyahoo-2.13.3 folder:

c:\emails\fetchyahoo-2.13.3>dir
 Volume in drive C has no label.
 Volume Serial Number is DA07-A231

 Directory of c:\emails\fetchyahoo-2.13.3

03/27/2009  09:48 PM    <DIR>          .
03/27/2009  09:48 PM    <DIR>          ..
03/09/2009  12:09 PM            15,182 ChangeLog
03/09/2009  12:09 PM            17,992 COPYING
03/09/2009  12:09 PM             2,747 Credits
03/09/2009  12:09 PM           107,289 fetchyahoo
03/09/2009  12:09 PM             5,359 fetchyahoo.1
03/09/2009  12:09 PM             2,287 fetchyahoo.spec
03/09/2009  12:09 PM             4,907 fetchyahoorc
03/09/2009  12:09 PM             6,314 index.html
03/09/2009  12:09 PM            19,380 INSTALL
03/09/2009  12:09 PM               966 TODO
              10 File(s)        182,423 bytes
               2 Dir(s)  147,889,139,712 bytes free

You should now try to run it. it gave me this error initially:

c:\emails\fetchyahoo-2.13.3>perl fetchyahoo
Can't locate MIME/Head.pm in @INC (@INC contains: C:/Perl/site/lib C:/Perl/lib .
) at fetchyahoo line 59.
BEGIN failed--compilation aborted at fetchyahoo line 59.

Basically, it needs the MIME::Head module installed. For this, we will use CPAN module. You can also use the CPANPLUS module, which is more advanced and has the option of un-installing PERL modules too. CPAN module cannot un-install modules.

This is how you invoke CPAN (you can also just type c:/> cpan). Note that the overwriting the lockfile message might come if a previous session did not terminate properly:

c:\emails\fetchyahoo-2.13.3>perl -MCPAN -e shell

There seems to be running another CPAN process (pid 5220).  Contacting...
Other job not responding. Shall I overwrite the lockfile 'C:\Perl\cpan\.lock'? (
Y/n) [y]

cpan shell -- CPAN exploration and modules installation (v1.9205)
ReadLine support enabled

cpan> install MIME::Head
Going to read C:\Perl\cpan\Metadata
  Database was generated on Thu, 26 Mar 2009 10:26:54 GMT
Running install for module 'MIME::Head'
Running make for D/DO/DONEILL/MIME-tools-5.427.tar.gz
Fetching with LWP:
  http://ppm.activestate.com/CPAN/authors/id/D/DO/DONEILL/MIME-tools-5.427.tar.g
z
Fetching with LWP:
  http://ppm.activestate.com/CPAN/authors/id/D/DO/DONEILL/CHECKSUMS
Checksum for C:\Perl\cpan\sources\authors\id\D\DO\DONEILL\MIME-tools-5.427.tar.g
z ok
Scanning cache C:\Perl/cpan/build for sizes
DONE
MIME-tools-5.427/
MIME-tools-5.427/testin/
MIME-tools-5.427/testin/multi-simple.msg
MIME-tools-5.427/testin/andreas-1296.uu
MIME-tools-5.427/testin/ak-0696.msg
MIME-tools-5.427/testin/short.txt
MIME-tools-5.427/testin/words.txt
..
..
..

  CPAN.pm: Going to build D/DO/DONEILL/MIME-tools-5.427.tar.gz

*** Module::AutoInstall version 1.03
*** Checking for Perl dependencies...
[Core Features]
- Test::More     ...loaded. (0.72)
- Mail::Header   ...missing. (would need 1.01)
- Mail::Internet ...missing. (would need 1.0203)
- Mail::Field    ...missing. (would need 1.05)
- MIME::Base64   ...loaded. (3.07_01 >= 2.2)
- IO::File       ...loaded. (1.14 >= 1.13)
- IO::Handle     ...loaded. (1.27)
- IO::Stringy    ...missing. (would need 2.11)
- File::Spec     ...loaded. (3.2501 >= 0.6)
- File::Path     ...loaded. (2.04 >= 1)
- File::Temp     ...loaded. (0.18 >= 0.18)
==> Auto-install the 4 mandatory module(s) from CPAN? [y]
...
...
Appending installation info to C:\Perl\lib/perllocal.pod
  GBARR/TimeDate-1.16.tar.gz
  nmake install  -- OK
Running install for module 'Test::Pod'
Running make for P/PE/PETDANCE/Test-Pod-1.26.tar.gz
Fetching with LWP:
  http://ppm.activestate.com/CPAN/authors/id/P/PE/PETDANCE/Test-Pod-1.26.tar.gz
Fetching with LWP:
  http://ppm.activestate.com/CPAN/authors/id/P/PE/PETDANCE/CHECKSUMS
Checksum for C:\Perl\cpan\sources\authors\id\P\PE\PETDANCE\Test-Pod-1.26.tar.gz
ok
..
..
t/require.....ok
t/send........ok
All tests successful.
Files=8, Tests=127,  2 wallclock secs ( 0.00 cusr +  0.00 csys =  0.00 CPU)
  MARKOV/MailTools-2.04.tar.gz
  nmake test -- OK
Running make install
Prepending C:\Perl\cpan\build\MailTools-2.04-fCc9N7/blib/arch C:\Perl\cpan\build
\MailTools-2.04-fCc9N7/blib/lib to PERL5LIB for 'install'
...
...
Module 'MIME::Head' installed successfully
No errors installing all modules

Interestingly, you can also check this using Perl Package Manager GUI Utility (invoked by typing ppm on the windows command prompt). It just takes lot of time to load the GUI’s data:

perl-package-manager-screenshot

Now, let us check if it works:

c:\emails\fetchyahoo-2.13.3>perl fetchyahoo --nodownload
No username specified.
Please enter your Yahoo! username: pooja33pandey
Please enter your Yahoo! password:
No mailbox or mailspool specified.
Please enter the path to and name of your mail spool or mailbox (eg /var/spool/m
ail/username): pooja33pandey.mbox
Logging in securely via SSL as poojagverma on Fri Mar 27 22:29:50 2009
Failed: Invalid ID or password entered (username: pooja33pandey )

If you are running Vista, you might see this infamous pop-up window, which you will need to unblock:

vista-perl-block-dialog

All right! So it works. Now, lets try a more comprehensive example:

c:\emails\fetchyahoo-2.13.3>perl fetchyahoo --onlylistmessages --username=pooja1
3pandey --password=<pwd> --spoolfile=pooja.mbox --logout
Use of uninitialized value $ENV{"HOME"} in concatenation (.) or string at fetchy
ahoo line 1992.
Logging in securely via SSL as pooja13pandey on Fri Mar 27 22:45:49 2009
Country Code 'in' not found. We will try the translation for 'us'.
Country code : in       FetchYahoo! Version: 2.13.3
Successfully logged in as pooja13pandey.
Marking messages read on the server

Fetching mail from folder: Inbox
Getting Message ID(s) for message(s) 1 - 25.
1. new "Public Records " - Locate anyone. Search public records. 7:46 AM 6KB
2. new "Pooja Pandey <p" - online skype number (678) 534-2725 2:47 AM 3KB
3. old "Nimesh Bhuva <b" - Re: [GHPCSB_MCA_2k] Re: Happy Holi 27/3/09 35KB
4. old "Nimesh Bhuva <b" - Re: [GHPCSB_MCA_2k] Happy Holi 27/3/09 32KB
5. old "Birthday Remind" - First Reminder for Vibha Deshmukh's Birthday 26/3/09
4KB
6. old "Sharma, Ashish " - RE: [LIKELY JUNK]RE: [LIKELY JUNK]Re: So it 25/3/09 6
0KB
....
....
Got 90 Message IDs
Not downloading messages
Messages have not been deleted.
Logged out.

Note that fetchyahoo limits the messages fetched to 90 by default, because there is a download limit of 65mb per hour per user per IP address that is set by yahoo. You can use –safedownload option to give a gap of 5-10 seconds between each message fetch. This way, you can run a single command for a long time, without hitting the yahoo imposed download limit (per user, per IP).

Note that once you download the messages locally, they will be marked as read. If you want to terminate the download in between, you can do so and resume it later with the –newonly and –msgidarchivefile option. By defeault, the messages are appended to the archive/spool file:

D:\emails\fetchyahoo-2.13.3>perl fetchyahoo --folder=<foldername>  \
--username=<username> --password=<password>                        \
--safedownload  --spoolfile=<foldername>.mbox                      \
--msgidarchivefile=<foldername>_msgids  --newonly

Conclusion: The strategy in a nutshell

So there you have it. A simple mechanism to get targeted email ids for making your online marketing campaign successful:

1) Identify the Yahoo Group that you are interested in. This is a strategic decision. You want to limit your focus to people who would be interested in your idea. The demographics are important for high return on interest.

2) Become a member of the group and subscribe to individual emails.

3) Setup a filter to direct all Group emails to a specific folder. Free Yahoo account allows for 100 such filters now. Make sure the traffic is flowing in.

4) Sit on your ass for 6 months to 1 year to allow of significant volume of emails. If it is high activity/volume group, then your wait time would be lesser.

5) Fetch the Yahoo folder contents to your local PC. Now you are sitting on the goldmine.

6) Filter out the email ids using simple shell script provided here. Feel free to extent it to your needs. Always manually check the email ids retrieved.

7) Last, but not the least, input the contacts gathered to your mail broadcast software and reap the benefits by inviting them to your newsletter/broadcast.

Remember, the golden rule of thumb to retain the interest of your audience — Do not send too many similar mails in too short a period of time. Start very moderately and hope that most of them would join your newsletter.

Conclusion – With great power comes great responsbility..

Well, I hope that this article was helpful to you, if your intentions are true and pure. I DO NOT support mis-use of this method for spamming people’s inboxes and for immoral or lucrative purposes (that is NOT the intention with which this article has been written).

If you find this article useful or would like to discuss it further, please leave a comment here. Have a great day and Good luck.

Quick script for extracting emails from unformatted text

Often, we face a need of extracting emails from some un-formatted text like or html tags etc. For this, the following script can come handy for extracting emails into simple text file, which can be uploaded to mailman or other mailing software contact lists:

$ more xtract_emails.sh
#/bin/ksh
sed -e 's/\,/\n/g' -e 's/ /\n/g' $1 |   \
                             grep '@' | \
sed -e "s/[<>();]//g" -e 's/mailto://g' \
                              | sort -u > ${1}.extracted.txt

wc -l ${1}.extracted.txt

Example:

$ ./xtract.sh emails_unformatted.txt

131 emails_formatted.extracted.txt

Hope it is useful for someone else for extracting emails in a single shot. Otherwise, it takes a lot of time for doing several passes by examining the post-processed output. Even with the above heuristic rules, the output may not have 100% proper email, so some proof reading would be needed.

If this is useful to you, please leave a comment here.

Failed opening required ‘wp-blog-header.php’ while using cformsII wordpress plugin

Problem

All right, so I was trying to insert a cforms II contact form in WordPress 2.7.0 Installation and was facing this error in a pop-up dialog box:

Warning: require_once(wp-blog-header.php) [function.require-once]: failed to open stream: No such file or directory in /home/wisdom/public_html/prashna/wp-content/plugins/cforms/js/insertdialog25.php on line 9

Fatal error: require_once() [function.require]: Failed opening required ‘wp-blog-header.php’ (include_path=’.:/usr/lib/php:/usr/local/lib/php’) in /home/wisdom/public_html/prashna/wp-content/plugins/cforms/js/insertdialog25.php on line 9

I ignored it for a little while, but a point came when I had to really get it going. As everyone else, I googled it. The first 3-5 pages of it are sheer nonsensical links of websites facing the same error, but without solution. Then finally, I hit upon a support forum of cforms II, which suggested many things.

Solution

This is what worked for me. Apparently, the abspath.php was MISSING from the cforms plugin directory:

wisdom@wisdomspeak.org [~]# find . -name abspath.php
./public_html/mantra/wp-content/plugins/cforms/abspath.php

wisdom@wisdomspeak.org [~]# find . -name cforms
./public_html/mantra/wp-content/plugins/cforms
./public_html/gita/wp-content/plugins/cforms
./public_html/prashna/wp-content/plugins/cforms
./public_html/vedvaani/wp-content/plugins/cforms

# cp ./public_html/mantra/wp-content/plugins/cforms/abspath.php \
./public_html/prashna/wp-content/plugins/cforms

And everything was golden..

Thanks to that, I was able to have a contact form like this in the wordpress page:

cforms1

Setting up a common login across multiple wordpress installations

A pre-requisite for promoting interaction across sub-domains..

After setting up wisdomspeak.org/mantra, wisdomspeak.org/vedictalks and wisdomspeak.org/gita, i realized that the only way the parent website, wisdomspeak.org, was going to get popular were through inviting user interaction on discussion boards. But for this, users would need to be logged into different sub-domains through a single login (like a global single sign-on feature of Oracle applications).

Assumptions:

First and foremost, the version of wordpress installed on the multiple sub-domains was version 2.7. Also, the wordpress installations were done in the same database, with different table prefixes.

The table_prefix of the first wordpress installation (wisdomspeak.org/mantra) was “wp_”, whereas the table prefix of the other wordpress installation with which I wanted to share the userbase of wisdomspeak.org/mantra, was “gita_”.

Now I had to make wisdomspeak.org/gita use the same users/roles as wisdomspeak.org/mantra.

What worked finally..

Once you try googling it yourself, this is probably the most straightforward and common response that you would see:

In the wp-config.php of the 2nd wordpress installation, after this line:

/* That's all, stop editing! Happy blogging. */

..add the following:

define('COOKIE_DOMAIN', '.wisdomspeak.org');
define('COOKIEPATH', '/');
define('CUSTOM_USER_TABLE', 'wp_users');
define('CUSTOM_USER_META_TABLE', 'wp_usermeta');

But when I was going to wisdomspeak.org/gita/wp-login.php and trying to login as admin user, I was getting you do not have ” You do not have sufficient permissions to access this page.” error message while using firefox browser, while IE just gave up with a page not found error.

Interestingly, this error is also encountered a log while people upgrade wordpress installations, so there is a lot of scope of mixing up resolutions while trying to solve this. Better be wary of mixing different recipes.

And so, in desperation, I searched for more options/resolutions and came across a post that suggested changing the prefix values of meta_key column in the <table_prefix>_usermeta table of the 2nd word press installation. Using this hint, I did some more tweaking by opening the phpMyAdmin interface of the gita_metadata, but the permissions error was still coming.

So, i searched a bit more and came across a posting in which a user was not able to make it work, in spite of manually the prefix of <table_prefix>_capabilities table referred in $WORDPRESS_HOME/wp-includes/capabilities.php to the table_prefix of the earlier wordpress installation (which was wp_ in my case). The change is actually quite simple: you are fixing the name of the capabilities table for a user to be wp_capabilities.

function _init_caps() {
global $wpdb;
/* $this->cap_key = $wpdb->prefix . 'capabilities';  -- the earlier entry*/
$this->cap_key = 'wp_capabilities';  /* the new entry */
$this->caps = &$this->{$this->cap_key};

And when I tried with this, not only was I able to login with the admin user’s password for wordpress installation 1 in wordpress installation 2, but when I changed the URL from wisdomspeak.org/gita/wp-admin/ to wisdomspeak.org/mantra/wp-admin/, i was not redicted to a login page again, which meant that the same user was shared across different wordpress installation. (It did ask me the login once for wisdomspeak.org/mantra/wp-admin/, so perhaps the cookie was not shared really, but that is something I need to doublecheck).

Extending this concept to roles?

While going across capabilities.php, I came across a similar looking entry for user_roles and thought that logically speaking, a similar fix would be needed in capabilities.php to re-use the user roles :

function _init () {
global $wpdb;
global $wp_user_roles;
 /* $this->role_key = $wpdb->prefix . 'user_roles';
$this->role_key = 'wp_user_roles';

But when I tried this, i started getting the You do not have sufficient permissions to access this page.” error again. On reverting it back like this, the login started working again:

function _init () {
global $wpdb;
global $wp_user_roles;
 $this->role_key = $wpdb->prefix . 'user_roles';
/* $this->role_key = 'wp_user_roles'; */

So was it really needed..

Looking back, changing the meta_key column’s entries in gita_usermeta table did not make any sense, since I was never going to use that table. To prove this point, i changed the prefix values for meta_key column back to gita_ and the admin user was still shared across wisdomspeak.org/mantra nad wisdomspeak.org/gita.

How to share cookies across wp installs in a common domain?

Thanks to Ben (whose comment can be seen below) for sharing the secret for making cookies work across wordpress installs in a common domain:

1) Use the same auth_salt, logged_in_salt, secret key in /wp-admin/options.php page for each sub-domain blog

2) Install Root-cookie plugin ( by LINICKX )

* http://www.linickx.com/archives/831/root-cookie-path-14-an-update-for-wordpress-27

1. Upload root-cookie.php to the /wp-content/plugins/ directory
2. Activate the plugin through the ‘Plugins’ menu in WordPress
3. Log out
4. Log in
5. Done :o )

3) And in: wp-settings.php

Change this source code like this:

351 – define(‘COOKIEHASH’, md5(get_option(’siteurl’)));

to:

351 -  define(‘COOKIEHASH’, md5(get_option(‘http://www.mysite.com’)));

Yippee!

All right, so that was a good learning on an early Sunday morning; All in 1 hour of googling and trying out options. Dont they say that early mornings are the most productive of times.

My first Aesthetic wordpress theme: Modifed Lotus Flower Theme for 3 columns

A big Leap..

The past few days have been a big leap for me. Thanks to Google’s search engine, tons of prolific writers across the world, and Tanvi Chanchalani, I learnt something about wordpress and css, which enabled me to modify a beautifully aesthetic 2-column wordpress theme called Lotus Flower into a 3-column wordpress theme. Not only this, using it, I was able to quickly make two websites on my newly purchased domain, wisdomspeak.org.

The purpose of this post is to recount my learning experience in slow motion for my own benefit and also for the benefit of those thousands of budding wordpress theme creators. Honestly, there is so much creativity out there. People get great ideas all the time. It would be a pity not to be of any service to them, so that they could help humanity. Well, seriously, I just want to help.

I Love you!.. but…

Ok, back to the mission.

When I initially saw the Lotus Flower theme on http://www.freewpthemes.net, I was so impressed (bowled over might be the right term) that it immediately struck me “the” one. And I used it very well, feeling happy.

But soon, I realized that to encourage the community to adopt the audio resources website that I was planning to build, Im going to need people to donate as well, which meant that they needed to see the Donate through Paypal plugin on the sidebar WITHOUT scrolling down.

Necessity is the mother of Invention..

The Support us plugin simply had to catch the attention of the person browsing the website, or else the idea would be buried in the annals of .. uhm.. the sidebar. So I had this really urging need of bringing it on the right hand side, along with some more visible links to related websites. Cmon now, I had to make it easy on the users, right, or else I wouldn’t be doing my marketing homework right.

And so, i started looking around for means to add another sidebar. But there was this ONE problem. I didn’t know squat about PHP or wordpress themes or CSS !

Hmm, but I had a couple of big factor on my side. I had the fire in the belly to make it work and I had TIME. Did anyone tell you that time is also a big resource? (The Capitalist says: Time is Money. In Hindi they say, समय बड़ा बलवान – time is very powerful).

And so, the hunt begins..

Ok, so the first thing to understand for customizing a wordpress theme is that the heart of the Look/Feel/User Interface is the style.css (cascading style sheet) file, which is usually in the home directory of the WordPress theme ($WORDPRESS_HOME/wp-content/themes/<themename>). The directives given in style.css regulate the placement and cosmetics of the elements that make up the website.

The contents or elements themselves come from WordPress’s infrastructure (content entered through …/wp-admin.php console) and have got nothing to do with a style.css file. You could simply modify the sytle.css and achieve visually very different results. For example, check out wisdomspeak.org/vedictalks and wisdomspeak.org/mantra. They are both using the SAME theme, but just slightly different style.css  etc.

A different path of hit and trial..

But thats not how it played out for me. The paragraph above me is just me talking in retrospect.

First, I tried adding a second sidebar to the Lotus Flower theme. After googling a lot of pages, I could finally see sidebar2 in the Configure Widgets Page (through the Dashboard link):

1) Prefixed an argument “2,” as the first argument to the register_sidebars() function in functions.php. Earlier, the function call was for register_sidebar() — notice the singular case.

register_sidebars(2, array(
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' =>  '</li>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>',
));

2) Copied $WORDPRESS_HOME/wp-content/themes/<themename>/sidebar.php to $WORDPRESS_HOME/wp-content/themes/<themename>/sidebar2.php and made the following changes in sidebar.php and sidebar2.php:

# diff sidebar.php sidebar2.php
1c1
< <div id="sidebar-left">
---
> <div id="sidebar-right">
3c3
<               <?php if (!function_exists('dynamic_sidebar')
|| !dynamic_sidebar(1)): ?>
---
>               <?php if (!function_exists('dynamic_sidebar')
|| !dynamic_sidebar(2)): ?>

Earlier, the function call inside sidebar.php was only for dynamic_sidebar(). It wasn’t working without it. Also, the <div id..> tag value was made more specific to -left or -right.

Later on, I realized that the advantage of this was that I could influence the look and feel of each sidebar individually.

3) Included <?php include( “sidebar2.php”); ?> in page.php and index.php like this:

<?php get_header(); ?>
<?php include( "sidebar2.php"); ?>

Then did the same for $WORDPRESS_HOME/wp-content/themes/<themename>/404.php, archive.php, search.php, single.php. The really dumb rule of thumb that I followed was: if there is a <?php get_sidebar(); ?> in the php file, it needs the 2nd sidebar too.  Common sense, eh?
4) At this point, lo and behold, I COULD see the 2nd sidebar in the Configured widgets page on WordPress admin console and happily assigned the PayPal widget to the right sidebar. At least, I was getting somewhere.

5)  When I tried previewing the website live, it WAS showing the right sidebar, but the left sidebar was pushed way down on the left. So the content was very much there, but the UI/cosmetics was not displaying it right. This is where we need to brush up our CSS skills.

learning basic CSS..

Now, it was down to manipulating the style.css for accommodating the extra sidebar.This is where these tutorials from html.net really helped me understand the overall scheme of css. I still don’t understand that much about how floating works. My approach to making the theme work was .. change one property, preview it and if it wasn’t working, revert it back. Pretty much hit and trial based.

From common sense, I could reason that there was a need to play with a lot of width values width/padding/marging values for various elements in style.css, because ultimately that’s what was causing the mis-adjustment.

Changed the style.css a bit to accomodate the 2nd sidebar to the right. I had to play with a lot of width values. I just guessed that some of those width/padding/marging values were infuencing the display. But I didn’t understand the overall structure properly yet.

It was actually at http://www.html.net/tutorials/css/lesson13.asp that a lightbulb lit up in my mind. The example had used width: 33%;.

Ok, I thought, if this directive can be used for columns in a list, then why cant it be used for any other element? Or in other words, it should be possible to use a similar % directive for other elements in css too.

First blood..

This is where Tanvi helped me a lot in advising which sections and their properties to be changed. I wanted to cover more width on the screen (800×600 resolution is history). Keeping this in mind, she not only widened some settings, but also sent me widened images to go along with the new theme.

When I initially replaced the style.css for theme, its working on firefox, but not on IE: The left sidebar was not able to adjust on the top somehow, and was pushed down below. Also, the header and top navigation pane were not centered.  Thats when I realized that the new widened images had not been overlaid. After copying them, the screen is much wider, finally! However, there seems to be some sort of an adjustment issue with the radio widget’s size or floating adjustment for IE. From googling, it seems that there are some CSS bugs for IE, especially around wrapping or floating.

After playing with width: <number>% directives for content, sidebar-left, sidebar-right sections of style.css (I identified them with the background image tag — compared the filenames to the theme’s images visually.), I was able to bring all the contents under a very uniformly formatted pattern.

I was experimenting with % values for width on top of the css and  this seems to be setting up the alignment very well for sidebars and the top! It almost like what is needed. But there was still a gap between the left sidebar and the main content box. It seems to be related to some margin setting for the content element. This is what worked out for me:

#sidebar-left {
        FLOAT: left; WIDTH: 20%
}
#sidebar-right {
        FLOAT: right; WIDTH: 20%
}
#content {
        BACKGROUND: url(images/img10.jpg) no-repeat left top;
 FLOAT: right ; WIDTH: 58%
}

In an effort to center and widen the header & logo and remove extra padding between header/logo, I kept playing with the properties of their sections:

#header {
        BACKGROUND: url(images/img02.jpg) no-repeat center center;
MARGIN: 0px auto; WIDTH: 1200px; HEIGHT: 60px
}
#logo-wrap
 {
       PADDING-RIGHT: 0px; PADDING-LEFT: 0px;
BACKGROUND: url(images/img03.jpg) no-repeat left top;
PADDING-BOTTOM: 20px; MARGIN: 0px auto;
WIDTH: 1200px; PADDING-TOP: 10px
}

Now the top alignment was perfect, but the menu links at the top (links to the WordPress “Pages”) were aligned to the very left. Once again, Tanvi came to the rescue and said that the answer was to change the left padding for menu UL section:

#menu UL {
    PADDING-RIGHT: 0px; PADDING-LEFT: 145px;
PADDING-BOTTOM: 0px; MARGIN:0px; LINE-HEIGHT: normal;
PADDING-TOP: 0px; LIST-STYLE-TYPE: none
}

This is when It was very much like what I wanted it to be. I was elated and thankful to have been able to achieve my goal.

Later that night, I saw that the padding for the elements in the right sidebar was off, not uniform. It was related to the left-padding pixel value being somewhat different for the list and element. I wouldn’t say that even now all the left/right padding values for left/right sidebar’s units/lists elements are uniform at 0px or 5px or 10px, but its just that the combination of hits and trial without a particular scheme worked out. You should take a more methodical approach and keep a uniform pixel side to make things easier.

The Modified theme ..

screenshot

The theme is available here for your download and further modification. The original theme’s zip file is available here.

Later on, I modified the following two things to make a different theme for wisdomspeak.org/vedictalks (the new one is style.css):

# diff style.css.gold1 style.css
2c2
<       PADDING-RIGHT: 0px; MARGIN-TOP: 10px; PADDING-LEFT: 0px; FONT-SIZE: 13px;
BACKGROUND: url(images/img01.jpg) repeat-x left top; PADDING-BOTTOM: 0px; COLOR: #333333;
PADDING-TOP: 0px; FONT-FAMILY: "Trebuchet MS", Arial, Helvetica, sans-serif
---
>       PADDING-RIGHT: 0px; MARGIN-TOP: 10px; PADDING-LEFT: 0px; FONT-SIZE: 13px; 
BACKGROUND-COLOR: #FFF380; PADDING-BOTTOM: 0px; COLOR: #333333;
PADDING-TOP: 0px; FONT-FAMILY: "Trebuchet MS", Arial, Helvetica, sans-serif
98c98
<       BACKGROUND: url(images/img05.jpg) no-repeat left top;MARGIN-LEFT: 4px;
MARGIN: 0px auto; WIDTH: 950px; HEIGHT: 200px;
---
>       BACKGROUND: url(images/img05.jpg) no-repeat left top;MARGIN-LEFT: 4px;
MARGIN: 0px auto; WIDTH: 950px; HEIGHT: 20.3em;

The beauty of  HEIGHT: <number>em property is that it can scale up the image very well.

The new theme looks like this:

vedictalks-snap

Feedback..

I know this is not the best of the tutorials out there on the internet, but I would appreciate feedback/validation from you, whatever your level of expertise. I am still learning CSS and would love to try new things like scalable flash images in a wordpress blog.  So please leave a comment here. Thanks for your consideration.

Shoutcasting into the new year – I made my own radio station for FREE Today in 1 hour

Preface – Joining the Android revolution

Last year, I joined the Android open source revolution as a user. I took a difficult and controversial decision. I bought the G1 phone. Many people call it the T-mobile G1 phone, but I like to call it the HTC G1 phone, to give credit to the actual phone manufacturer. Agreed, it couldn’t have happened without Google sponsoring the Android platform and creating the Open Handset Alliance. T-mobile got exclusive rights to the marketing of the very First device to run the Open source android platform and got a sweet deal for itself. It even convinced many people to buy the data plan.

I am sure a lot of people thought that they had to get the data plan to make the phone even work. Well, that was true, but only for the very first power up of the phone. Once it had registered the google account for the phone, it didn’t really care if it had the data plan or not.

I bought the G1 through Ebay (unlocked). After utilizing Microsoft Cashback Livesearch feature with Ebay, I got a sweet deal for $375, including some accessories. Back in Nov 2008, I got a 25% cashback! A week later, Microsoft announced that they would give instant rebates, instead of delaying the cashback for 2 months via Paypal, as originally announced.

Later, I learnt that Tmobile also sells the unlocked handset to customers for $399 without contract, although its not openly said so. So if you are thinking of getting it from ebay/amazon, try hammering a Tmobile representative at a store. It might be worth getting it from Tmobile and make them liable (just in case the handset develops some issues).

After playing with the G1 Phone for a while, I thought it was a worthwhile investment for me, as I was able to get on the internet anywhere with the data plan. K-9 Email (just released a more stable version yesterday) and AIM IM (continuously improving) work well on this RC30 revision of the platform now, and honestly, that was all I needed to work efficiently; effectively, I had bought my independence.

The Android Market/Application Store

One of the most fascinating selling points of the android platform is the Market, which is in Beta stage till 15th Jan 2009, which effectively means that all applications are free on it. (The Pacman game is the lone exception, I guess). There are some very creative people out there who are developing applications left and right. I remember that when I got hooked to the market, I would check out the market almost every night and try out new programs.

This was also the time when I logged a lot of bugs/enhancements through http://code.google.com/p/android/issues/entry website. It was quite concerning to see that this website was not very much publicized, though. I guess Google wanted to keep it quiet till the Beta stage was over.

Streamfurious – Great potential

When I first played the StreamFurious application, I was fascinated at the various radio stations that I could play. It also set me thinking as to what was shoutcast/icecast in the first place.

On doing a bit of Googling, I came across some posts and youtube videos of how to build a shoutcast server, which seemed lucid enough.

http://www.frihost.com/forums/vt-15354.html – This is the one I used for my shoutcast server
http://wizardskeep.org/mainhall/tutor/shbroad.html — this one has screenshots

http://www.youtube.com/watch?v=c1leou1vqE4 – This is a good video for Linux installation (recommended for stability)

This morning, I had some free time on my hands and decided to look into creating my radio station. I only used the first link, http://www.frihost.com/forums/vt-15354.html, and I was up and running with my station within 1+ hour (includes discovery and trial/error time). Now thats really OPEN technology.

Apparently, there are a lot of FREE shoutcast servers on the internet, and the most popular of them seem to be WINAMP’s shoutcast plugin (from winamp.com) and the shoutcast server from shoutcast.com.

How does it work..

Come to think of it, the technology itself is quite simple, after all the abstractions and implementations.

The actual audio track is played in Winamp. Winamp, in turn, has a plugin, which talks to another Shoutcast streaming service (installed through the Shoutcast server). The Shoutcast service talks to the shoutcast.com servers for registration/status etc. and makes the audio available to internet users.

The entire flow could be depicted as:

Winamp (play audio here) –> Winamp shoutcast Plugin –> Your Shoutcast Server <–> Shoutcast.com

/\

|

Internet users (Shoutcast clients)

In addition, I had to enable port forwarding in my home router for port 8001 for 192.168.0.2 IP, so that external users could talk to my shoutcast streaming server.

Some Setup considerations..

One thing to note here is that I had to wait for an hour or so before my station actually got registered with shoutcast.com and was showing up in the search.

It seems that when the shoutcast server log shows this message, the registration can be assumed to done:

I think this is the right log message to look for the station registration..

<01/07/09@12:09:28> [yp_tch] yp.shoutcast.com touched!
<01/07/09@12:19:37> [yp_tch] yp.shoutcast.com touched!

Another thing to mention here is that the upload speed of the internet connection on your shoutcast server matters and would be key to decide what encoder setting you would use. If you expect N concurrent users and you arebroadcasting at 24kbps encoder setting, then your overall upload requirement is (N x 24) kbps at any time.

shoutcast-log

You got to make sure you can sustain that upload bandwidth. Even with 24 or 48 kbps, you get pretty good results. The default number of maximum users is 32, which is not bad for experimentation over cable modem internet speeds.

shoutcast-encoder-freq

Also, remember that the lower your encoder settings, the more people can connect to your radio station. Know that BBC UK streams audio at 24kbps, so its not bad to use smaller settings. (but then they must be having a cluster of shoutcast servers and multiple relay server too, I’m guessing).

I started off with 24kbps first, but later switched to 64kbps to experiment with downloading speeds for StreamFurious. Also, I was using Comcast High speed Internet with download speed of 3.5mbps and upload speed of 1.5mpbs (speedtest.net would tell you).

Mantra Pushpam @ Atlanta – My Radio Station

mantra-pushpam

I always wanted to listen to Vedic Mantras/Chants whenever I wanted to. Thanks to Open source technology (shoutcast), Google, HTC, Tmobile and ebay, now I am able to play Vedic chants/Mantras on the G1 phone through StreamFurious client.

shoutcast-server-running

All I had to do was click on http://71.204.14.23:8000, click on Listen tab and the browser redirected the request to Streamfurious, which then added the station through the listen.pls file and buffered media upto 2mb before playing the streaming audio. Now, I was on an EDGE connection, so it took a while for the buffering to happen. On 3g Networks, it should be even faster.

Note that Streamfurious does not have the capability to add a radio station manually as of now, but if you go to the source URL of a streamcast server and click on Listen, the default browser is smart enough to redirect the request to Streamfurious. That’s how I’m getting around it for now.

For the iPhone users..

For the iPhone users, there are FlyCast (FREE! Very cool article here: http://cybernetnews.com/2008/09/16/free-iphone-app-streams-music-in-the-background/) , iRadio and Shoutcast radio applications that came out in the market. I am still having my iPhone friends try this out.

Here is a very good article on how to listen to Shoutcast radio stations using iTunes.. http://cybernetnews.com/2008/10/23/cybernotes-add-shoutcast-radio-streams-to-itunes/

Another good article with Video review is at http://www.appvee.com/t/shoutcast-radio

For them BlackBerry users..

For the Blackberry power users, FlyCast works well for them. Information on how to download and install FlyCast is available at http://www.blackberryforums.com/aftermarket-software/158658-flycast-download-links.html

When the installation dialog comes up, click “Set Application Permissions” and then click “Download”. On the configuration screen, change the “Connections” and “Interactions” settings from “Custom” to “Allow”. Press “Back” and then “Save”. The application will download and install. If you have a Bold – Run “FlyCast” from the Downloads folder

If you have a Curve – Run “FlyCast” from the general “Ribbon”

You have have to register here – FlyCast – Now your smartphone is complete, then  log in from your BB.

FlyCast has set up a support site for iPhone and BlackBerry users. Please visit FlyCast Forums Index page for tips on getting the most from FlyCast on your BlackBerry.

Additionally, You can also run audio streaming through the Slacker application, as seen here : http://blog.laptopmag.com/video-hands-on-with-slacker-application-for-blackberry

StreamFurious Vs AntPlayer

When I tried running the station again later today with StreamFurious (version 0.0.6), it started deleting the buffer first (which it was not recycling — seemed like a bug for sure. I wrote to feedback@streamfurious.com about this and did not get any response from them). The deletion of the buffer resulted in timeouts and not a very good user experience. This forced me to look for more alternatives in the android market for playing shoutcast streams.

Through http://www.howardforums.com/showthread.php?t=1468651, I found AntPlayer, which seems to be more mature in terms of finding stations (the search feature actually works) and also a good buffer recycling mechanism.

On day 1, I had better success with AntPlayer for some reason. However, on the subsequent days, at random times, StreamFurious seemed to work better than AntPlayer. Actually, AntPlayer seemed to hang while buffering totally, while StreamFurious did not seem to repeat the buffer deletion syndrome anymore. (It COULD have to do with the fact that I had restarted the shoutcast server a couple times on the first day itself).

A caveat with StreamFurious seems to be that it uses up the battery very quickly. Also, it seems StreamFurious is getting more publicity in the market due to the keyword Stream in its application name.

http://mantra.podzone.org:8000/listen.pls – Making the radio station URL  user friendly and Pnemonic to memory

Since I am running this station from my home on a regular Dell latitude D630 laptop on Windows XP and Comcast Cable internet (behind a Netgear router), the actual external IP would change from time to time. I wondered: How could I make the radio station’s URL independent of the IP?

Then I remembered that a long while back, I had used free DNS services provided by dyndns.com. DynDNS has many paid services, but you can associate an IP to some predetermined domains (you get to choose the sub-domain though) for FREE.

So I created a free account on dyndns.com and associated my shoutcast server’s external IP 71.204.14.23 (got through http://www.Whatismyip.com) with mantra.podzone.org.

update-for-mantra-podzone-org1

Whenever I would have to reset the internet connection or restart Windows, the external IP would change. To re-associate the latest external IP, I would simply go to https://www.dyndns.com/account/services/hosts/ and assign the latest IP (it detects the external IP auto-matically) to mantra.podzone.org. This way, the users do not have to remember anything, but  http://mantra.podzone.org:8000/index.html.

If you click on the Listen subtab, the browser should be able to open the listen.pls (playlist) file with a suitable application on the mobile OS.

You’ve got to utilize the power of free stuff on the internet.

Network utilization Stats..

Now, I was also interested in the network utilization stats on my wireless network due to shoutcast broadcast per user. When I played the station through streamfurious on my G1 phone, i monitored the local wireless network interface’s bandwidth usage (11mpbs maximum bandwidth) and got this graph:

wireless-bandwidth-usage-from-task-manager

As you can see, it was using less than 1% of 11mbps bandwidth per mobile user.

Feedback welcome

If you found this article helpful and would like to discuss/express your views, please do leave a comment and we can discuss over web/email.

Thanks a lot for your time to read this article!

Virtualbox shared folder mounting issue: Missing module on opensuse 10.3

The Version combination for this scenario..

This problem was encountered with the following combination:

  • Virtualbox 1.6.4
  • Host OS: windows XP service pack 2
  • Guest OS: OpenSuSE 10.3

A shared virtual folder was defined for the opensuse virtual machine like this:

In the guest OS, a mount point was defined like this:

linux-jo4o:~ # mkdir -p /ddrive

Now when the mount of the shared folder was attempted, this error was received:

inux-jo4o:~ # mount -t vboxsf d_drive /ddrive
/sbin/mount.vboxsf: mounting failed with the error: No such device

An unlikely solution…

It seems that a critical module required for shared mount points was not loaded in memory. Here, we can see that only one module with the vbox pattern in it’s name is loaded:

linux-jo4o:~ # lsmod | grep vbox
vboxadd                56232  3

So lets load the vboxsvfs module into memory:

linux-jo4o:~ # modprobe vboxvfs

After that, we can verify that it is really loaded:

linux-jo4o:~ # lsmod | grep vbox
vboxvfs                38184  0
vboxadd                56232  4 vboxvfs

Now, let us mount the shared folder:

linux-jo4o:~ #  mount -t vboxsf d_drive /ddrive

Awesome! That was smooth. Lets check if the shared folder really got mounted or not:

linux-jo4o:~ # mount
/dev/sda2 on / type ext3 (rw,acl,user_xattr)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
debugfs on /sys/kernel/debug type debugfs (rw)
udev on /dev type tmpfs (rw)
devpts on /dev/pts type devpts (rw,mode=0620,gid=5)
/dev/sda3 on /home type ext3 (rw,acl,user_xattr)
/dev/sr0 on /media/VBOXADDITIONS_1.6.4_33808 type iso9660 (ro,nosuid,nodev,uid=0)
d_drive on /ddrive type vboxsf (rw)
linux-jo4o:~ #

Yippee!

I can share files with my windows laptop now. Now that was some adventure, eh :)

To make this more permanent, there has to be a way of loading this module automatically. Maybe I can put the modprobe command in /etc/rc.d/boot.local file, but then maybe there is a better way. I leave that to you to figure out.

Package dependency for installing virtualbox guest additions on Open SuSE 10.3

The problem at hand..

Well, I had to get the shared folder feature working on Open SuSE 10.3 virtual machine for a variety of reasons, and in turn, I had to install guest additions on virtualbox 1.6.4. There were a bunch of package dependencies even before coming to this error, and unfortunately, I dont have the entire series of command that I issued, but in this posting, I will attempt to present the solution of the immediate error that I was facing.

The KERN_INCL variable had to be set to the /usr/include directory:

linux-jo4o:/usr/src/linux # env | grep KER
KERN_INCL=/usr/include

After mounting the guest additions CD and running the VboxAdditions.run command as root, the kernel was not able to be compiled and this was visible in the install log:

linux-jo4o:~/addons # more /var/log/vboxadd-install.log

Installing VirtualBox 1.6.4 Guest Additions, built Tue Jul 29 20:13:59 CEST 2008

Testing the setup of the guest system

Building a test kernel module...

make KBUILD_VERBOSE=1 -C /lib/modules/2.6.22.5-31-default/build SUBDIRS=/tmp/sel
fgz1883915647/module/test SRCROOT=/tmp/selfgz1883915647/module/test modules
make[1]: *** No rule to make target `modules'.  Stop.
make: *** [vboxadd_test] Error 2

Building the test kernel module failed.
Giving up due to the problems mentioned above.
linux-jo4o:~/addons #

Initial thoughts and a potential solution

Initially, I thought that maybe it was a problem due to missing symbolic link to the modules directory (??), but when I posted this question on the vbox-users mailing list (which I think is more effective than the forums at times), I got a response saying that maybe I should check if the kernel-source package was installed or not.

To even find the package, we needed the main SOURCE repository added in the YAST setup. This is what the installed online repositories looked like:

When I ran the following command as root, it was clear that this was the missing link:

linux-jo4o:~ # zypper install kernel-source
* Reading repository 'Main Repository (NON-OSS)' cache
* Reading repository 'openSUSE-10.3-OSS-KDE 10.3' cache
* Reading repository 'Main Repository (Sources)' cache
* Reading repository 'Main Repository (OSS)' cache
* Reading installed packages [100%]

The following NEW package is going to be installed:
  kernel-source 

Overall download size: 49.2 M. After the operation, additional 243.4 M will be used.
Continue? [yes/no]: yes
Downloading package kernel-source-2.6.22.5-31.i586, 49.2 M (243.4 M unpacked)
Downloading: media
* Downloading [100%]
Downloading: kernel-source-2.6.22.5-31.i586.rpm
* Downloading [100%]
* Installing: kernel-source-2.6.22.5-31 [100%]
linux-jo4o:~ #

Now, when I tried installing the guest additions, it was able to install them and recompile the kernel JUST fine. Sweet!

linux-jo4o:~ # /media/VBOXADDITIONS_1.6.4_33808/VboxAdditions.run
Verifying archive integrity... All good.
Uncompressing
VirtualBox 1.6.4 Guest Additions for Linux
installation.............................................................................................................................................................................
VirtualBox 1.6.4 Guest Additions installation
Building the VirtualBox Guest Additions kernel module...
Building the shared folder support kernel module...
Installing the VirtualBox Guest Additions...

Successfully installed the VirtualBox Guest Additions.
You must restart your guest system in order to complete the installation.
linux-jo4o:~ #

How to get the enhanced Rich text editing buttons in wordpress.com editor?

The why — Bloggers need Rich text editing..

If you are a newbie wordpress.com blogger, chances are that at some point you would have pulled your hair out trying to figure out how the heck to display the rich text editing buttons that would give you the MS word like editing features. I definitely remember doing that, it was an uphill experience. Believe me, I had “seriously” tried to look for it in Google and wordpress forums — only to be told that you are probably mistaking wordpress.com for wordpress.org (arrgh!) and that its not part of the free wordpress.com blog (that was support talking — can you believe that?).

I am posting this in the hope that a fellow newbie like me would not be in the same boat and gets productive right off the bat.

This is what you might originally see when you write a new post..

Life was difficult with this kind of editor. To put heading tags, I had to use the HTML editor and put these tags in manually, which was a royal pain:

Then one fine day…

It was Serendipity. Nothing less. While editing a post, I hit a key by mistake, and Viola!, there it was, the rich text palette, right in front of it. I had really no idea what had caused the second half of rich text editing buttons to come up, but I could see that it was not disappearing even after many shutdown and startups of my laptop.

Strangely, it would not come up on my other computers even though I was logged into the same wordpress account.

Its the kitchen sink, silly..

Serendipity – Part 2. God has his ways of revealing his glories. This fine day, I accidently clicked on the color palette icon on the extreme right end in the hope of getting some colors, but instead, I got the rich text editing buttons in the editor! The so called color palette was called the Kitchen sink. Duh! How ignorant of me. Thank you Almighty, for delivering me from ignorance.

So this is how it looked now:

Life was beautiful now…

I could do different kind of formatting, underlining, paste from word, erase, indenting, undo, redo, heading, color change etc.

Hope you find this useful too. Do leave me a message if you do.

An assessment of CiviCRM for non-profits

Introduction

Lately, we have been evaluating open source CRM softwares that are available in the market. Remarkably speaking, the CRM software market seems to really on the move with SugarCRM and CiviCRM being some of the most popular and widely used open source softwares.

Our Requirements in a nutshell

We are a small non profit service organization and have the need of maintaining contacts ( volunteers, donors, media contacts, partner organizations, NGOs etc), accounting/donor/fund raising information and potentially a document knowledge base and project management/event planning functionality. In addition, we needed mass personalized mailing functionality as well and an ability to define internal hierarchy or relationship between volunteers or organizations.

Till now, we were maintaining all our information in Yahoo! groups Files section or not even that in some cases. Contacts were kept in different forms, most of the times misplaced and rarely followed up on properly. Out of sight is out of mind and thats what happened.

CiviCRM

Well, I was looking at online articles and blogs about similar non-profit organizations who may implemented open source CRM softwares, and that’s when I came to know about Civicrm. I spent about a day installing it on Drupal 5.x (civicrm 2.0 does not work with Drupal 6.x yet) and exploring it.

The scope of this article is limited to CiviCRM and observations around it. But as all things, there is good news and there is bad news. Let me start with the good news.

Good features:

1) The GUI is quite simple and intuitive for administrators. Most of the features and projected functionality can be figured out easily.

2) Contact management and defining different kinds of relationships is simple. You can define relationships between individuals, groups and organizations, which is quite extensible. For a contact, you can define associated grants, notes, meetings, groups, memberships, relationships, mails etc, kind of like a central view.

3) Contribute and Grants module are good for Integration with online payment system like Googlc checking or Paypal and for tracking and pre-scheduling donations

4) CiviMail can do personalized mailings. Attachments dont seem to be possible (at least I could not see it work). Messages can be tracked etc, but the reporting interface does not compare with SugarCRM (more evolved). For actually triggering the mail delivery a cron job has to be run and for bounce processing, some extra unix utilies (e.g. AMaViS,postfix) have to be configured

5) Customization to current forms or tables is easy. When we upgrade to a newer version of CiviCRM, the Custom Data Fields and Custom Data Groups will be maintained. Specialized customizations using the PHP programming language will need to be re-created when you upgrade, however.

6) The data model is simpler and easy to understand. The entity relationship diagram is available at
http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+ERD+2.0

7) It has a planner features too — activities, meetings etc (types can be defined).

8) Good user integration/sync with Drupal and Joomla

9) Although there is no menu link for CiviReports, the reports are available through http://wiki.civicrm.org/confluence/display/CRMDOC/CiviReport. There are a lot of sql queries also that are available online on wiki.civicrm.org

Some other features — but not essential for us:

1) CiviEvent is useful for putting signup pages for events. I thought it was kind of interesting though. Its good for promoting events and signing up people into your contact database.

2) CiviMember module can be used for tracking memberships to the organization (e.g. lifemember, goldmember etc). We did not need this functionality as we do not charge anything for membership, but it could be used at some point of time.

3) Can Configure Google or Yahoo Maps to work with CiviCRM. This is actually kind of cool. I always wanted to implement something like for our website wherein a project’s location in the world could be shown through yahoo or google map.

4) The CitizenSpeak module allows the creation of email petition campaign nodes. Users enter the email recipients and the a message to create a campaign. When someone visits the node, they see a form that displays a preview of the message and allows them to enter their contact information and a personal statement. When they submit the form, the target of the campaign is notified. The version currently in CVS is built against Drupal 4.6. (http://drupal.org/project/citizenspeak)

Features lacking:

1) project Management — This feature is present in sugarcrm Community Edition and we though we could use it for managing events (their tasks) and sharing event templates between chapters

2) Document management — This feature would have been done to implement a knowledge base system for our volunteers and organization in general.

3) Can’t create a new module through GUI, but APIs are published.

4) Leads and Opportunity Management are not present and not differentiated

Some Interesting Facts:

Amnesty International uses CiviCRM to collect website registration data and process online donations

Overall thoughts

I felt that the civicrm product is in initial stages and will see a lot of change or value addition in the near future. There are a lot of things coming and they will come slowly. From the http://civicrm.org/architecture, I could see that there was already talk of more performance or caching features in 2.1 version.

All in all, It still has some ways to go before it can catch up with sugarCRM. But then, civicrm is focused exclusively on non-profit organizations and is designed for them. It will have its own growth path: one that would may be less spectacular than sugarcrm for a little while, but it sure packs a lot of potential in it.

Sharing windows folders on unix hosts using samba filesystem (smbfs) using virtualbox

The need for windows sharing..

A few days ago, I wanted to do a Oracle 12i installation on a x86 linux distribution using virtualbox. The media was available on an external hard disk, but I thought that instead of copying the 30+ G of media on unix virtual machine, why not just make it shared between the windows host OS and unix guest OS.

The quest for sharing..

And so began my quest for sharing files between windows and virtualbox unix OS (SuSE linux). I discovered that for sharing folders using virtualbox, the guest OS additions have to be installed.

I have seen that upgrading the kernel breaks the guest OS additions at times. After upgrading the guest OS from SuSE linux 9 to SuSE linux 9.3, the guest additions stopped working. The same problem also exists with vmware tools.

So first, I created a shared folder in the virtual machine’s definition:

Click here for a bigger view

After starting the Guest OS (Ubuntu),

root@gverma-laptop:/home/gverma# mkdir /mnt/winshare

root@gverma-laptop:/home/gverma# mount -t vboxsf public /mnt/winshare

Mind you, the filesystem type is NOT vboxfs, it is vboxsf (s and f are interchanged). If you do not take note of this, you might end up wasting your time for nothing.

Now, we can check that the shared folder did indeed mount:

root@gverma-laptop:/home/gverma# mount | grep vbox
public on /mnt/winshare type vboxsf (rw)

root@gverma-laptop:/home/gverma# ls /mnt/winshare
CyberLink  desktop.ini  Downloads  Music     Recorded TV         Videos
Desktop    Documents    Favorites  Pictures  StarzEntertainment  Vongo

Let it be mentioned here that the vboxadd and vboxvfs (note that it has vfs after vbox) modules needed to be loaded for this to work:

root@gverma-laptop:/home/gverma# lsmod | grep vb
vboxvfs                 42432  1
vboxadd                 24872  9 vboxvfs

The Caveat..

But, as every cloud has a silver lining, there was a caveat here for my problem.

The above case was just a demonstration of how the shared folder could have worked fine. I actually then went on to mount some linux media for Oracle Applications 12i for x86 intel platform. After the directory mounted all right, I had a really hard time adding the execute permissions to the rapidwiz files. Even after doing persistent # chmod -R +x commands, the shell scripts under the media were not showing the “x” execute flag.

This was very frustrating. It was probably just another virtualbox bug.

So, then I started looking around for more options. I had heard that many people had used samba with success and hence I started scouring the internet (Google Zindabaad! – Long live, Google!). Came across a link that explained how to do it in a succinct manner.

The good thing about sharing files from windows to unix using samba file system (smbfs) was that was that I did not need to run samba on unix at all.

Doing it using samba filesystem..

So here are some quick and easy steps for sharing a windows share using smbfs:

First things first. You need to create a network share for the folder that you want to share. In my case, I wanted to share an external hard disk that had the media for Oracle Applications 12i. So, I did a network share of windows folder (e.g. \\GAURAV-PC\media)

On the guest OS (Ubuntu), did the following:

# mkdir -p /mnt/media

# smbmount //GAURAV-PC/media /mnt/media -o username=gaurav,password=welcome

Please note that // (forward slashes) worked for me. Some guides on the internet say that you need to use \\ (back slashes)

Note here that GAURAV-PC hostname was defined in the local hosts file to a resolvable IP address in the LAN. The Ubuntu Virtual machine was connected to the windows Host through a host only networking type interface, that allowed the host and guest OS to talk to each other.

# more /etc/hosts
GAURAV-PC 192.168.0.2

Please note here that a ping to GAURAV-PC HAS TO work when you give the smbmount command. I wasted many hours trying to run strace on this command, just because it was hanging. The issue was that due to some strange happenstance, the ping to GAURAV-PC (windows host) was hanging.

The workaround was to ping the Ubuntu virtual machine (say 192.168.0.7) first from the host OS (windows), after which the ping to GAURAV-PC 192.168.0.2 started working from Ubuntu Guest OS. Strange, strange, I agree, but I am just a guy looking for solutions! I have seen this behaviour in Windows Vista home premium edition – host OS.

Make sure the smbfs module is loaded in the guest OS. If not, then load it using # modprobe smbfs:

root@gverma-laptop:/mnt/media/oracle_12.0.4/startCD/Disk1/rapidwiz# lsmod | grep smbfs
smbfs                  66296  0

Note that the Samba server does not need to run:

root@gverma-laptop:/mnt/media/oracle_12.0.4/startCD/Disk1/rapidwiz# ps -ef | grep smb
root      6116  5616  0 00:00:00 grep smb

This was my samba configuration file:

root@gverma-laptop:/mnt/media/oracle_12.0.4/startCD/Disk1/rapidwiz# more /usr/share/samba/smb.conf
[global]
workgroup = WORKGROUP
security = share
usershare path =  /var/lib/samba/usershare
usershare max shares = 100
usershare allow guests = yes
usershare owner only = yes
wins support = no
netbios name = GAURAV-PC

I am not exactly sure if setting the netbios name parameter was a major factor in making it work or not, but I guess it certainly did not hurt.

Now when I run mount command, the windows network share was showing up there just fine:

root@gverma-laptop:/mnt/media/oracle_12.0.4/startCD/Disk1/rapidwiz# mount
/dev/sda1 on / type ext3 (rw,relatime,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
/sys on /sys type sysfs (rw,noexec,nosuid,nodev)
varrun on /var/run type tmpfs (rw,noexec,nosuid,nodev,mode=0755)
varlock on /var/lock type tmpfs (rw,noexec,nosuid,nodev,mode=1777)
udev on /dev type tmpfs (rw,mode=0755)
devshm on /dev/shm type tmpfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
lrm on /lib/modules/2.6.24-16-generic/volatile type tmpfs (rw)
securityfs on /sys/kernel/security type securityfs (rw)
rpc_pipefs on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
nfsd on /proc/fs/nfsd type nfsd (rw)
gvfs-fuse-daemon on /home/gverma/.gvfs type  fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=gverma)
//GAURAV-PC/media on /mnt/media type cifs (rw,mand)

Thankfully, I was able to make the unix shell scripts executable after doing this and launch the rapid wizard for 12i installation. That’s all I wanted.

Conclusion

Well, so there you have it. If you are using windows host OS and you upgraded your guest OS kernel, the guest additions may not work due to compilation errors. In such a case, you are better off using the samba file system as its much easier to deal with and not too much of a pain to setup.

A poor man’s guide for creating iscsi targets without using external USB hard disks

A special need..

Those of you who have a need for exposing iscsi targets to other machines for discovery, but who do not want to invest in an external USB hard disk OR who do not want to have a USB external hard disk connected to a desktop 24×7, there is a better way of creating and exposing iscsi target logical volumes.

This method does not need installing openfiler either as noted in my earlier article Combining Openfiler and Virtualbox (Ubuntu guest OS on windows host).

A simple solution..

The method is simple: create logical volumes based on SCSI devices on a Ubuntu Hardy Heron 8.04 installation using virtualbox.

The advantage of using Ubuntu is that it creates the hard disk devices as scsi devices (with the naming convention /dev/sd*, instead of /dev/hd*). I have seen that in other unix OS like SuSE linux, the local disks are listed as /dev/hd* (IDE). Ubuntu seems to have better disk drivers.

If you use Hardy Heron 8.04 Ubuntu, it is *really* easy to get iscsitarget package working. If you try to make the iscsi-target package work with Gutsy Gibbon 7.x release of Ubuntu, there is a very good chance that you will run into lot of compilation issues. I went down this path myself and later realized that a lot of bugs existed for Gutsy Gibbon release. (e.g. https://bugs.launchpad.net/ubuntu/gutsy/+source/iscsitarget/+bug/160104, http://ubuntuforums.org/showthread.php?t=692651) and eventually found https://bugs.launchpad.net/ubuntu/+source/iscsitarget/+bug/145539 which said that the module was fixed in Hardy Heron 8.04.

So instead of breaking my head over making iscsi-target package work in Gutsy Gibbon 2.6.22, I decided to give Hardy Heron 8.04 (still beta) a try.

Thankfully, with a little effort, I was able to make it work. In this article, I present a simplistic scenario in which we create three logical volumes that can be easily discovered by another virtualbox iscsi initiator machine(s) using open-iscsi package. This is the beauty of the entire approach.

Here is a block diagram of the end configuration:

Click here for a bigger view

Iscsi support in Hardy Heron 8.04 Ubuntu..

The first thing to understand is that as per the published features of Hardy Heron 8.04 Ubuntu at https://wiki.ubuntu.com/HardyHeron/Beta#head-da07b62e1e43afd0bef06ab8b60d2502c734a0f9, the iscsi support is enabled out of the box if we add iscsi=true in the boot options during the installation.

Click here for a bigger view

While installing Hardy 8.04 OS using virtualbox or any other virtualization software being used, remember to add iscsi=true in the boot options (after pressing F6)

Click here for a bigger view

Configuring iscsi targets..

I would like to give credit to a really awesome link I found through google: http://www.linuxconfig.org/Linux_lvm_-_Logical_Volume_Manager, which I rate as a one of the best article s for doing this!

Some other relevant links are:

https://help.ubuntu.com/community/SettingUpLVM-WithoutACleanInstall
http://t3flyers.wordpress.com/2007/04/24/logical-volume-manager-on-ubuntu-feisty-704/
http://www.howtoforge.com/linux_lvm

After Ubuntu installation, the output of uname -a looks like this:

HARDY# uname -a
Linux gverma-laptop 2.6.24-16-generic #1 SMP Thu Apr 10 13:23:42 UTC 2008 i686 GNU/Linux

And the output of fdisk -l looks like this:

HARDY# fdisk -l

Disk /dev/sda: 16.5 GB, 16592666624 bytes
255 heads, 63 sectors/track, 2017 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0004ccc2
Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        1927    15478596   83  Linux
/dev/sda2            1928        2017      722925    5  Extended
/dev/sda5            1928        2017      722893+  82  Linux swap / Solaris

At this point, I added two more hard disks to the virtualbox virtual machine. Virtualbox 1.5.6 allows upto three hard disk devices to be attached to a machine.

Click here for a bigger view

After booting up HARDY again, /dev/sdb and /dev/sdc were also visible in the output of fdisk -l. Using fdisk, I created a single partition in both devices that spanned the entire device, resulting in /dev/sdb1 and /dev/sdc1:

HARDY# fdisk -l

...
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xd310045f

Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        2610    20964793+  83  Linux

Disk /dev/sdc: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x93d4c692

Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1        2610    20964793+  83  Linux

Also make sure that you configure host only networking so that other virtual machines (scsi initiators) are able to ssh/telnet into HARDY. Please look at article to understand how host only networking can be setup: Virtualbox Case Study: Making host only networking work between two Ubuntu Guest OS (virtual machine) on Windows Vista host

Getting the right packages installed..

Now, we need to create the target physical volume, virtual group, and logical volume, in that order. These logical volumes will serve as SCSI targets that can be discovered by other iscsi initiator machines or virtual machines as per your configuration.

Make sure you reload the package definitions from the configured repositories (get the latest packages that are published from the ubuntu repositories). You can do this from the Synaptic Package Manager:

Click here for a bigger view

Now, you should install the lvm2 package in Synaptic Package Manager:

Click here for a bigger view

Create the physical volumes:

HARDY# lvm

lvm> pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created
lvm> pvcreate /dev/sdc1
Physical volume "/dev/sdc1" successfully created
lvm> pvdisplay
--- NEW Physical volume ---
PV Name               /dev/sdb1
VG Name
PV Size               19.99 GB
Allocatable           NO
PE Size (KByte)       0
Total PE              0
Free PE               0
Allocated PE          0
PV UUID               OHKhOq-AMG7-XtYz-7CrP-q2VH-2b53-tW0yMO

--- NEW Physical volume ---
PV Name               /dev/sdc1
VG Name
PV Size               19.99 GB
Allocatable           NO
PE Size (KByte)       0
Total PE              0
Free PE               0
Allocated PE          0
PV UUID               M9qXXB-GVxC-FZjI-9Zb7-IhcH-rbhb-vQ3aek

Create the virtual group:

lvm> vgcreate vg /dev/sdb1 /dev/sdc1
Volume group "vg" successfully created
lvm> vgdisplay
--- Volume group ---
VG Name               vg
System ID
Format                lvm2
Metadata Areas        2
Metadata Sequence No  1
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                0
Open LV               0
Max PV                0
Cur PV                2
Act PV                2
VG Size               39.98 GB
PE Size               4.00 MB
Total PE              10236
Alloc PE / Size       0 / 0
Free  PE / Size       10236 / 39.98 GB
VG UUID               GkUMNq-3atR-qKTK-lG0b-gM0n-budV-Uc4lH8

lvm>

Create logial volumes:

lvm> lvcreate -L 1G -n ocr vg
Logical volume "ocr" created
lvm> lvcreate -L 1G -n vote vg
Logical volume "vote" created
lvm> lvcreate -L 35G -n asm vg
Logical volume "asm" created

If you get an error message saying:
/proc/misc: No entry for device-mapper
you can get around it by issuing sudo modprobe dm-mod

lvm> lvdisplay
--- Logical volume ---
LV Name                /dev/vg/ocr
VG Name                vg
LV UUID                a2ARIQ-11dn-kdoB-cHCd-gtoR-aokO-HGqoo4
LV Write Access        read/write
LV Status              available
# open                 0
LV Size                1.00 GB
Current LE             256
Segments               1
Allocation             inherit
Read ahead sectors     0
Block device           254:0

--- Logical volume ---
LV Name                /dev/vg/vote
VG Name                vg
LV UUID                1DqYL0-Ptsx-9kmE-UHmn-PmE9-ebVm-bfr0r0
LV Write Access        read/write
LV Status              available
# open                 0
LV Size                1.00 GB
Current LE             256
Segments               1
Allocation             inherit
Read ahead sectors     0
Block device           254:1

--- Logical volume ---
LV Name                /dev/vg/asm
VG Name                vg
LV UUID                UKWcPz-aNGl-VdPm-51wa-Ewvm-ahvD-Y7N57v
LV Write Access        read/write
LV Status              available
# open                 0
LV Size                35.00 GB
Current LE             8960
Segments               2
Allocation             inherit
Read ahead sectors     0
Block device           254:2

lvm>

Now, you can check the logical volume devices like this:

HARDY# ls -l /dev/vg
total 0
lrwxrwxrwx 1 root root 18 2008-05-03 02:42 asm -> /dev/mapper/vg-asm
lrwxrwxrwx 1 root root 18 2008-05-03 02:41 ocr -> /dev/mapper/vg-ocr
lrwxrwxrwx 1 root root 19 2008-05-03 02:41 vote -> /dev/mapper/vg-vote

You can also check the newly created devices in the /dev/disk/* directories on HARDY:

HARDY# ls -l /dev/disk/*
/dev/disk/by-id:
..
lrwxrwxrwx 1 root root 19 2008-05-03 02:42 dm-name-vg-asm -> ../../mapper/vg-asm
lrwxrwxrwx 1 root root 19 2008-05-03 02:41 dm-name-vg-ocr -> ../../mapper/vg-ocr
lrwxrwxrwx 1 root root 20 2008-05-03 02:41 dm-name-vg-vote -> ../../mapper/vg-vote
..

/dev/disk/by-path:
total 0
lrwxrwxrwx 1 root root  9 2008-05-02 22:30 pci-0000:00:01.1-scsi-0:0:1:0 -> ../../sdb
lrwxrwxrwx 1 root root 10 2008-05-03 02:34 pci-0000:00:01.1-scsi-0:0:1:0-part1 -> ../../sdb1
lrwxrwxrwx 1 root root  9 2008-05-02 22:30 pci-0000:00:01.1-scsi-1:0:1:0 -> ../../sdc
lrwxrwxrwx 1 root root 10 2008-05-03 02:35 pci-0000:00:01.1-scsi-1:0:1:0-part1 -> ../../sdc1

You need to install the iscsitarget package using Synaptic Package Manager:

Click here for a bigger view

Now, you need to configure the /etc/ietd.conf file with the Target names and entries for each logical volume. The target names just need to unique within the network and are totally upto your imagination.

HARDY# more /etc/ietd.conf
Target iqn.2001-04.com.ubuntu:scsi.disk.vg.vote
Lun 0 Path=/dev/vg/vote,Type=fileio
Target iqn.2001-04.com.ubuntu:scsi.disk.vg.ocr
Lun 0 Path=/dev/vg/ocr,Type=fileio
Target iqn.2001-04.com.ubuntu:scsi.disk.vg.asm
Lun 0 Path=/dev/vg/asm,Type=fileio

To enforce these entries, we need to restart the iscsitarget service manually now.

Keep in mind that there is no dash (-) between iscsi and target in the name of the service, as in openfiler 2.2 (openfiler’s IET implementation service has the name iscsi-target)

HARDY# /etc/init.d/iscsitarget restart
Removing iSCSI enterprise target devices: succeeded.
Stopping iSCSI enterprise target service: succeeded.
Removing iSCSI enterprise target modules: succeeded.
Starting iSCSI enterprise target service: succeeded.

To double check if the logical volumes have been discovered and published, you can check content of /proc/net/iet/volume on HARDY:

::::::::::::::
/proc/net/iet/volume
::::::::::::::
tid:3 name:iqn.2001-04.com.ubuntu:scsi.disk.vg.asm
lun:0 state:0 iotype:fileio iomode:wt path:/dev/vg/asm
tid:2 name:iqn.2001-04.com.ubuntu:scsi.disk.vg.ocr
lun:0 state:0 iotype:fileio iomode:wt path:/dev/vg/ocr
tid:1 name:iqn.2001-04.com.ubuntu:scsi.disk.vg.vote
lun:0 state:0 iotype:fileio iomode:wt path:/dev/vg/vote

If you do a more of /proc/net/iet/session, you can clearly see that no iscsi-initiator machine have connected to HARDY yet (there are no session sub-entries under the volume name):

HARDY# more /proc/net/iet/session
tid:3 name:iqn.2001-04.com.ubuntu:scsi.disk.vg.asm
tid:2 name:iqn.2001-04.com.ubuntu:scsi.disk.vg.ocr
tid:1 name:iqn.2001-04.com.ubuntu:scsi.disk.vg.vote

Here is a quick check of the physical volume, volume group, and logical volume :

HARDY# lvm
lvm> lvscan
ACTIVE ‘/dev/vg/ocr’ [1.00 GB] inherit
ACTIVE ‘/dev/vg/vote’ [1.00 GB] inherit
ACTIVE ‘/dev/vg/asm’ [35.00 GB] inherit

lvm> pvscan
PV /dev/sdb1 VG vg lvm2 [19.99 GB / 0 free]
PV /dev/sdc1 VG vg lvm2 [19.99 GB / 2.98 GB free]
Total: 2 [39.98 GB] / in use: 2 [39.98 GB] / in no VG: 0 [0 ]

lvm> vgscan
Reading all physical volumes. This may take a while…
Found volume group “vg” using metadata type lvm2
lvm>

Discovering the iscsi targets from another iscsi initiator machine..

We will assume that the iscsi initiator machine name is GUTSY and it has the open-iscsi package installed (this also installs iscsiadm utility along with it). We will also assume that the IP of HARDY (iscsi target) is 192.168.0.7.

You can leave the majority default values in /etc/iscsi.conf. Make sure you disable the CHAP authentication parameter values since we have not configured them in the scsi target.

Discover the new iscsi targets in HARDY:

GUTSY# iscsiadm -m discovery -t st -p 192.168.0.7
192.168.0.7:3260,1 iqn.2001-04.com.ubuntu:scsi.disk.vg.asm
192.168.0.7:3260,1 iqn.2001-04.com.ubuntu:scsi.disk.vg.ocr
192.168.0.7:3260,1 iqn.2001-04.com.ubuntu:scsi.disk.vg.vote

Verify the newly discovered target machine:

GUTSY# sudo iscsiadm -m discovery
192.168.0.6:3260 via sendtargets
192.168.0.7:3260 via sendtargets  --> the new iscsi target got added to the local database

Check the combination of discovered iscsi-target and logical volumes (the new ones are in BLUE color):

GUTSY# sudo iscsiadm -m node
192.168.0.6:3260,1 iqn.2006-01.com.openfiler:openfiler.ocr
192.168.0.6:3260,1 iqn.2006-01.com.openfiler:openfiler.vote
192.168.0.6:3260,1 iqn.2006-01.com.openfiler:openfiler.asm
192.168.0.7:3260,1 iqn.2001-04.com.ubuntu:scsi.disk.vg.asm
192.168.0.7:3260,1 iqn.2001-04.com.ubuntu:scsi.disk.vg.ocr
192.168.0.7:3260,1 iqn.2001-04.com.ubuntu:scsi.disk.vg.vote

But, at this point, we have no active sessions connected to these targets:

GUTSY# iscsiadm -m session
iscsiadm: No active sessions.

Establish connection to the scsi targets from the initiator:

GUTSY# iscsiadm -m node \
-T iqn.2001-04.com.ubuntu:scsi.disk.vg.asm \
-p 192.168.0.7 -l
Login session [iface: default, target: iqn.2001-04.com.ubuntu:scsi.disk.vg.asm, portal: 192.168.0.7,3260]
GUTSY# iscsiadm -m node \
-T iqn.2001-04.com.ubuntu:scsi.disk.vg.vote \
-p 192.168.0.7 -l
Login session [iface: default, target: iqn.2001-04.com.ubuntu:scsi.disk.vg.vote, portal: 192.168.0.7,3260]
GUTSY# iscsiadm -m node \
-T iqn.2001-04.com.ubuntu:scsi.disk.vg.ocr \
-p 192.168.0.7 -l
Login session [iface: default, target: iqn.2001-04.com.ubuntu:scsi.disk.vg.ocr, portal: 192.168.0.7,3260]

Verify the newly formed connections:

GUTSY# iscsiadm -m session
tcp: [1] 192.168.0.7:3260,1 iqn.2001-04.com.ubuntu:scsi.disk.vg.asm
tcp: [2] 192.168.0.7:3260,1 iqn.2001-04.com.ubuntu:scsi.disk.vg.vote
tcp: [3] 192.168.0.7:3260,1 iqn.2001-04.com.ubuntu:scsi.disk.vg.ocr

It would be useful to enable automatic startup/discovery of these volumes on server and client. For this, you need to do the following:

  • On server(where the logical volumes are created):
HARDY# sudo gedit /etc/iscsi/iscsid.conf

Change node.startup=manual to: node.startup = Automatic

GUTSY# sudo /etc/init.d/open-iscsi restart
  • On client
GUTSY# sudo iscsiadm -m discovery -t st -p <ipaddress>
GUTSY# sudo iscsiadm -m node
-T iqn.2001-04.com.ubuntu:scsi.disk.vg.asm
-p <ipaddress> -o update
-n node.conn[0].startup -v automatic
GUTSY# sudo /etc/init.d/open-iscsi restart
  • or reboot both the systems if required (make sure server boots first). To check if the scsi devices are automatically setup and list all your scsi iqns:
GUTSY # sudo iscsiadm -m session

Now assumed that the TCP scsi connections have been formed, let us check if the scsi devices are visible from fdisk -l:

GUTSY# fdisk -l

..
Disk /dev/sdb: 37.5 GB, 37580963840 bytes
64 heads, 32 sectors/track, 35840 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Disk identifier: 0x00000000

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/sdc: 1073 MB, 1073741824 bytes
34 heads, 61 sectors/track, 1011 cylinders
Units = cylinders of 2074 * 512 = 1061888 bytes
Disk identifier: 0x00000000

Disk /dev/sdc doesn't contain a valid partition table

Disk /dev/sdd: 1073 MB, 1073741824 bytes
34 heads, 61 sectors/track, 1011 cylinders
Units = cylinders of 2074 * 512 = 1061888 bytes
Disk identifier: 0x00000000

Disk /dev/sdd doesn't contain a valid partition table
GUTSY#

The newly discovered devices can also be checked under the contents of /dev/disk/*:

GUTSY# ls -l /dev/disk/*
/dev/disk/by-id:
total 0
..
lrwxrwxrwx 1 root root  9 2008-05-02 23:05 scsi-149455400000000000000000001000000795600000e000000 -> ../../sdc
lrwxrwxrwx 1 root root  9 2008-05-02 23:05 scsi-1494554000000000000000000020000004f5600000e000000 -> ../../sdd
lrwxrwxrwx 1 root root  9 2008-05-02 23:05 scsi-149455400000000000000000003000000a45600000e000000 -> ../../sdb
..

/dev/disk/by-path:
total 0
lrwxrwxrwx 1 root root  9 2008-05-02 23:05 ip-192.168.0.7:3260-iscsi-iqn.2001-04.com.ubuntu:scsi.disk.vg.asm-lun-0 -> ../../sdb
lrwxrwxrwx 1 root root  9 2008-05-02 23:05 ip-192.168.0.7:3260-iscsi-iqn.2001-04.com.ubuntu:scsi.disk.vg.ocr-lun-0 -> ../../sdd
lrwxrwxrwx 1 root root  9 2008-05-02 23:05 ip-192.168.0.7:3260-iscsi-iqn.2001-04.com.ubuntu:scsi.disk.vg.vote-lun-0 -> ../../sdc
..

Relevant messages in the system log of scsi initiator (GUTSY)

# dmesg
...
[ 1156.290868] scsi2 : iSCSI Initiator over TCP/IP
[ 1156.607026] scsi 2:0:0:0: Direct-Access     IET      VIRTUAL-DISK     0    PQ: 0 ANSI: 4
[ 1156.607026] sd 2:0:0:0: [sdb] 73400320 512-byte hardware sectors (37581 MB)
[ 1156.607026] sd 2:0:0:0: [sdb] Write Protect is off
[ 1156.607026] sd 2:0:0:0: [sdb] Mode Sense: 77 00 00 08
[ 1156.607026] sd 2:0:0:0: [sdb] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[ 1156.607111] sd 2:0:0:0: [sdb] 73400320 512-byte hardware sectors (37581 MB)
[ 1156.608275] sd 2:0:0:0: [sdb] Write Protect is off
[ 1156.608293] sd 2:0:0:0: [sdb] Mode Sense: 77 00 00 08
[ 1156.610635] sd 2:0:0:0: [sdb] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[ 1156.610665]  sdb: unknown partition table
[ 1156.619320] sd 2:0:0:0: [sdb] Attached SCSI disk
[ 1156.619398] sd 2:0:0:0: Attached scsi generic sg2 type 0
[ 1163.865083] scsi3 : iSCSI Initiator over TCP/IP
[ 1164.132972] scsi 3:0:0:0: Direct-Access     IET      VIRTUAL-DISK     0    PQ: 0 ANSI: 4
[ 1164.135287] sd 3:0:0:0: [sdc] 2097152 512-byte hardware sectors (1074 MB)
[ 1164.136424] sd 3:0:0:0: [sdc] Write Protect is off
[ 1164.136438] sd 3:0:0:0: [sdc] Mode Sense: 77 00 00 08
[ 1164.138002] sd 3:0:0:0: [sdc] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[ 1164.140341] sd 3:0:0:0: [sdc] 2097152 512-byte hardware sectors (1074 MB)
[ 1164.141443] sd 3:0:0:0: [sdc] Write Protect is off
[ 1164.141460] sd 3:0:0:0: [sdc] Mode Sense: 77 00 00 08
[ 1164.144746] sd 3:0:0:0: [sdc] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[ 1164.144809]  sdc: unknown partition table
[ 1164.154241] sd 3:0:0:0: [sdc] Attached SCSI disk
[ 1164.154290] sd 3:0:0:0: Attached scsi generic sg3 type 0
[ 1170.533158] scsi4 : iSCSI Initiator over TCP/IP
[ 1170.798343] scsi 4:0:0:0: Direct-Access     IET      VIRTUAL-DISK     0    PQ: 0 ANSI: 4
[ 1170.798343] sd 4:0:0:0: [sdd] 2097152 512-byte hardware sectors (1074 MB)
[ 1170.801229] sd 4:0:0:0: [sdd] Write Protect is off
[ 1170.801263] sd 4:0:0:0: [sdd] Mode Sense: 77 00 00 08
[ 1170.806093] sd 4:0:0:0: [sdd] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[ 1170.809875] sd 4:0:0:0: [sdd] 2097152 512-byte hardware sectors (1074 MB)
[ 1170.812347] sd 4:0:0:0: [sdd] Write Protect is off
[ 1170.812380] sd 4:0:0:0: [sdd] Mode Sense: 77 00 00 08
[ 1170.816757] sd 4:0:0:0: [sdd] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[ 1170.816757]  sdd: unknown partition table
[ 1170.828375] sd 4:0:0:0: [sdd] Attached SCSI disk
[ 1170.828446] sd 4:0:0:0: Attached scsi generic sg4 type 0

Cross checking incoming sessions at scsi target (HARDY)..

In the meanwhile, in HARDY, the incoming sessions can be checked by:

HARDY# more /proc/net/iet/*
::::::::::::::
/proc/net/iet/session
::::::::::::::
tid:3 name:iqn.2001-04.com.ubuntu:scsi.disk.vg.asm
sid:281474997486080 initiator:iqn.1993-08.org.debian:01:950a218cdd1
cid:0 ip:192.168.0.6 state:active hd:none dd:none
tid:2 name:iqn.2001-04.com.ubuntu:scsi.disk.vg.ocr
sid:844424984461824 initiator:iqn.1993-08.org.debian:01:950a218cdd1
cid:0 ip:192.168.0.6 state:active hd:none dd:none
tid:1 name:iqn.2001-04.com.ubuntu:scsi.disk.vg.vote
sid:562949990973952 initiator:iqn.1993-08.org.debian:01:950a218cdd1
cid:0 ip:192.168.0.6 state:active hd:none dd:none
::::::::::::::
/proc/net/iet/volume
::::::::::::::
tid:3 name:iqn.2001-04.com.ubuntu:scsi.disk.vg.asm
lun:0 state:0 iotype:fileio iomode:wt path:/dev/vg/asm
tid:2 name:iqn.2001-04.com.ubuntu:scsi.disk.vg.ocr
lun:0 state:0 iotype:fileio iomode:wt path:/dev/vg/ocr
tid:1 name:iqn.2001-04.com.ubuntu:scsi.disk.vg.vote
lun:0 state:0 iotype:fileio iomode:wt path:/dev/vg/vote
root@gverma-laptop:/home/gverma#

Conclusion..

Congratulations! You have been successful in creating a poor man’s scsi target and discovered them using open source softwares in an easy manner. Now GUTSY can read/write to /dev/vg/asm etc logical volumes. For more machines to do the same thing, similar setup is needed on them and they should also be access these volumes in a clustered fashion. This kind of setup is most beneficial for creating your own Oracle 10g RAC sandbox environment or for doing installs over shared disk.

In this case, we did not format the discovered logical volumes in ext3 or OCFS2 file system, because it is assumed that these volumes will be used as raw devices only.

Read more »

Creating your own 10g RAC cluster at home using virtualbox and SAN targets (using openfiler + with/without USB hard disk)

Preface

After playing around with some open source technologies like virtualbox and openfiler, we are finally at a point when it is possible to create your own network lab of Oracle 10gR2 RAC cluster and ASM database using iscsi targets in an external hard disk drive. The last time I checked, USB 2.0 hard disk drives are cheaply available in the market.

If you do not want to use an external USB hard disk, then please go through the article A poor man’s guide for creating iscsi targets without using external USB hard disks

All it takes is a little persistence and willingness to follow easy to follow tutorials. In the previous articles on this blog, I have talked about the building blocks of using virtualbox and openfiler open source softwares. If we combine that knowledge with Oracle 10g RAC setup, the following end configuration can be achieved:

Click here for a bigger view

The building blocks..

The operating system

First of all, you need to install a linux distribution of your choice using virtualbox. In this example, I chose SuSE linux 9.3. I feel that SuSE linux will be embraced by more and more enterprises in the near future, hence this decision.

For doing the installation, just boot from the Linux install media CD and then keep switching CDs as per request of the install process. It is always better if you have an ISO file of the installable media. You can get the SuSE media from www.opensuse.org

Always keep a decent amount of swap space for the OS installation. Also it is better to have a /tmp mount point as a separate mount point from the root (/) partition. These are some evergreen tips that a sysadmin friend of mine (Erik Niklas) had suggested to me a long time back.

A word of caution while deciding the VDI disk size for virtualbox machine (especially relevant for Version 1.5.6). The virtualbox disks cannot be resized!!

The dynamically expanding option means that the disk can grow UPTO the maximum limit and it will grow as per usage till the maximum limit. After that, it is not possible to resize it using some Vbox utility.A workaround may be to copy the device using partition editors, but till virtualbox comes out with an enhancement on this feature, better to be safe than sorry and keep a very high disk size – as per your judgement.

For building a Oracle 10g RAC configuration, it is better to focus all your installation efforts on one virtual machine and then clone the virtualbox disks (including the bootable disk) using the VboxManage clonevdi command. This way, you save a lot of duplicate effort.

The networking configuration – Public and Private IPs

The other networking building blocks of this configuration can be achieved by the following:

1) RAC needs a public IP, which is usually (but not limited to) eth0. It is advantageous to configure the public IP as host only networking interface when using virtualbox because it gives you the dual advantage of being able to SSH into the machine from outside (e.g. other rac node or another machine on the LAN) and also make internet work.

I tried to keep this as a static IP, but the downside is that the default gateway was somehow not working for me. However, if I kept this as DHCP interface, the default gateway and nameservers were being accessible out of the box.

A detailed example of how to do this is shown in the article Virtualbox Case Study: Making host only networking work between two Ubuntu Guest OS (virtual machine) on Windows Vista host

2) A RAC setup also needs a private network between the RAC nodes for global communication system (GCS) and synchronization. This is also usually referred to as the private interconnects. This is usually configured on a private subnet like 10.10.x.x or 192.168.x.x, wherein other network traffic would not impinge on the sacrosanct synchronization traffic between the RAC nodes.

A detailed example of how to do this is shown in the article Case study: Making Internal networking for talking between two linux guest OS (Ubuntu) on windows vista host

The Network Attached Storage or Storage Area Network setup..

NAS is hot! Well, what i mean is that its like configure once, use everywhere kind of thing. You setup iSCSI target logical volumes and then discover and access them from other machines. There are packages like linux-iscsi and open-iscsi which will help you do that. As per the latest announcements, both these open source projects have been merged into open-iscsi now.

Why should we choose Ubuntu for hard disk drivers? The partitions from a /dev/sd* devices gets discovered as separate devices, whereas all partitions in /dev/hd* get discovered as a single device.

There are quite promising open source softwares in this area too. openfiler and freenas are a few of them. For no particular reason, I picked openfiler and did a few experiments for discovering iscsi targets using it.

A detailed example of how to do this has been shown in the article Case Study: How to discover iscsi targets with linux-iscsi initiator package — Suse linux 9 (scsi Initiator) and openfiler (scsi target)

If you are using USB external hard disks for this exercise, there are many gotchas involved in their proper detection when using virtualbox on windows host. But some golden rules mentioned in this article can be useful: Virtualbox How to: Gotchas involved in making a USB external hard disk device work on windows host

A problem with openfiler 2.2 is that it forgets the previous logical volumes etc after reboots. This situation can result in frustration, especially when you see no LUNs being discovered from the initiators. If you read the following article, there is a good chance that you will be fine: iSCSI: no LUNs detected for session when using openfiler

The Oracle 10gR2 RAC setup

With the above components in place, the stage is now set for you to install the Oracle 10g CRS software. Needless to say, there are several detailed guides available on Oracle Technology Network on how to do this. Each Operating system has unique package pre-requisites for the Oracle software to be installed properly.

Some more guides area available on the novell.com website at http://www.novell.com/products/server/oracle/documents.html

Check out the guides under SUSE Enterprise Linux Server 9 tab. They are pretty detailed.

Some more guides are available at http://www.nextre.it/oracledocs/rac10gonsles9.html and http://www.oracle.com/technology/pub/articles/smiley_rac10g_install.html#oracle

Suggested reading..

It is very likely that you would have come across the widely read article by Jeffrey Hunter on a similar topic. In http://www.oracle.com/technology/pub/articles/hunter_rac10gr2_iscsi.html, he deals with creating a 10g RAC on Redhat linux.

If you do not want to use an external USB hard disk for iscsi SAN targets, then please go through the article A poor man’s guide for creating iscsi targets without using external USB hard disks

iSCSI: no LUNs detected for session when using openfiler

A common problem…

If you are using openfiler, at some point of time, you are bound to reboot the openfiler OS/machine. After the reboot, a common problem is that openfiler forgets or loses the logical volume/volume group information.

So, as a workaround, you need to issue the following commands:

################################
# to discover the volume groups
################################
# vgscan   

#################################
# to discover the logical volumes
#################################
# lvscan  

##################################
# to discover the physical volumes
##################################
# pvscan

Then, you can display them using the commands vgdisplay, lvdisplay, pvdisplay. Similarly, there is a whole suite of commands in the same location.

Then, you STILL need to activate the discovered logical volumes using the -ay switch of lvchange:

# lvchange -ay openfiler/asm
# lvchange -ay openfiler/ocr
# lvchange -ay openfiler/vote

Now, if you run the lvscan or lvdisplay command, the status of the Logical volumes will show as ACTIVATED.

Remember..

AFTER you do this, You will STILL need to restart the iscsi-target service on openfiler machine.

openfiler $> service iscsi-target restart

If you fail to do this, you will see these messages in the dmesg output on the iscsi-initiator node (not the openfiler machine) – iSCSI: no LUNs detected for session. This message can be very confusing, especially since you will see that the session to the iscsi target WAS established:

openfiler $> dmesg
...
...
iSCSI: bus 0 target 0 = iqn.2006-01.com.openfiler:openfiler.vote
iSCSI: bus 0 target 0 portal 0 = address 10.143.213.248 port 3260 group 1
iSCSI: starting timer thread at 286340
iSCSI: bus 0 target 0 trying to establish session to portal 0, address 10.143.213.248 port 3260 group 1
iSCSI: bus 0 target 1 = iqn.2006-01.com.openfiler:openfiler.ocr
iSCSI: bus 0 target 1 portal 0 = address 10.143.213.248 port 3260 group 1
iSCSI: bus 0 target 1 trying to establish session to portal 0, address 10.143.213.248 port 3260 group 1
iSCSI: bus 0 target 0 established session #1, portal 0, address 10.143.213.248 port 3260 group 1
iSCSI: bus 0 target 2 = iqn.2006-01.com.openfiler:openfiler.asm
iSCSI: bus 0 target 2 portal 0 = address 10.143.213.248 port 3260 group 1
iSCSI: bus 0 target 1 established session #1, portal 0, address 10.143.213.248 port 3260 group 1
iSCSI: bus 0 target 2 trying to establish session to portal 0, address 10.143.213.248 port 3260 group 1
iSCSI: bus 0 target 3 = iqn.2006-01.com.openfiler:openfiler.test
iSCSI: bus 0 target 3 portal 0 = address 10.143.213.248 port 3260 group 1
iSCSI: bus 0 target 3 trying to establish session to portal 0, address 10.143.213.248 port 3260 group 1
iSCSI: bus 0 target 2 established session #1, portal 0, address 10.143.213.248 port 3260 group 1
iSCSI: no LUNs detected for session (bus 0 target 0) to iqn.2006-01.com.openfiler:openfiler.vote
iSCSI: no LUNs detected for session (bus 0 target 1) to iqn.2006-01.com.openfiler:openfiler.ocr
iSCSI: no LUNs detected for session (bus 0 target 2) to iqn.2006-01.com.openfiler:openfiler.asm
iSCSI: bus 0 target 3 established session #1, portal 0, address 10.143.213.248 port 3260 group 1

Case Study: How to discover iscsi targets with linux-iscsi initiator package — Suse linux 9 (scsi Initiator) and openfiler (scsi target)

Birds eye view of the end configuration…

Here is the bird’s eye view of the end configuration that we will achieve at the end of this article:

Click here for a bigger view..

My Grumblings with openfiler..

Those of you who have started experimented with openfiler may have started liking its features already. One of the biggest concerns that I have with openfiler is that it’s administrative GUI is full of bugs or makes a lot of assumptions while working.

For example, it wouldn’t show up logical volumes which were created in a iscsi external hard disk from another installation of openfiler virtual machine.

Somehow, CLI commands like pvscan, lvscan and vgscan are able to discover previously created physcial volumes, logical volumes and volume groups; but the front end GUI (http://<openfiler IP>:446) fails to do the same.

Although there is another open source product called freenas, I resisted to temptation to switch my loyalties too soon as no product is without bugs as such.

My requirement..

Anyways, my real requirement was to create a homegrown 10g RAC cluster using virtualbox virtual machines. For better or worse, I had chosen Suse Linux 9 (SP3) as the base operating system for the 10g RAC installation. A great reason was that many big customers like officedepot have chosen to implement 10g RAC on Suse Linux 9.3 . As time goes by, I feel that SuSE linux will become a more popular platform. Hence my persistence with this distribution.

There are ways to spoof the 10g RAC installation with 1 node too, but I wanted to simulate the real thing and be able to drive a Train-The-Trainer session for my teammates.

Looking back at my initial struggles…

I now realize that figuring out how to discover iscsi targets on Ubuntu was much easier. The experience is documented here: Combining Openfiler and Virtualbox (Ubuntu guest OS on windows host

My initial struggles were torn with anguish, especially because I realized very soon that I could not use open-iscsi linux package with SuSE linux 9 (2.6.5-7-244 kernel) at all. SuSE linux 10.x seems to have great support for it, though. This is simply because open-iscsi package works with kernels 2.6.14 and above only.

Tough luck there.

So, whats available for SuSE Linux 9 if you want to discover iscsi target devices?

Well, there are some options. The linux-iscsi package is very much available and with a little configuration, which is quite simplistic, it works great. A lot of people tried to woo me with other distributions like Oracle Enterprise Linux 5, which has iscsi-initiator-utils package built into it, but I stuck to my ground.

Here are some important distinctions between linux-iscsi and open-iscsi:

- The linux-iscsi package (aka iscsi-sfnet) reads /etc/iscsi.conf
- The open-iscsi package reads /etc/iscsid.conf. This package has an additional iscsiadm utility for discovering targets.

As of now, linux-iscsi and open-iscsi projects have been merged (as from their announcement) into one open-iscsi project.

Now, the difficult part: figuring out the setup ..

The most difficult part was figuring out the setup that worked. Eventually, after umpteen tries, it did work. On more than one occasion, I thought if it was even worth trying linux-iscsi initiator package with openfiler as iscsi target, iscsi-target drivers seemed more compatible with open-iscsi initiator package (this was the Ubuntu experience dominating my thinking).

However, I now realize that this perception was delusional. All I really needed was to a proper configuration of linux-iscsi package as iscsi initiator.

i will assume that the reader is conversant with the terms iscsi iniatiator/target.
If not, here is a crash course: iscsi targets are the LUNs or logical volumes in your NAS device , iscsi initiator is the client machine which wants to use these LUNs or Logical volumes. You dig?

With debug level 10 of iscsid process (# iscsid -d 10 &), i was getting the following error while discovering targets:

.. >> iscsid[17946]: connecting to 10.143.213.233:446
.. >> iscsid[17946]: connected local port 33785 to 10.143.213.233:446
.. >> iscsid[17946]: discovery session to 10.143.213.233:446 starting iSCSI login on fd 1
.. >> iscsid[17946]: sending login PDU with current stage 1, next stage 3, transit 0x80, isid 0x00023d000001
.. >> iscsid[17946]: >   InitiatorName=iqn.1987-05.com.cisco:01.51f06557c68
.. >> iscsid[17946]: >   InitiatorAlias=raclinux1
.. >> iscsid[17946]: >   SessionType=Discovery
.. >> iscsid[17946]: >   HeaderDigest=None
.. >> iscsid[17946]: >   DataDigest=None
.. >> iscsid[17946]: >   MaxRecvDataSegmentLength=8192
.. >> iscsid[17946]: >   X-com.cisco.PingTimeout=5
.. >> iscsid[17946]: >   X-com.cisco.sendAsyncText=Yes
.. >> iscsid[17946]: >   X-com.cisco.protocol=draft20
.. >> iscsid[17946]: wrote 48 bytes of PDU header
.. >> iscsid[17946]: wrote 248 bytes of PDU data
.. >> iscsid[17946]: socket 1 closed by target
.. >> iscsid[17946]: login I/O error, failed to receive a PDU
.. >> iscsid[17946]: retrying discovery login to 10.143.213.233
.. >> iscsid[17946]: disconnecting session 0x80b4890, fd 1
.. >> iscsid[17946]: discovery session to 10.143.213.233:446 sleeping for 2 seconds before next login attempt

I saw light at the end of the tunnel after trying a simple setup mentioned in http://www-941.ibm.com/collaboration/wiki/display/LinuxP/iSCSI

Lets talk about the experience in more detail now.

The setup on iscsi target (Openfiler) side..

[root@openfiler~]# uname -a
Linux openfiler.usdhcp.example.com 2.6.19.4-0.1.x86.i686.cmov #1 ..

I did not setup a network or subnet of allowed initiators for LUNs (as
can be seen here that the /etc/initiators.allow and /etc/initiators.deny files are
non-existent):

[root@openfiler~]# ls /etc/initiators.allow
ls: /etc/initiators.allow: No such file or directory 

[root@openfiler~]# ls /etc/initiators.deny
ls: /etc/initiators.deny: No such file or directory 

[root@openfiler~]# more /etc/ietd.conf
Target iqn.2006-01.com.openfiler:openfiler.testLun0Path=/dev/openfiler/test,Type=fileio

[root@openfiler~]# service iscsi-target status
ietd (pid 4164) is running...

Checking if the device drivers are loaded:

[root@openfiler~]# lsmod | grep scsi
iscsi_trgt             61788  4
scsi_mod              111756  2 sd_mod,usb_storage

Checking if the NAS device is discovered:

[root@openfiler~]# more /proc/scsi/scsi
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
  Vendor: ST332083 Model: 3A               Rev: 3.AA
  Type:   Direct-Access                    ANSI SCSI revision: 02

Checking what logical volumes have been discovered:

[root@openfiler~]# cat /proc/net/iet/session
tid:1 name:iqn.2006-01.com.openfiler:openfiler.test

Discover the volume groups, logical volumes and physical volumes:

[root@openfiler~]# vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "openfiler" using metadata type lvm2

[root@openfiler~]# lvscan
  ACTIVE            '/dev/openfiler/ocr' [1.00 GB] inherit
  ACTIVE            '/dev/openfiler/vote' [1.00 GB] inherit
  ACTIVE            '/dev/openfiler/asm' [60.00 GB] inherit
  ACTIVE            '/dev/openfiler/test' [32.00 MB] inherit

[root@openfiler~]# pvscan
  PV /dev/sda2   VG openfiler   lvm2 [122.30 GB / 60.27 GB free]
  Total: 1 [122.30 GB] / in use: 1 [122.30 GB] / in no VG: 0 [0   ]

As you can see, there are actually three more logical volumes that were discovered than
what we have configured in /etc/ietd.conf. We will deal with this later:

[root@openfiler~]# ls -l /dev/openfiler
total 0
lrwxrwxrwx  1 root root 25 Apr 24 09:58 asm -> /dev/mapper/openfiler-asm
lrwxrwxrwx  1 root root 25 Apr 24 09:58 ocr -> /dev/mapper/openfiler-ocr
lrwxrwxrwx  1 root root 26 Apr 24 12:07 test -> /dev/mapper/openfiler-test
lrwxrwxrwx  1 root root 26 Apr 24 09:59 vote -> /dev/mapper/openfiler-vote

The real deal-iscsi Initiator setup using linux-iscsi package on Suse Linux 9.3

raclinux1:~ # uname -a
Linux raclinux1 2.6.5-7.244-default #1 Mon Dec 12 18:32:25 UTC 2005 i686 i686 i386 GNU/Linux

Make sure the linux-iscsi package is installed:

raclinux1:/etc # rpm -qa | grep linux-iscsi
linux-iscsi-4.0.1-98

Show the discovered iscsi devices as of yet:

raclinux1:/etc # iscsi-ls
###############################################################################

iSCSI driver is not loaded

###############################################################################

Since the iscsi driver is missing, Load the iscsi driver (which is also known as the iscsi-Sfnet driver)

raclinux1:/etc # modprobe iscsi

Verify that the iscsi driver was loaded:

raclinux1:/etc # lsmod | grep scsi
iscsi                 182192  0
scsi_mod              112972  5 iscsi,sg,st,sd_mod,sr_mod
raclinux1:/etc #

Check what devices have been configured. Right now, no iscsi devices have been discovered:

raclinux1:/etc # iscsi-ls
*******************************************************************************
        Cisco iSCSI Driver Version ... 4.0.198 ( 21-May-2004 )
*******************************************************************************
raclinux1:/etc #

Configure the /etc/iscsi.conf file for linux-iscsi – the most simplistic case — This is SO the key.

Trivia
Initially, I had given port 446 in the DiscoveryAddress too and that was causing a very cryptic ‘login I/O error, failed to receive a PDU’ error.

I had searched all over the internet to resolve this error, including openfiler forums, only to find out that a few people resolved this by doing a firmware upgrade! Unfortunately, there is very little literature on the internet on this error. That is why I hope this article helps someone out there facing the same situation.

raclinux1:~ # more /etc/iscsi.conf
# this is the IP of the openfiler iscsi target machine
DiscoveryAddress=10.143.213.233

Verify that we have a unique IQN name for the initiator node (SuSE Linux 9.3):

raclinux1:~ # more /etc/initiatorname.iscsi
## DO NOT EDIT OR REMOVE THIS FILE!
## If you remove this file, the iSCSI daemon will not start.
## If you change the InitiatorName, existing access control lists
## may reject this initiator.  The InitiatorName must be unique
## for each iSCSI initiator.  Do NOT duplicate iSCSI InitiatorNames.
InitiatorName=iqn.1987-05.com.cisco:01.51f06557c68

Now, start up iscsid process with a high debug level to see what goes on behind the scenes.
I chose debug level 10 for no particular reason:

raclinux1:/etc # iscsid -d 10 &
[1] 30332
raclinux1:/etc # 1209056895.780916 >> iscsid[30332]: iSCSI debug level 10
1209056895.781428 >> iscsid[30332]: InitiatorName=iqn.1987-05.com.cisco:01.51f06557c68
1209056895.781790 >> iscsid[30332]: InitiatorAlias=raclinux1
1209056895.782101 >> iscsid[30332]: version 4.0.198 ( 21-May-2004)
1209056895.785327 >> iscsid[30333]: pid file fd 0
1209056895.785694 >> iscsid[30333]: locked pid file /var/run/iscsid.pid
1209056895.795251 >> iscsid[30333]: updating config 0xbfffeb10 from /etc/iscsi.conf
...
....
1209056895.799724 >> iscsid[30334]: sendtargets discovery process 0x80a80c0 starting, address 10.143.213.233:3260, continuous 1
1209056895.800315 >> iscsid[30334]: sendtargets discovery process 0x80a80c0 to 10.143.213.233:3260 using isid 0x00023d0000011209056895.802181 >> iscsid[30334]: connecting to 10.143.213.233:3260
1209056895.803657 >> iscsid[30334]: connected local port 34261 to 10.143.213.233:3260
1209056895.804189 >> iscsid[30334]: discovery session to 10.143.213.233:3260 starting iSCSI login on fd 1
1209056895.805081 >> iscsid[30334]: sending login PDU with current stage 1, next stage 3, transit 0x80, isid 0x00023d000001
1209056895.805415 >> iscsid[30334]: >    InitiatorName=iqn.1987-05.com.cisco:01.51f06557c68
1209056895.805807 >> iscsid[30334]: >    InitiatorAlias=raclinux1
1209056895.806120 >> iscsid[30334]: >    SessionType=Discovery
1209056895.806535 >> iscsid[30334]: >    HeaderDigest=None
1209056895.806918 >> iscsid[30334]: >    DataDigest=None
1209056895.807213 >> iscsid[30334]: >    MaxRecvDataSegmentLength=8192
1209056895.807515 >> iscsid[30334]: >    X-com.cisco.PingTimeout=5
1209056895.807910 >> iscsid[30334]: >    X-com.cisco.sendAsyncText=Yes
1209056895.808217 >> iscsid[30334]: >    X-com.cisco.protocol=draft20
1209056895.808555 >> iscsid[30334]: wrote 48 bytes of PDU header
1209056895.809044 >> iscsid[30334]: wrote 248 bytes of PDU data
1209056895.810896 >> iscsid[30333]: done starting discovery processes
...
...
1209056895.825881 >> iscsid[30334]: discovery login success to 10.143.213.233
1209056895.800928 >> iscsid[30334]: resolved 10.143.213.233 to 10.4294967183.4294967253.4294967273
...
...
TargetName=iqn.2006-01.com.openfiler:openfiler.test
1209056895.831110 >> iscsid[30334]: >    TargetAddress=10.143.213.233:3260,1
1209056895.831416 >> iscsid[30334]: discovery session to 10.143.213.233:3260 received text response, 88 data bytes, ttt 0xffffffff, final 0x80
...
...
1209056895.849821 >> iscsid[30333]: mkdir /var/lib
1209056895.850134 >> iscsid[30333]: mkdir /var/lib/iscsi
1209056895.850439 >> iscsid[30333]: opened bindings file /var/lib/iscsi/bindings
1209056895.850769 >> iscsid[30333]: locked bindings file /var/lib/iscsi/bindings
1209056895.851143 >> iscsid[30333]: scanning bindings file for 1 unbound sessions
1209056895.851580 >> iscsid[30333]: iSCSI bus 0 target 0 bound to session #1 to iqn.2006-01.com.openfiler:openfiler.test
1209056895.851906 >> iscsid[30333]: done scanning bindings file at line 11
1209056895.852320 >> iscsid[30333]: unlocked bindings file /var/lib/iscsi/bindings

Voila! A new virtual disk is discovered!

Paydirt! The iscsi targets are detected as per messages in /var/log/messages

iSCSI: 4.0.188.26 ( 21-May-2004) built for Linux 2.6.5-7.244-default
iSCSI: will translate deferred sense to current sense on disk command responses
iSCSI: control device major number 254 scsi15 : SFNet iSCSI driver
iSCSI:detected HBA host #15 iSCSI:
bus 0 target 0 = iqn.2006-01.com.openfiler:openfiler.test
iSCSI: bus 0 target 0 portal 0 = address
10.143.213.233 port 3260 group 1iSCSI: bus 0 target 0 established session #1, portal
0, address 10.143.213.233 port 3260 group 1
  Vendor: Openfile  Model: Virtual disk      Rev: 0
  Type:   Direct-Access                      ANSI SCSI
revision: 04
SCSI device sda: 65536 512-byte hdwr sectors (34 MB)
iSCSI: starting timer thread at 11948918
iSCSI: bus 0 target 0 trying to establish session to
portal 0, address 10.143.213.233 port 3260 group 1
SCSI device sda: drive cache: write through
 sda: unknown partition table
Attached scsi disk sda at scsi15, channel 0, id 0, lun 0
Attached scsi generic sg0 at scsi15, channel 0, id 0, lun 0,  type 0
md: Autodetecting RAID arrays.
md: autorun ...
md: ... autorun DONE.

Verifying that the discovery of target LUNs was indeed made:

raclinux1:~ # more /var/lib/iscsi/bindings
# iSCSI bindings, file format version 1.0.
# NOTE: this file is automatically maintained by the iSCSI daemon.
# You should not need to edit this file under most circumstances.
# If iSCSI targets in this file have been permanently deleted, you
# may wish to delete the bindings for the deleted targets.
#
# Format:
# bus   target  iSCSI
# id    id      TargetName
#
0       0       iqn.2006-01.com.openfiler:openfiler.test

Lets restart the linux-iscsi service again (without the debug this time):

raclinux1:/etc # rciscsi stop
Stopping iSCSI: sync umount sync iscsid

raclinux1:/etc # rciscsi start
Starting iSCSI: iscsi iscsid fsck/mount     done

raclinux1:/etc # rciscsi status
Checking for service iSCSI iSCSI driver is loaded
                                            running

Check what devices were discovered:

raclinux1:/etc # iscsi-ls
*******************************************************************************
        Cisco iSCSI Driver Version ... 4.0.198 ( 21-May-2004 )
*******************************************************************************
TARGET NAME             : iqn.2006-01.com.openfiler:openfiler.test
TARGET ALIAS            :
HOST NO                 : 18
BUS NO                  : 0
TARGET ID               : 0
TARGET ADDRESS          : 1.1.3923087114.0:0
SESSION STATUS          : DROPPED AT Thu Apr 24 10:19:16 2008
NO. OF PORTALS          : 1
Segmentation fault

raclinux1:/etc # fdisk -l /dev/sda

Disk /dev/sda: 33 MB, 33554432 bytes
2 heads, 32 sectors/track, 1024 cylinders
Units = cylinders of 64 * 512 = 32768 bytes

Disk /dev/sda doesn't contain a valid partition table

You can now partition the iscsi device using fdisk:

raclinux1:/etc # fdisk /dev/sda
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1024, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1024, default 1024):
Using default value 1024

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
raclinux1:/etc #

raclinux1:/etc # fdisk -l /dev/sda

Disk /dev/sda: 33 MB, 33554432 bytes
2 heads, 32 sectors/track, 1024 cylinders
Units = cylinders of 64 * 512 = 32768 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1        1024       32752   83  Linux

raclinux1:/etc # ls -l /dev/disk
total 132
drwxr-xr-x   4 root root   4096 Apr 10 08:44 .
drwxr-xr-x  33 root root 118784 Apr 24 10:19 ..
drwxr-xr-x   2 root root   4096 Apr 24 10:21 by-id
drwxr-xr-x   2 root root   4096 Apr 24 10:21 by-path

raclinux1:/etc # ls -l /dev/disk/by-id
total 8
...
.. iscsi-iqn.2006-01.com.openfiler:openfiler.test-0 -> ../../sda
.. iscsi-iqn.2006-01.com.openfiler:openfiler.test-0-generic -> ../../sg0
.. iscsi-iqn.2006-01.com.openfiler:openfiler.test-0p1 -> ../../sda1

raclinux1:/etc # ls -l /dev/disk/by-path
total 8
.. ip-10.143.213.233-iscsi-iqn.2006-01.com.openfiler:openfiler.test-0 -> ../../sda
.. ip-10.143.213.233-iscsi-iqn.2006-01.com.openfiler:openfiler.test-0-generic -> ../../sg0
.. ip-10.143.213.233-iscsi-iqn.2006-01.com.openfiler:openfiler.test-0p1 -> ../../sda1
...

In the meanwhile, lets look at the sessions on openfiler server:

[root@openfiler~]# cat /proc/net/iet/session
tid:1 name:iqn.2006-01.com.openfiler:openfiler.test
        sid:564049469047296 initiator:iqn.1987-05.com.cisco:01.51f06557c68
                cid:0 ip:10.143.213.238 state:active hd:none dd:none

[root@openfiler~]# more /proc/net/iet/*
::::::::::::::
/proc/net/iet/session
::::::::::::::
tid:1 name:iqn.2006-01.com.openfiler:openfiler.test
        sid:564049469047296 initiator:iqn.1987-05.com.cisco:01.51f06557c68
                cid:0 ip:10.143.213.238 state:active hd:none dd:none
::::::::::::::
/proc/net/iet/session.xml
::::::::::::::
<?xml version="1.0" ?>

<info>

<target id="1" name="iqn.2006-01.com.openfiler:openfiler.test">
        <session id="564049469047296" initiator="iqn.1987-05.com.cisco:01.51f06557c68">
                <connection id="0" ip="10.143.213.238" state="active" hd="none" dd="none" />
        </session>
</target>

</info>

::::::::::::::
/proc/net/iet/volume
::::::::::::::
tid:1 name:iqn.2006-01.com.openfiler:openfiler.test
        lun:0 state:0 iotype:fileio iomode:wt path:/dev/openfiler/test
::::::::::::::
/proc/net/iet/volume.xml
::::::::::::::
<?xml version="1.0" ?>

<info>

<target id="1" name="iqn.2006-01.com.openfiler:openfiler.test">
        <lun number="0" state= "0"iotype="fileio"iomode="wt" path="/dev/openfiler/test" />
</target>

</info>

Adding all the discovered LUNs to openfiler’s published iscsi targets:

[root@openfiler~]# more /etc/ietd.conf
Target iqn.2006-01.com.openfiler:openfiler.test
    Lun 0 Path=/dev/openfiler/test,Type=fileio
Targetiqn.2006-01.com.openfiler:openfiler.asm
    Lun 1 Path=/dev/openfiler/asm,Type=fileio
Targetiqn.2006-01.com.openfiler:openfiler.ocr
    Lun 2 Path=/dev/openfiler/ocr,Type=fileio
Targetiqn.2006-01.com.openfiler:openfiler.vote
    Lun 3 Path=/dev/openfiler/vote,Type=fileio

[root@openfiler~]# service iscsi-target restart
Stopping iSCSI target service:                             [  OK  ]
Starting iSCSI target service:                             [  OK  ]

[root@openfiler~]# more /proc/net/iet/*
::::::::::::::
/proc/net/iet/session
::::::::::::::
tid:4 name:iqn.2006-01.com.openfiler:openfiler.vote
sid:282574492336640 initiator:iqn.1987-05.com.cisco:01.51f06557c68
cid:0 ip:10.143.213.238 state:active hd:none dd:none
tid:3 name:iqn.2006-01.com.openfiler:openfiler.ocr
sid:564049469047296 initiator:iqn.1987-05.com.cisco:01.51f06557c68
cid:0 ip:10.143.213.238 state:active hd:none dd:none
tid:2 name:iqn.2006-01.com.openfiler:openfiler.asm
sid:845524445757952 initiator:iqn.1987-05.com.cisco:01.51f06557c68
cid:0 ip:10.143.213.238 state:active hd:none dd:none
tid:1 name:iqn.2006-01.com.openfiler:openfiler.test
sid:1126999422468608 initiator:iqn.1987-05.com.cisco:01.51f06557c68
cid:0 ip:10.143.213.238 state:active hd:none dd:none
::::::::::::::
/proc/net/iet/session.xml
::::::::::::::
<?xml version="1.0" ?>

<info>

<target id="4" name="iqn.2006-01.com.openfiler:openfiler.vote">
<session id="282574492336640" initiator="iqn.1987-05.com.cisco:01.51f06557c68">
<connection id="0" ip="10.143.213.238" state="active" hd="none" dd="none" />
</session>
</target>

<target id="3" name="iqn.2006-01.com.openfiler:openfiler.ocr">
<session id="564049469047296" initiator="iqn.1987-05.com.cisco:01.51f06557c68">
<connection id="0" ip="10.143.213.238" state="active" hd="none" dd="none" />
</session>
</target>

<target id="2" name="iqn.2006-01.com.openfiler:openfiler.asm">
<session id="845524445757952" initiator="iqn.1987-05.com.cisco:01.51f06557c68">
<connection id="0" ip="10.143.213.238" state="active" hd="none" dd="none" />
</session>
</target>

<target id="1" name="iqn.2006-01.com.openfiler:openfiler.test">
<session id="1126999422468608" initiator="iqn.1987-05.com.cisco:01.51f06557c68">
<connection id="0" ip="10.143.213.238" state="active" hd="none" dd="none" />
</session>
</target>

</info>

::::::::::::::
/proc/net/iet/volume
::::::::::::::
tid:4 name:iqn.2006-01.com.openfiler:openfiler.vote
lun:0 state:0 iotype:fileio iomode:wt path:/dev/openfiler/asm
tid:3 name:iqn.2006-01.com.openfiler:openfiler.ocr
lun:0 state:0 iotype:fileio iomode:wt path:/dev/openfiler/asm
tid:2 name:iqn.2006-01.com.openfiler:openfiler.asm
lun:0 state:0 iotype:fileio iomode:wt path:/dev/openfiler/asm
tid:1 name:iqn.2006-01.com.openfiler:openfiler.test
lun:0 state:0 iotype:fileio iomode:wt path:/dev/openfiler/test
::::::::::::::
/proc/net/iet/volume.xml
::::::::::::::
<?xml version="1.0" ?>

<info>

<target id="4" name="iqn.2006-01.com.openfiler:openfiler.vote">
<lun number="0" state= "0"iotype="fileio"iomode="wt" path="/dev/openfiler/vote" />
</target>

<target id="3" name="iqn.2006-01.com.openfiler:openfiler.ocr">
<lun number="0" state= "0"iotype="fileio"iomode="wt" path="/dev/openfiler/ocr" />
</target>

<target id="2" name="iqn.2006-01.com.openfiler:openfiler.asm">
<lun number="0" state= "0"iotype="fileio"iomode="wt" path="/dev/openfiler/asm" />
</target>

<target id="1" name="iqn.2006-01.com.openfiler:openfiler.test">
<lun number="0" state= "0"iotype="fileio"iomode="wt" path="/dev/openfiler/test" />
</target>

</info>

In the meanwhile, On the initiator:

Now, let us check the devices detected (the iscsi-device command works more reliably):

raclinux1:/etc # iscsi-device /dev/sda
/dev/sda: 0   0   0       10.143.213.233   3260  iqn.2006-01.com.openfiler:openfiler.test
raclinux1:/etc # iscsi-device /dev/sdb
/dev/sdb: 0   1   0       10.143.213.233   3260  iqn.2006-01.com.openfiler:openfiler.asm
raclinux1:/etc # iscsi-device /dev/sdc
/dev/sdc: 0   2   0       10.143.213.233   3260  iqn.2006-01.com.openfiler:openfiler.vote
raclinux1:/etc # iscsi-device /dev/sdd
/dev/sdd: 0   3   0       10.143.213.233   3260  iqn.2006-01.com.openfiler:openfiler.ocr
raclinux1:/etc # fdisk -l /dev/sd*

Disk /dev/sda: 33 MB, 33554432 bytes
2 heads, 32 sectors/track, 1024 cylinders
Units = cylinders of 64 * 512 = 32768 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1        1024       32752   83  Linux

Disk /dev/sda1: 33 MB, 33538048 bytes
2 heads, 32 sectors/track, 1023 cylinders
Units = cylinders of 64 * 512 = 32768 bytes

Disk /dev/sdb: 64.4 GB, 64424509440 bytes
64 heads, 32 sectors/track, 61440 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/sdc: 64.4 GB, 64424509440 bytes
64 heads, 32 sectors/track, 61440 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

Disk /dev/sdc doesn't contain a valid partition table

Disk /dev/sdd: 64.4 GB, 64424509440 bytes
64 heads, 32 sectors/track, 61440 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

Disk /dev/sdd doesn't contain a valid partition table

raclinux1:/etc # more /var/lib/iscsi/bindings
# iSCSI bindings, file format version 1.0.
# NOTE: this file is automatically maintained by the iSCSI daemon.
# You should not need to edit this file under most circumstances.
# If iSCSI targets in this file have been permanently deleted, you
# may wish to delete the bindings for the deleted targets.
#
# Format:
# bus   target  iSCSI
# id    id      TargetName
#
0       0       iqn.2006-01.com.openfiler:openfiler.test
0       1       iqn.2006-01.com.openfiler:openfiler.asm
0       2       iqn.2006-01.com.openfiler:openfiler.vote
0       3       iqn.2006-01.com.openfiler:openfiler.ocr

************************************************************************************************
Caveat:

Somehow, the iscsi-ls utility was not working. However, the devices were accesible all right.

Instead, the iscsi-device command works beautifully.
************************************************************************************************

raclinux1:/etc # iscsi-ls
*******************************************************************************
Cisco iSCSI Driver Version ... 4.0.198 ( 21-May-2004 )
*******************************************************************************
TARGET NAME             : iqn.2006-01.com.openfiler:openfiler.test
TARGET ALIAS            :
HOST NO                 : 20
BUS NO                  : 0
TARGET ID               : 0
TARGET ADDRESS          : 1.1.3923087114.0:0
SESSION STATUS          : DROPPED AT Thu Apr 24 10:43:41 2008
NO. OF PORTALS          : 1
Segmentation fault

raclinux1:/etc # echo $?
139

Conclusion..

This proves that linux-iscsi package can be made to work on 2.6.5-7.x distributions or for any other linux distribution less than 2.6.14. So if open-iscsi was not meant to compile on your distribution, do not despair. There are other avenues. This article also serves to demonstrate how to use the command line interface of the openfiler product better, as compared to the GUI console.

It also professes that there are some caveats in openfiler, but if we know our way around them, life is good.

Virtualbox How to: Gotchas involved in making a USB external hard disk device work on windows host

Preface

Sometime back, I installed Openfiler on a external hard disk (manufacturer: Iomega)that I had at home (running Windows Vista Home Premium). This was meant to be a proof of concept and pretty soon, I had to bring it to office desktop (running Windows XP SP2) to make it work with some other virtualbox virtual machines that I had built in my spare time.

Troubles in recognizing the USB external hard disk on windows XP

However, the problem that I faced on Windows XP SP2 host operating system was that the openfiler Virtual machine (using virtualbox 1.5.6 of course) would not recognize the USB external hard disk at all! The same USB device was working fine on windows vista.

After struggling with this problem for a while, I found a quick workaround (Not sure if it is documented in the user manual or not) and also tested some reset steps on windows, which seem to work with the Iomega external USB hard disk.

These steps should also be relevant to other hard disk models in general.

Some more details…

In my case, windows had detected the USB drive and had even installed the Virtualbox driver for it. USB support was enabled for the openfiler virtual machine in the settings. The external hard disk was selected, but still no iscsi drive showed up on doing a fdisk -l

When to know a device is being accessed..

Well, if the device makes a whirring noise and the light blinks or comes on, it is enough to know that the device is being accessed internally and something good happened in terms of making the USB device work.

The setup that worked..

However, this setup worked after a little tinkering:

Firstly, make sure the USB controller and EHCI controller is enabled. Then choose the USB external hard disk device from the list of all USB devices and enabled it.

Click here for a bigger view

Make sure no other Virtual machine is accessing the same USB device. From what I have seen, if the same device is accessed by other virtualbox VMs, an exclusive lock is acquired on it, which makes it difficult to be used by other virtual machines.

This is true with windows too. Windows will stop seeing the USB hard disk when it is being used by a virtualbox virtual machine. At least, I have seen this behaviour with virtualbox 1.5.6

Click here for a bigger view

Make sure that Windows is able to detect the USB device first. If not, then you need to troubleshoot that first. Usually, powering off the device, unplugging it from the USB port and restarting the windows PC/desktop/laptop works great. (Hey, its windows).

You want to see something like this in your system tray to be sure of this.

Now you know for a fact that windows, your guest Operating system, detected the USB drive fine. So now, there is a good chance that virtualbox will detect it too.

Fire it up..

Power up the virtual machine and check if the USB device got detected. A simple fdisk -l will show it as a iscsi device, with names like /dev/sda, /dev/sdb or so. If you do not see anything of the sort, you can be certain that the device did not get detected. Another visual way to know is to see if the light on USB device comes up or not. No light, no access.

The manual workaround if the device is still now seen after powering up the virtual machine ..

However, there is still another trick up our sleeve that can be tried.

Click here for a bigger view

At the bottom message bar of the virtual machine, right click on the USB plug icon. You will see that a list of the detected USB devices comes up. Select the external hard disk. Unless another virtual machine is running that is using the same USB device, there is a very good chance that the light on the hard disk will light up like this:

At this point, you may also see a windows dialog box saying that a virtualbox USB device was detected and the driver needs to be loaded:

Double check before you congratulate yourself..

All right! So it looks like your device got accessed after all.

There are many ways to confirm if it really got detected by the virtual machine as a scsi device or not:

1) Check the fdisk -l command’s output:

Click here for a bigger view

2) Check the contents of /proc/scsi/scsi file:

Click here for a bigger view

3) Check the content of /var/log/messages or the output of dmesg command:

Click here for a bigger view

A quick Recap…

Once again, if this does not work, just go back to the basics:

1) Power off the USB device (when applicable) and take it out

2) Reboot windows

3) Plug in the USB device

4) Make sure windows detects it

5) Make sure the virtual machine has the USB device enabled in its setup

6) Start up the virtual machine. Make sure no other virtual machine is using the same USB drive.

7) If you do not see the USB device, force it to be attached by right click on USB plug icon in bottom bar of virtualbox VM application window

Hope that helps.

Combining Openfiler and Virtualbox (Ubuntu guest OS on windows host)

Preface – Celebrating Openfiler

Ever since I came to know about openfiler, a free open source network attached storage appliance, I could not wait to get started on it! Compared to similar open source products in the internet like FreeNAS, openfiler has much better reviews from the user community.

In this article, we will talk about how we can leverage openfiler along with an Ubuntu virtual machine running on windows host. The fact that the virtual machine is running on windows is immaterial, as most of the material covered in this article will deal with making openfiler shared devices work with a unix distribution, namely Ubuntu, in our case. The steps discussed should not be largely different for any other unix operating system.

The ingredients

One of the main ingredients for doing this setup is to know about how to make host only networking work in Virtualbox. For this, I will recommend you to go through the article Virtualbox Case Study: Making host only networking work between two Ubuntu Guest OS (virtual machine) on Windows Vista host, that was posted just before this one. It has detailed steps as to how two virtual machines can be made to talk to each other, with internet working too.

So, going along with this idea, you need to do host only networking between a Unix virtual machine and an openfiler installation virtual machine. For installing openfiler, detailed how to graphical instructions are available at http://openfiler.com/learn/how-to/graphical-installation. If you are a text person, consider going through the text instructions at http://openfiler.com/learn/how-to/text-based-installation.

The other important ingredient that we need is an external USB hard disk to attach with the openfiler virtual machine like this:

click here for a bigger picture

I discovered that after the openfiler virtual machine booted up, windows vista premium home edition was not able to discover the USB hard disk in explorer. After I shutdown openfiler virtual machine, windows would detect the USB external drive.

windows-discovers-the-usb-drive

I also noticed was that if I specified the USB mouse device in the virtualbox USB devices setup of the unix machine, it was not able to access it! (The touchpad was still working though). So eventually, I just unchecked the USB mouse device for Ubuntu virtual machine and everything was ok.

The Openfiler Virtualbox VM setup example

Click here to see a bigger picture

The Ubuntu unix Virtualbox VM setup example

Click here to see a bigger picture

After the openfiler installation, you can see that it installs a linux 2.6.x OS, which can be brought up like any other linux installation.

Once you boot up the operating system, you can invoke the web administration GUI tool using http://<IP of openfiler server>:446 like this (openfiler/password is the default login):

Click here for a bigger picture

A Caveat if you do not want to use the entire external USB drive as network attached storage

Since I could not afford to dedicate my entire 300GB USB external drive for this experiment, I had to find a way of working with a part of it. Thankfully, with the help of gparted live CD, I was able to resize the FAT32/NTFS windows partition in external drive to 175G and created another partition of 125G with the remaining space. If you have never used gparted (GNOME partition editor), I must tell you that you simply have to try it. It is free, its versatile and its simply amazing.

Please note here that I DID NOT format the 125G partition as ext3 or any other format. This was important since the openfiler was not able to see the second physical volume in the USB drive otherwise as a iSCSI device otherwise.

Once this was done, I found that the openfiler administrator GUI was having a hard time creating a physical volume and a volume group based on the second partition carved in USB drive.

It seems that the GUI assumes that the entire attached drive should be available for its manipulations.

To get around this problem, I had to use the command line interface commands, which was good in a way, as I was able to learn many useful commands that are employed by the pretty front end. Using fdisk -l, it could be seen that the USB external drive was discovered as /dev/sda by openfiler OS.

# pvcreate /dev/sda2
Physical volume "/dev/sda2" successfully created

Click here for the bigger picture


Let it be understood that after any changes on openfiler, it is required to restart the iSCSI service. This can be done either by “# service iscsi-target restart” command or from the GUI: Services->Enable/Disable (Disable and Enable the iSCSI service forcibly to achieve the same result).

# vgcreate openfiler /dev/sda2
Volume group "vg" successfully created

Click here for a bigger picture (note that the Web UI 
does not show the PVs yet, but its still OK)

After this, we need to create the logical volumes. Another weird thing I noticed was that if I used the lvcreate commane line interface to create logical volumes, they were not showing up in the web admin utility, even after restarting the iSCSI server on openfiler OS.

So I created three of them from the web administration utility (Hey, whatever works):

/dev/openfiler/ocr
/dev/openfiler/vote
/dev/openfiler/asm

This is how the web GUI showed them now:

Click here for a bigger view

The openfiler:/etc/ietd.conf file now has contents like this:

Defining Local networks

Be informed that another variation here is to define a local network consisting of IP subnet, which would essentially decide which machines can be allowed to discover the LUNs in network attached storage. Using the GUI, this is achieved through General->Local Networks.

Subsequently, you need can control allow/deny access to each logical volume from the GUI by updating the property of respective logical volumes (be aware that this creates /etc/initiators.allow and /etc/initiators.deny files in the openfiler OS):

Click here for a bigger view

I did not use any local networks, as I got burnt by giving an incorrect subnet and that was causing the discovery of LUNs to not work from ubuntu VM. So I just kept it plain and simple by allowing any machine in the LAN to discover the LUNs.

CHAP authentication

There is also something called CHAP authentication (the username and passwords can be set using the iscsiadm command) to further qualify iscsi initiator/target LUN discovery. This is a topic that I have not explored fully at this point, so I did not enable incoming/outgoing CHAP authentication either in openfiler OS (iSCSI target) or the ubuntu virtual machine (iSCSI initiator).

This was another aspect of open-iscsi that burnt me while trying to discover target LUNs from ubuntu VM, so I just steered clear of it, for the time being.

There is a fantastic How to on how to configure open-iscsi using CHAP authentication at http://en.opensuse.org/Open-iSCSI_and_SUSE_Linux. I would strongly recommend you to read and digest it.

Understanding how LUN discovery works with open-iscsi

open-iscsi is a robust, well performing implementation of iSCSI device package that is very much in vogue and is being adopted by various unix flavours.

It runs a daemon in the background called iscsid. Open-iSCSI utility keeps a persistent configuration of target LUNs and initiator nodes in a database. The iscsiadm utility is a command-line tool to manage (update, delete, insert, query) the persistent database.

The database contains two tables:

- Discovery table (/etc/iscsi/send_targets);
- Node table (/etc/iscsi/nodes).

You can install the open-iscsi package using either Synaptic package manager or “sudo apt-get install open-iscsi” command in Ubuntu. For my case, the apt-get command was somehow not able to to refer to ubuntu repositories, but thankfully Synaptic package manager worked fine.

open-iscsi works on a client server model. Initiators like the Ubuntu virtual machine will send discovery requests to SCSI targets and access them by creating login sessions. Till the duration of the session, the initiator can access the discovered targets (LUNs). Simply put, that is it.

This can be made a little complicated by adding CHAP authentication into the mix.

Each Initiator has a unique name, which can be got by checking the contents of /etc/iscsi/initiatorname.iscsi:

gverma@gverma-laptop:~$ sudo more /etc/iscsi/initiatorname.iscsi
## DO NOT EDIT OR REMOVE THIS FILE!
## If you remove this file, the iSCSI daemon will not start.
## If you change the InitiatorName, existing access control lists
## may reject this initiator.  The InitiatorName must be unique
## for each iSCSI initiator.  Do NOT duplicate iSCSI InitiatorNames.
InitiatorName=iqn.1993-08.org.debian:01:8211251a31ff

Making iscsi work

After installation of open-iscsi, I made sure that /etc/iscsi/iscsid.conf had the defaults configured, without CHAP authentication. The defaults for the rest are usually ok, which is what I went along with. After any changes, its important to restart open-iscsi service:

# sudo /etc/init.d/open-iscsi restart

I also disabled CHAP authentication (both incoming and outgoing users) for each logical volume from the openfiler GUI administrator utility.

The IP of openfiler VM was 192.168.0.6 and that Ubuntu VM was 192.168.0.4

Some initial problems..

gverma@gverma-laptop:~$ sudo iscsiadm -m discovery -t
st -p 192.168.0.6
iscsiadm: Login failed to authenticate with target
iscsiadm: discovery login to 192.168.0.6 rejected:
initiator error (02/01), non-retryable, giving up

To debug this, we can use the -d switch:

gverma@gverma-laptop:~$ sudo iscsiadm -m discovery -d -t st -p 192.168.0.6

discovery.startup = manual
discovery.type = sendtargets
discovery.sendtargets.address = 192.168.0.6
discovery.sendtargets.port = 3260
discovery.sendtargets.auth.authmethod = None
discovery.sendtargets.auth.username = gverma
discovery.sendtargets.auth.password = ********

discovery.sendtargets.auth.username_in = <empty>
discovery.sendtargets.auth.password_in = <empty>

discovery.sendtargets.timeo.login_timeout = 15
discovery.sendtargets.reopen_max = 5
discovery.sendtargets.timeo.auth_timeout = 45
discovery.sendtargets.timeo.active_timeout = 30
discovery.sendtargets.timeo.idle_timeout = 60
discovery.sendtargets.iscsi.MaxRecvDataSegmentLength = 32768

It seemed that some sort of authentication was still being used. To overcome this issue, I commented CHAP authentication for all discovery modes in /etc/iscsi/iscsid.conf and restarted open-iscsi service.

Then we needed to discover the targets on 192.168.0.6 (openfiler VM):

gverma@gverma-laptop:~$ sudo iscsiadm -m discovery
-t st -p 192.168.0.6
192.168.0.6:3260,1 iqn.2006-01.com.openfiler:openfiler.asm
192.168.0.6:3260,1 iqn.2006-01.com.openfiler:openfiler.ocr
192.168.0.6:3260,1 iqn.2006-01.com.openfiler:openfiler.vote
gverma@gverma-laptop:~$ sudo iscsiadm -m discovery
192.168.0.6:3260 via sendtargets
gverma@gverma-laptop:~$ sudo iscsiadm -m node
192.168.0.6:3260,1 iqn.2006-01.com.openfiler:openfiler.ocr
192.168.0.6:3260,1 iqn.2006-01.com.openfiler:openfiler.vote
192.168.0.6:3260,1 iqn.2006-01.com.openfiler:openfiler.asm

Now that the targets from Ubuntu node were discovered, it was needed to login to each of them:

gverma@gverma-laptop:~$ sudo iscsiadm -m node
-T iqn.2006-01.com.openfiler:openfiler.ocr -p 192.168.0.6 -l
Login session [iface: default, target: iqn.2006-01.com.openfiler:openfiler.ocr,
portal: 192.168.0.6,3260]
iscsiadm: initiator reported error (5 - encountered iSCSI login failure)
iscsiadm: Could not execute operation on all records. Err 107.

This error was because I had setup a local network for qualifying initiators to connect to LUNs and has basically given a wrong subnet in the openfiler setup. When I removed the local network from openfiler setup, removed openfiler:/etc/initiators.allow and /etc/initiators.deny files, and restarted ietd service, the command went through.

Now, we can also setup the target LUNs to startup/attach automatically on iscsi service restart on initiator (this will make the LUNs visible from the iscsi initiator by creating a session to the iscsi target). This can be done by influencing the node.startup property value to automatic in the iscsid database:

gverma@gverma-laptop:~$ sudo iscsiadm -m node \
-T iqn.2006-01.com.openfiler:openfiler.ocr -p 192.168.0.6 \
--op update -n node.startup -v automatic
gverma@gverma-laptop:~$ sudo iscsiadm -m node \
-T iqn.2006-01.com.openfiler:openfiler.vote -p 192.168.0.6 \
--op update -n node.startup -v automatic
gverma@gverma-laptop:~$ sudo iscsiadm -m node \
-T iqn.2006-01.com.openfiler:openfiler.asm -p 192.168.0.6 \
--op update -n node.startup -v automatic

Now, when we restart the open-iscsi service, it can be seen that the targets LUNs are attaching to the initiator:

gverma@gverma-laptop:~$ sudo /etc/init.d/open-iscsi restart
* Disconnecting iSCSI targets                                                                                         [ OK ]
* Stopping iSCSI initiator service                                                                                    [ OK ]
* Starting iSCSI initiator service iscsid                                                                             [ OK ]
* Setting up iSCSI targets
Login session [iface: default, target: iqn.2006-01.com.openfiler:openfiler.ocr,
portal: 192.168.0.6,3260]
Login session [iface: default, target: iqn.2006-01.com.openfiler:openfiler.vote,
portal: 192.168.0.6,3260]
Login session [iface: default, target: iqn.2006-01.com.openfiler:openfiler.asm,
portal: 192.168.0.6,3260]                                                                                               [ OK ]

You can verify the login sessions with this command:

gverma@gverma-laptop:~$ sudo iscsiadm -m session
tcp: [4] 192.168.0.6:3260,1 iqn.2006-01.com.openfiler:openfiler.ocr
tcp: [5] 192.168.0.6:3260,1 iqn.2006-01.com.openfiler:openfiler.vote
tcp: [6] 192.168.0.6:3260,1 iqn.2006-01.com.openfiler:openfiler.asm

If you logout, the sessions wont be visible anymore:

gverma@gverma-laptop:~$ sudo iscsiadm -m node \
-T iqn.2006-01.com.openfiler:openfiler.asm -p 192.168.0.6 --logout
Logout session [sid: 1, target: iqn.2006-01.com.openfiler:openfiler.ocr,
portal: 192.168.0.6,3260]
Logout session [sid: 2, target: iqn.2006-01.com.openfiler:openfiler.vote,
portal: 192.168.0.6,3260]
Logout session [sid: 3, target: iqn.2006-01.com.openfiler:openfiler.asm,
portal: 192.168.0.6,3260]
gverma@gverma-laptop:~$ sudo iscsiadm -m session
iscsiadm: No active sessions.

You can login back again now:

gverma@gverma-laptop:~$ sudo iscsiadm -m node \
-T iqn.2006-01.com.openfiler:openfiler.asm -p 192.168.0.6 --login
Login session [iface: default, target: iqn.2006-01.com.openfiler:openfiler.ocr,
portal: 192.168.0.6,3260]
Login session [iface: default, target: iqn.2006-01.com.openfiler:openfiler.vote,
portal: 192.168.0.6,3260]
Login session [iface: default, target: iqn.2006-01.com.openfiler:openfiler.asm,
portal: 192.168.0.6,3260]
gverma@gverma-laptop:~$ sudo iscsiadm -m session
tcp: [4] 192.168.0.6:3260,1 iqn.2006-01.com.openfiler:openfiler.ocr
tcp: [5] 192.168.0.6:3260,1 iqn.2006-01.com.openfiler:openfiler.vote
tcp: [6] 192.168.0.6:3260,1 iqn.2006-01.com.openfiler:openfiler.asm

This is how the current mapping of the attached SAN LUNs and device name is got for the current session:

gverma@gverma-laptop:~$ ls -l /dev/disk/by-path
lrwxrwxrwx 1 root root  9 2008-04-16 22:02 ..
ip-192.168.0.6:3260-iscsi-iqn.2006-01.com.openfiler:openfiler.asm-lun-0 -> ../../sdd
lrwxrwxrwx 1 root root  9 2008-04-16 22:02 ..
ip-192.168.0.6:3260-iscsi-iqn.2006-01.com.openfiler:openfiler.ocr-lun-0 -> ../../sdb
lrwxrwxrwx 1 root root  9 2008-04-16 22:02 ..
ip-192.168.0.6:3260-iscsi-iqn.2006-01.com.openfiler:openfiler.vote-lun-0 -> ../../sdc
lrwxrwxrwx 1 root root  9 2008-04-16 12:48 pci-0000:00:01.1-scsi-0:0:0:0 -> ../../sda
lrwxrwxrwx 1 root root 10 2008-04-16 12:48 pci-0000:00:01.1-scsi-0:0:0:0-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10 2008-04-16 12:48 pci-0000:00:01.1-scsi-0:0:0:0-part2 -> ../../sda2
lrwxrwxrwx 1 root root 10 2008-04-16 12:48 pci-0000:00:01.1-scsi-0:0:0:0-part5 -> ../../sda5
lrwxrwxrwx 1 root root 10 2008-04-16 12:48 pci-0000:00:01.1-scsi-1:0:0:0 -> ../../scd0

Paydirt: Seeing the LUNs on Ubuntu VM

This could be seen in the /var/log/messages:

Apr 16 21:53:19 gverma-laptop kernel: [18263.996005] scsi 42:0:0:0: Direct-Access Openfile Virtual disk 0 PQ: 0 ANSI: 4
Apr 16 21:53:19 gverma-laptop kernel: [18264.000393] sd 42:0:0:0: [sdb] 2097152 512-byte hardware sectors (1074 MB)
Apr 16 21:53:19 gverma-laptop kernel: [18264.002548] sd 42:0:0:0: [sdb] Write Protect is off
Apr 16 21:53:19 gverma-laptop kernel: [18264.004196] sd 42:0:0:0: [sdb] Write cache: disabled, read cache: enabled, doesn’t support DPO or FUA
Apr 16 21:53:19 gverma-laptop kernel: [18264.004196] sd 42:0:0:0: [sdb] 2097152 512-byte hardware sectors (1074 MB)
Apr 16 21:53:19 gverma-laptop kernel: [18264.004196] sd 42:0:0:0: [sdb] Write Protect is off
Apr 16 21:53:19 gverma-laptop kernel: [18264.009630] sd 42:0:0:0: [sdb] Write cache: disabled, read cache: enabled, doesn’t support DPO or FUA
Apr 16 21:53:19 gverma-laptop kernel: [18264.009718] sdb: unknown partition table
Apr 16 21:53:19 gverma-laptop kernel: [18264.030856] sd 42:0:0:0: [sdb] Attached SCSI disk
Apr 16 21:53:19 gverma-laptop kernel: [18264.030974] sd 42:0:0:0: Attached scsi generic sg2 type 0
Apr 16 21:53:19 gverma-laptop kernel: [18264.292677] scsi43 : iSCSI Initiator over TCP/IP
Apr 16 21:53:19 gverma-laptop kernel: [18264.553516] scsi 43:0:0:0: Direct-Access Openfile Virtual disk 0 PQ: 0 ANSI: 4
Apr 16 21:53:19 gverma-laptop kernel: [18264.555463] sd 43:0:0:0: [sdc] 2097152 512-byte hardware sectors (1074 MB)
Apr 16 21:53:19 gverma-laptop kernel: [18264.556540] sd 43:0:0:0: [sdc] Write Protect is off
Apr 16 21:53:19 gverma-laptop kernel: [18264.559456] sd 43:0:0:0: [sdc] Write cache: disabled, read cache: enabled, doesn’t support DPO or FUA
Apr 16 21:53:19 gverma-laptop kernel: [18264.561681] sd 43:0:0:0: [sdc] 2097152 512-byte hardware sectors (1074 MB)
Apr 16 21:53:19 gverma-laptop kernel: [18264.564112] sd 43:0:0:0: [sdc] Write Protect is off
Apr 16 21:53:19 gverma-laptop kernel: [18264.566617] sd 43:0:0:0: [sdc] Write cache: disabled, read cache: enabled, doesn’t support DPO or FUA
Apr 16 21:53:19 gverma-laptop kernel: [18264.566719] sdc: unknown partition table
Apr 16 21:53:19 gverma-laptop kernel: [18264.585774] sd 43:0:0:0: [sdc] Attached SCSI disk
Apr 16 21:53:19 gverma-laptop kernel: [18264.585872] sd 43:0:0:0: Attached scsi generic sg3 type 0
Apr 16 21:53:20 gverma-laptop kernel: [18264.847763] scsi44 : iSCSI Initiator over TCP/IP
Apr 16 21:53:20 gverma-laptop kernel: [18265.112437] scsi 44:0:0:0: Direct-Access Openfile Virtual disk 0 PQ: 0 ANSI: 4
Apr 16 21:53:20 gverma-laptop kernel: [18265.112437] sd 44:0:0:0: [sdd] 125829120 512-byte hardware sectors (64425 MB)
Apr 16 21:53:20 gverma-laptop kernel: [18265.112437] sd 44:0:0:0: [sdd] Write Protect is off
Apr 16 21:53:20 gverma-laptop kernel: [18265.113012] sd 44:0:0:0: [sdd] Write cache: disabled, read cache: enabled, doesn’t support DPO or FUA
Apr 16 21:53:20 gverma-laptop kernel: [18265.115823] sd 44:0:0:0: [sdd] 125829120 512-byte hardware sectors (64425 MB)
Apr 16 21:53:20 gverma-laptop kernel: [18265.117126] sd 44:0:0:0: [sdd] Write Protect is off
Apr 16 21:53:20 gverma-laptop kernel: [18265.119686] sd 44:0:0:0: [sdd] Write cache: disabled, read cache: enabled, doesn’t support DPO or FUA
Apr 16 21:53:20 gverma-laptop kernel: [18265.119786] sdd: unknown partition table
Apr 16 21:53:20 gverma-laptop kernel: [18265.134147] sd 44:0:0:0: [sdd] Attached SCSI disk
Apr 16 21:53:20 gverma-laptop kernel: [18265.134235] sd 44:0:0:0: Attached scsi generic sg4 type 0

The SAN devices were visible on Ubuntu VM now:

gverma@gverma-laptop:~$ sudo fdisk -l
Disk /dev/sda: 5906 MB, 5906628608 bytes
255 heads, 63 sectors/track, 718 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000eb831
Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1         680     5462068+  83  Linux
/dev/sda2             681         718      305235    5  Extended
/dev/sda5             681         718      305203+  82  Linux swap / Solaris
Disk /dev/sdb: 1073 MB, 1073741824 bytes
34 heads, 61 sectors/track, 1011 cylinders
Units = cylinders of 2074 * 512 = 1061888 bytes
Disk identifier: 0x00000000
Disk /dev/sdb doesn't contain a valid partition table
Disk /dev/sdc: 1073 MB, 1073741824 bytes
34 heads, 61 sectors/track, 1011 cylinders
Units = cylinders of 2074 * 512 = 1061888 bytes
Disk identifier: 0x00000000
Disk /dev/sdc doesn't contain a valid partition table
Disk /dev/sdd: 64.4 GB, 64424509440 bytes
64 heads, 32 sectors/track, 61440 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Disk identifier: 0x00000000
Disk /dev/sdd doesn't contain a valid partition table

Gotcha: Logical Volumes lost after reboot of openfiler

One common caveat that I noticed was that the logical volumes were lost after a reboot of the openfiler virtual machine. The issue seems to be related to detection of USB devices while bringing up the linux OS.

Anyways, to get around it, I did the following each time (better put this in /etc/rc.local)

# pvscan
# vgscan
# lvscan

Activate the logical volumes, otherwise, although sudo /etc/init.d/open-iscsi restart will show that initiator discovers target LUNs, BUT they will not show up in fdisk -l and when you do lvdisplay on openfiler machine, the status will show as NOT available.

# lvchange -ay openfiler/asm
# lvchange -ay openfiler/ocr
# lvchange -ay openfiler/vote
# pvscan
# vgscan
# lvscan

You can verify the status of the logical/physical volumes and volume groups now:

# lvdisplay
# pvdisplay
# vgdisplay

Pending Areas to explore

  • One of the pending topics to explore is unique device labeling using udev. This will prevent LUN name renaming from /dev/sdb to /dev/sdd all of a sudden, should you happen to add a new Logical volume in the SAN or restart the open-iscsi server on initiator.

I tried setting it up using some other examples on the internet, but it did not quite work out. It also seems that devlabel is passe’ and udev is favored in most unix distributions.

  • Mounting the SAN device as a filesystem on initiator machine.

Conclusion

Well, its not as if I covered the whole nine yards, but it was a start and I hope to complete the remaining topics soon. When I do so, I will cover that in more details either in this article or in a separate one.

In the meanwhile, if you have any feedback, feel free to leave a message or email me at gaurav _ verma 22 at yahoo DOT com.