Archive for March, 2007

Playing with iSCSI

Friday, March 2nd, 2007

I recently found myself needing more disk space on a system, but unfortunately the system concerned can only take one hard disk and I didn’t want to buy a bigger hard disk because I’ve got a load of smaller drives spare. So I figured I’d whack a hard disk into a USB enclosure and connect it to my server (rather than shut the server down to add the hard disk properly). As I’d been waiting for an excuse to play with iSCSI, I figured I’d give it a go rather than share the drive by NFS as I usually would.

There are basically two halves to iSCSI: a target, which is the device you want to share and an initiator, a system that wants to access the shared device. So on one system you need to setup and configure iSCSI target software and on the other initiator software.

I started by downloading, compiling and installing iSCSI Enterprise Target onto my server. Once installed, you need to set-up a configuration file (/etc/ietd.conf) to share the device which looks hideous, but actually it’s not too hard. This is mine:

Target iqn.2007-03.uk.co.demon.lug:myth
  Lun 0 Path=/dev/sdb,Type=fileio
  Alias myth
  MaxConnections 1

The first line has to be in a particular format:

iqn.yyyy-mm.<reversed domain name>[:identifier]

So it’s basically the date, the machine’s domain name reversed and a made-up identifier (I used ‘myth’ as the disk is for use by MythTV).
Then I give it the device node (sdb), give it an alias and specify that only one initiator may be connected at any one time. You can define security (a username and password, allowed/disallowed hosts etc.) but I’m on a secure network so I didn’t bother. That’s all the required configuration, now start the daemon:

/etc/init.d/iscsi-target start

On the initiator machine I downloaded, compiled and installed Open-iSCSI. The configuration of this is a bit more of a pain, but not too bad. Once it’s installed, you’ll need to run ‘depmod -a’ to allow the kernel to find the newly-installed modules.
You need to start by creating a configuration file called /etc/iscsi/initiatorname.iscsi. Mine is:

InitiatorName=mythtvbox
InitiatorAlias=mythtv

Basically you just have to make up a name and an alias, which the machine will use to identify itself to the target.
Now you need to start the iscsi daemon:

/etc/init.d/open-iscsi start

Now you need to configure the daemon to automatically connect to the target when started. First you need to ‘discover’ the target using the iscsi_discovery command:

iscsi_discovery <ip address/domain name>

In my case, this returns:

starting discovery to 10.0.0.254
Testing iser-login to target iqn.2007-03.uk.co.demon.lug:myth portal 10.0.0.254:3260
starting to test tcp-login to target iqn.2007-03.uk.co.demon.lug:myth portal 10.0.0.254:3260
discovered 1 targets at 10.0.0.254, connected to 0

That demonstrates that the connection is working. Now you can configure the daemon to connect automatically at start:

iscsiadm -m node -p <ip address/domain name> -T <target name as above> –op update -n node.conn[0].startup -v automatic

In my case, I did:

iscsiadm -m node -p 10.0.0.254 -T iqn.2007-03.uk.co.demon.lug:myth –op update -n node.conn[0].startup -v automatic

Now you need to restart the daemon. There’s a slight bug in the iscsi daemon which means that it doesn’t shut down properly (it isn’t really considered ’stable’ yet), so in addition to stopping it via the init script (/etc/init.d/open-iscsi stop) you’ll need to kill it off manually then restart it:

/etc/init.d/open-iscsi start

All being well, the hard disk should have appeared, so you can access it just like a physical disk connected by SCSI or USB – check in dmesg:

Loading iSCSI transport class v2.0-754.
iscsi: registered transport (tcp)
scsi0 : iSCSI Initiator over TCP/IP
scsi 0:0:0:0: Direct-Access IET VIRTUAL-DISK 0 PQ: 0 ANSI: 4
SCSI device sda: 160086528 512-byte hdwr sectors (81964 MB)
sda: Write Protect is off
sda: Mode Sense: 77 00 00 08
SCSI device sda: drive cache: write through
SCSI device sda: 160086528 512-byte hdwr sectors (81964 MB)
sda: Write Protect is off
sda: Mode Sense: 77 00 00 08
SCSI device sda: drive cache: write through
sda: sda1 sda2 < sda5 >
sd 0:0:0:0: Attached scsi disk sda
sd 0:0:0:0: Attached scsi generic sg0 type 0

Now you can enjoy the iSCSI-goodness. Sure sharing with NFS is easier, but apparently iSCSI is faster (actually, it probably doesn’t help very much at all when you’re talking over USB using emulated-SCSI to an IDE disk…).

FOSDEM retrospective

Thursday, March 1st, 2007

Well having finally recovered from the beer and traveling associated with FOSDEM (it was a 10 hour journey for me, since I went by train in order to save a few quid) I figure I should do a quick write-up.

I didn’t take any photographs this time, simply because 1. I was feeling a bit lazy and 2. it has been shown from previous visits that my camera is not good enough to get decent photographs.

Anyway, for me the best talks of FOSDEM 2007 were Simon PhippsLiberating Java and Sean Moss-Pultz’s OpenMoko.

While I’m not really interested in Java itself (I really don’t like Java as a language; it’s too object-oriented, if that makes sense), I am interested in Sun’s reason for GPLing Java and in their new-found commitment to Free Software. Simon Phipps is a really good speaker; he is somewhat like Stallman in that he has the ability to clearly convey what he’s trying to say and when he says something, you believe him. I think it’s essential that Sun have someone like Simon to speak for them, since as a community we’re somewhat wary of corporations that claim to be on our side, since that’s exactly how Novell were before they turned around and screwed us.
In any case, the talk actually wasn’t really about Java, but more about how Sun has come to recognise the importance of Free Software and are making a serious commitment to it – such as, announced for the first time during the talk, Sun becoming a corporate patron of the Free Software Foundation. What was also emphaised was that ‘Sun are listening’ are want to know if they’re screwing up in the eyes of the FLOSS community – this is good to hear and I hope that continues. I was hoping to catch up with Simon to discuss OpenSolaris licensing and how it is impacting on my Linux kernel development work, but unfortunately didn’t get the opportunity. I’ll have to mail him instead.

The OpenMoko talk was really interesting, because these guys have some really big ambitions and are bringing some new ideas to a somewhat stagnant industry. The company behind the OpenMoko project are producing a mobile phone (the Neo1973) based on 99% FLOSS, which is completely hackable: you can write standard GTK applications for them – none of this cut-down-slow-as-hell-Java nonsense to worry about. The small room the talk was in was not just full, but over-full – people were spilling out into the corridor. Clearly the popularity of the OpenMoko project had been grossly underestimated – it should have been in one of the main lecture theaters. A development model will be available in about a month for just $350 – I will absolutely be having one, presuming I can get a nice discount when they launch the final hardware revision a few months later. One thing that really annoys me is when I buy a mobile phone, only to find that the firmware is full of bugs (my current handset has more than its fair share). The prospect of having a bugzilla in which to report firmware bugs and having the ability to fix such things myself is really cool.
Looking at the handset in-the-flesh, it was cool to see it booting a regular Linux kernel with all the usual boot-up messages and framebuffer penguin in the top-left of the screen, but it did take about a minute or so from power-on until the UI was loaded – I hope this is fixed before they go into production!

I have to say that having been to FOSDEM each year since 2005, this has been the best one. Previously I’ve had difficulty finding enough talks that I’m interested in seeing, especially on the Sunday, but this time I was in talks all day on Saturday and most of the day on Sunday. Good work FOSDEM organisers!