Wednesday, May 14, 2008

My new motherboard: Discovering hardware with 'grml'

I've bought a new motherboard for a new PC I'm building. It's intended to run OpenSolaris with the ZFS file system and the Solaris iScsi target. But to kick-off, I'm going to start by taking a look at the system, running a Linux Live-CD distribution called 'grml'.

Gigabyte seem to have generated some confusion over the numbering of this motherboard. My board it labelled 'GA-P35C-DS3R v2.1'. A very similar motherboard, the 'GA-EP35C-DS3R' has been reviewed this month in 'PCpro' magazine here in the UK, and was selected as 'Labs Winner'.

So what is the difference between these two similarly named motherboards. Other are asking the same question, and the answer seems to be 'there is no difference'. They are both 'dynamic energy saver' motherboards.

Grml originates from Germany, and is based on a Debian. It boot's directly to a command line prompt, which I love, as this is where the real work is done.

On any new hardware I get my hands on, I like to boot up grml, and use it to poke around & identify what sort of hardware we have for hard drive interfaces and networking.

One of the reasons I picked this Gigabyte motherboard was that it used the Intel ICH9R chipset to provide six AHCI compatible SATA interfaces. In addition it has a JMicron interface chip, which can either provide two more AHCI sata ports, or alternatively run in legacy mode with old style IDE drives.

Again to kick off, I am running the JMicron in legacy mode, with a DVD drive
and a IDE drive hanging off of the ribbon cable.

Ok, lets take a look:

root@grml ~ # uname -a
Linux grml 2.6.23-grml64 #1 SMP PREEMPT Mon Feb 11 16:49:32 CET 2008 x86_64 GNU/Linux
root@grml ~ # lspci -nn
00:00.0 Host bridge [0600]: Intel Corporation 82G33/G31/P35/P31 Express DRAM Controller [8086:29c0] (rev 02)
00:01.0 PCI bridge [0604]: Intel Corporation 82G33/G31/P35/P31 Express PCI Express Root Port [8086:29c1] (rev 02)
00:1a.0 USB Controller [0c03]: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #4 [8086:2937] (rev 02)
00:1a.1 USB Controller [0c03]: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #5 [8086:2938] (rev 02)
00:1a.2 USB Controller [0c03]: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #6 [8086:2939] (rev 02)
00:1a.7 USB Controller [0c03]: Intel Corporation 82801I (ICH9 Family) USB2 EHCI Controller #2 [8086:293c] (rev 02)
00:1b.0 Audio device [0403]: Intel Corporation 82801I (ICH9 Family) HD Audio Controller [8086:293e] (rev 02)
00:1c.0 PCI bridge [0604]: Intel Corporation 82801I (ICH9 Family) PCI Express Port 1 [8086:2940] (rev 02)
00:1c.3 PCI bridge [0604]: Intel Corporation 82801I (ICH9 Family) PCI Express Port 4 [8086:2946] (rev 02)
00:1c.4 PCI bridge [0604]: Intel Corporation 82801I (ICH9 Family) PCI Express Port 5 [8086:2948] (rev 02)
00:1d.0 USB Controller [0c03]: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #1 [8086:2934] (rev 02)
00:1d.1 USB Controller [0c03]: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #2 [8086:2935] (rev 02)
00:1d.2 USB Controller [0c03]: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #3 [8086:2936] (rev 02)
00:1d.7 USB Controller [0c03]: Intel Corporation 82801I (ICH9 Family) USB2 EHCI Controller #1 [8086:293a] (rev 02)
00:1e.0 PCI bridge [0604]: Intel Corporation 82801 PCI Bridge [8086:244e] (rev 92)
00:1f.0 ISA bridge [0601]: Intel Corporation 82801IR (ICH9R) LPC Interface Controller [8086:2916] (rev 02)
00:1f.2 SATA controller [0106]: Intel Corporation 82801IR/IO/IH (ICH9R/DO/DH) 6 port SATA AHCI Controller [8086:2922] (rev 02)
00:1f.3 SMBus [0c05]: Intel Corporation 82801I (ICH9 Family) SMBus Controller [8086:2930] (rev 02)
01:00.0 VGA compatible controller [0300]: nVidia Corporation NV44 [Quadro NVS 285] [10de:0165] (rev a1)
03:00.0 SATA controller [0106]: JMicron Technologies, Inc. JMicron 20360/20363 AHCI Controller [197b:2363] (rev 02)
03:00.1 IDE interface [0101]: JMicron Technologies, Inc. JMicron 20360/20363 AHCI Controller [197b:2363] (rev 02)
04:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller [10ec:8168] (rev 01)

Here are some 'highlights' from the 'dmesg' command, showing I have a
Samsung SATA drive on one of the ICH9 ports, and a Western Digital drive
on the JMicron IDE port.

root@grml ~ # dmesg
Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2
ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx
JMB363: IDE controller at PCI slot 0000:03:00.1
PCI: Enabling device 0000:03:00.1 (0000 -> 0001)
ACPI: PCI Interrupt 0000:03:00.1[B] -> GSI 16 (level, low) -> IRQ 16
JMB363: chipset revision 2
JMB363: 100% native mode on irq 16
Probing IDE interface ide0...
hda: SAMSUNG CD-ROM SC-148C, ATAPI CD/DVD-ROM drive
hdb: WDC WD800JB-00CRA1, ATA DISK drive
hda: Disabling (U)DMA for SAMSUNG CD-ROM SC-148C (blacklisted)
hdb: selected mode 0x45
ahci 0000:00:1f.2: version 2.3
ACPI: PCI Interrupt 0000:00:1f.2[B] -> GSI 19 (level, low) -> IRQ 19
ahci 0000:00:1f.2: AHCI 0001.0200 32 slots 6 ports 3 Gbps 0x3f impl SATA mode
ahci 0000:00:1f.2: flags: 64bit ncq sntf stag pm led clo pmp pio slum part
PCI: Setting latency timer of device 0000:00:1f.2 to 64
scsi0 : ahci
scsi1 : ahci
scsi2 : ahci
scsi3 : ahci
scsi4 : ahci
scsi5 : ahci
ata1: SATA max UDMA/133 cmd 0xffffc20000026100 ctl 0x0000000000000000 bmdma 0x0000000000000000 irq 507
ata2: SATA max UDMA/133 cmd 0xffffc20000026180 ctl 0x0000000000000000 bmdma 0x0000000000000000 irq 507
ata3: SATA max UDMA/133 cmd 0xffffc20000026200 ctl 0x0000000000000000 bmdma 0x0000000000000000 irq 507
ata4: SATA max UDMA/133 cmd 0xffffc20000026280 ctl 0x0000000000000000 bmdma 0x0000000000000000 irq 507
ata5: SATA max UDMA/133 cmd 0xffffc20000026300 ctl 0x0000000000000000 bmdma 0x0000000000000000 irq 507
ata6: SATA max UDMA/133 cmd 0xffffc20000026380 ctl 0x0000000000000000 bmdma 0x0000000000000000 irq 507
ata1: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
ata1.00: ATA-7: SAMSUNG HD400LJ, ZZ100-15, max UDMA7
ata1.00: 781422768 sectors, multi 0: LBA48 NCQ (depth 31/32)
ata1.00: configured for UDMA/133
ata2: SATA link down (SStatus 0 SControl 300)
ata3: SATA link down (SStatus 0 SControl 300)
ata4: SATA link down (SStatus 0 SControl 300)
ata5: SATA link down (SStatus 0 SControl 300)
ata6: SATA link down (SStatus 0 SControl 300)
scsi 0:0:0:0: Direct-Access ATA SAMSUNG HD400LJ ZZ10 PQ: 0 ANSI: 5
sd 0:0:0:0: [sda] 781422768 512-byte hardware sectors (400088 MB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Mode Sense: 00 3a 00 00
sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
ACPI: PCI Interrupt 0000:03:00.0[A] -> GSI 19 (level, low) -> IRQ 19
ahci 0000:03:00.0: AHCI 0001.0000 32 slots 2 ports 3 Gbps 0x3 impl SATA mode
ahci 0000:03:00.0: flags: 64bit ncq pm led clo pmp pio slum part
PCI: Setting latency timer of device 0000:03:00.0 to 64
scsi6 : ahci
scsi7 : ahci
ata7: SATA max UDMA/133 cmd 0xffffc20000028100 ctl 0x0000000000000000 bmdma 0x0000000000000000 irq 19
ata8: SATA max UDMA/133 cmd 0xffffc20000028180 ctl 0x0000000000000000 bmdma 0x0000000000000000 irq 19
ata7: SATA link down (SStatus 0 SControl 300)
ata8: SATA link down (SStatus 0 SControl 300)
r8169 Gigabit Ethernet driver 2.2LK-NAPI loaded
eth0: RTL8168b/8111b at 0xffffc20000030000, 00:1a:4d:5e:b9:ba, XID 38500000 IRQ 16
r8169: eth0: link up

Ok, that's enough excitement for this time, as I'm out of time.
See you next time...

Tuesday, March 25, 2008

Vista SP1 crashes Linux L2TP daemon

In the last week, one of our users has had problems connecting to our VPN, which uses Smoothwall and the Linux L2TP daemon. Until recently this user had not experienced a problem.

I checked our Smoothwall box, and found that the L2TP daemon (l2tpd) was not running. But after restarting it, it crashed again as soon as the user tried to connect. Other users could connect without problem.

Here is the tail end of the log from /var/log/messages:

l2tpd version 0.70-smoothwall started on smoothwallAF1 PID:28094
Linux version 2.4.34.5-up on a i686, listening on IP address 0.0.0.0, port 1701
<--snip-->
handle_avps: handling avp's for tunnel 61598, call 0
message_type_avp: message type 10 (Incoming-Call-Request)
message_type_avp: new incoming call
ourcid = 13433, entropy_buf = 3479
assigned_session_avp: assigned session id: 1
call_serno_avp: serial number is 0
bearer_type_avp: peer bears: analog
handle_avps: Bad exit status handling attribute 1 (Result Code).
Segmentation fault (core dumped) /modules/tunnel/usr/sbin/l2tpd

So, why suddenly a problem?
The Windows XP users could connect ok. The Windows Vista users could connect ok.

Ahh! The user who was having problems had recently applied Vista SP1.

Using tcpdump, I captured the packets arriving at Smoothwall on UDP port 1701, and then examined the capture file using WireShark. The problem seems to occur on the ICRQ packet, which is the 'Incomming Call Request', transmitted by the Windows client to the Smoothwall server.

For Windows XP clients, we see the following AVP's (Attribute Value pair):
'Control Message', 'Assigned Session', 'Call Serial Number' and 'Bearer Type'.

For the Windows Vista SP1 client, there was an extra AVP tagged onto the end. This is a 'Vendor-Specific' AVP of 'Type 1', specifying a 'Vendor ID' of 311 (0x0137), meaning 'Microsoft'.

So what is this extra Microsoft AVP? A quick google finds a Cisco document, implying it may be a related to RADIUS. It talks about Vendor-Specific Attributes (VSAs). Table 36 lists Vendor-Specific RADIUS IETF Attributes with Vendor company code 311 and Sub-type 1 which is a "MSCHAP-Response" attribute.

Ok, so it seems the version of l2tpd we are using does not like the presence of this extra AVP, and mistakes it for a 'Result Code' AVP, which should only be present in CDN and StopCCN messages.

The relavent RFC is: RFC2261 - "Layer Two Tunneling Protocol".

Looking at the top of page 50 of the RFC, for an ICRQ, it lists the AVPs that MUST be present, and the AVPs that MAY be present. This would seem to indicate that a vendor specific AVP is NOT valid at this stage.

Looking at page 12 of the RFC, section 4.1, which details the format of the AVP, implies that the problem could be fixed if l2tpd were to look at the 'Vendor ID' field, and ignore the AVP in the ICRQ where the Vendor ID was non zero.

Looking at the code for l2tpd, in the file "avp.c" and in function "handle_avps()" there is no code that checks to confirm that (avp->vendorid) is zero.

At the moment we do not have a fix, other than to un-install Vista SP1.

Thursday, February 28, 2008

Windbg Symbols for ntoskrnl.exe

In this case the OS was Windows Vista 64-bit with SP1 RTM applied,
so the kernel was "6001.18000.amd64fre.longhorn_rtm.080118-1840".

I tried setting WinDbg to load sysmbols across the Internet
from Microsoft's symbol server. But I got errors like the following:

ERROR: Module load completed but symbols could not be loaded for ntoskrnl.exe
Kernel symbols are WRONG. Please fix symbols to do analysis.
Your debugger is not using the correct symbols
Type referenced: nt!_KPRCB


So I decided to download the symbols, from here:
http://www.microsoft.com/whdc/devtools/debugging/symbolpkg.mspx

I extracted them onto my hard drive, updated my symbols path,
but I still got the same errors.

I discovered that to fix this, you need to go into
the SYMBOLS\EXE folder and copy file 'ntkrnlmp.pdb'
to 'ntoskrnl.pdb'.

Friday, January 18, 2008

Calling Oracle Stored Procedure with PHP

I've just been following this excellent tutorial article
on the Oracle WebSite:
Calling Oracle Stored Procedure with PHP

I'm only just starting to use Oracle PL/SQL and PHP,
and it's still early days. So I'm making really stupid
mistakes and getting errors like this:
Warning: oci_execute() [function.oci-execute]: ORA-06550: line 1, column 7:
PLS-00201: identifier 'ROLLROUTE' must be declared ORA-06550: line 1, column 7:

Here was my code:
 $sql = "BEGIN RollRoute(:PartNo); END;";

$s = oci_parse($c, $sql );
oci_bind_by_name($s,':PartNo',$PartNo,32);
oci_execute($s);

The fix was simple:
 $sql = "BEGIN RROUTING_API.RollRoute(:PartNo); END;";

Yes, the Procedure is in a Package.
So you need to prefix the procedure name, with the package name.
Being a newbie, it look me a while to spot that!

Thursday, August 30, 2007

WMI and "Permission denied"

Today we were trying to use vbscript and WMI to audit the software installed on PCs connected to our network. The PC's were running Windows XP Pro, and were members of an Active Directory Domain.

The script worked fine in most cases, but we occasionally got errors like these:

Error 462 on GetObject()
"The remote server machine does not exist or is unavailable"

Error 70 on GetObject()
"Permission denied"


The line of code in question was:
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate,authenticationLevel=Pkt}!//" & strComputer & sDNS & "/root/default:StdRegProv")


To cut a long story short, we used WireShark to capture the conversation between the source and target PC's.

Here is a RPC packet sent from the source to the target PC.
The target PC is "PC-ONE-LAP".

DCE RPC Bind, Fragment: Single, FragLen: 1440, Call: 2
Version: 5
Version (minor): 0
Packet type: Bind (11)
Packet Flags: 0x03
Data Representation: 10000000
Frag Length: 1440
Auth Length: 1360
Call ID: 2
Max Xmit Frag: 5840
Max Recv Frag: 5840
Assoc Group: 0x0000b254
Num Ctx Items: 1
Ctx Item[1]: ID:1
Context ID: 1
Num Trans Items: 1
Abstract Syntax: ISystemActivator V0.0
Interface: ISystemActivator UUID: 000001a0-0000-0000-c000-000000000046
Interface Ver: 0
Interface Ver Minor: 0
Transfer Syntax[1]: 8a885d04-1ceb-11c9-9fe8-08002b104860 V2
Auth type: SPNEGO (9)
Auth level: Connect (2)
Auth pad len: 0
Auth Rsrvd: 0
Auth Context ID: 1277840
GSS-API Generic Security Service Application Program Interface
OID: 1.3.6.1.5.5.2 (SPNEGO - Simple Protected Negotiation)
SPNEGO
negTokenInit
mechTypes: 3 items
Item: 1.2.840.48018.1.2.2 (MS KRB5 - Microsoft Kerberos 5)
Item: 1.2.840.113554.1.2.2 (KRB5 - Kerberos 5)
Item: 1.3.6.1.4.1.311.2.2.10 (NTLMSSP - Microsoft NTLM Security Support Provider)
mechToken: 6E82050A30820506A003020105A10302010EA20703050020...
krb5_blob: 6E82050A30820506A003020105A10302010EA20703050020...
Kerberos AP-REQ
Pvno: 5
MSG Type: AP-REQ (14)
Padding: 0
APOptions: 20000000 (Mutual required)
Ticket
Tkt-vno: 5
Realm: COMPANY.NET
Server Name (Service and Instance): RPCSS/PC-ONE-LAP.company.net
enc-part rc4-hmac
Authenticator rc4-hmac


You can see it is using kerberos to authenticate.
Here is the response from the target PC:

DCE RPC Bind_ack, Fragment: Single, FragLen: 199, Call: 2
Version: 5
Version (minor): 0
Packet type: Bind_ack (12)
Packet Flags: 0x03
Data Representation: 10000000
Frag Length: 199
Auth Length: 131
Call ID: 2
Max Xmit Frag: 5840
Max Recv Frag: 5840
Assoc Group: 0x0000b254
Scndry Addr len: 4
Scndry Addr: 135
Num results: 1
Context ID[1]
Auth type: SPNEGO (9)
Auth level: Connect (2)
Auth pad len: 0
Auth Rsrvd: 0
Auth Context ID: 1277840
GSS-API Generic Security Service Application Program Interface
SPNEGO
negTokenTarg
negResult: accept-incomplete (1)
supportedMech: 1.2.840.48018.1.2.2 (MS KRB5 - Microsoft Kerberos 5)
responseToken: 606606092A864886F71201020203007E573055A003020105...
krb5_blob: 606606092A864886F71201020203007E573055A003020105...
KRB5 OID: 1.2.840.113554.1.2.2 (KRB5 - Kerberos 5)
krb5_tok_id: KRB5_ERROR (0x0003)
Kerberos KRB-ERROR
Pvno: 5
MSG Type: KRB-ERROR (30)
stime: 2007-08-30 10:19:06 (Z)
susec: 851504
error_code: KRB5KRB_AP_ERR_MODIFIED (41)
Realm: COMPANY.NET
Server Name (Principal): PC-TWO-LAP$

The response show an Kerberos error "KRB5KRB_AP_ERR_MODIFIED", as it is basically saying - hold on, my name is "PC-TWO-LAP" and not "PC-ONE-LAP".

In the System Event Log for the source PC, you will see the following:
Event Type: Error
Event Source: DCOM
Event Category: None
Event ID: 10009
Date: 30/08/2007
Time: 10:22:52
User: COMPANY\USER
Computer: SOURCEPC
Description:
DCOM was unable to communicate with the computer PC-ONE-LAP.company.net
using any of the configured protocols.

Event Type: Error
Event Source: Kerberos
Event Category: None
Event ID: 4
Date: 30/08/2007
Time: 10:22:52
User: N/A
Computer: SOURCEPC
Description:
The kerberos client received a KRB_AP_ERR_MODIFIED error from the
server PC-TWO-LAP$. This indicates that the password used to encrypt
the kerberos service ticket is different than that on the target server.
Commonly, this is due to identically named machine accounts in the
target realm (COMPANY.NET), and the client realm.

The explanation is that the DNS server was returning the same IP address for both "PC-ONE-LAP" and "PC-TWO-LAP". Only "PC-TWO-LAP" was actually connected to the network, but when we tried "PC-ONE-LAP", it was actually "PC-TWO-LAP" that responded.

Kerberos authenticates both the User and the Computer, so that is why we got the error. If you get this error, then check your DNS records.

For other similar problems you may find this link useful:
Failed to get remote resources: Remote server is unavailable. The RPC server is unavailable.

Monday, August 27, 2007

A problem with wget on OpenSolaris

Ok, here is a stupid little problem.I waisted an hour trying to figure this one out. Maybe this will help someone to avoid the same mistake!

I was using 'wget' to try to download a file from a http server onto my OpenSolaris PC. Here is what I did:
# uname -a
SunOS solaris 5.11 snv_60 i86pc i386 i86pc
# wget -V
GNU Wget 1.10.2
# cd /home
# /usr/sfw/bin/wget http://www.nwsmith.net/index.htm
--18:31:13-- http://www.nwsmith.net/index.htm
=> `index.htm'
Resolving www.nwsmith.net... NNN.NNN.NNN.NNN
Connecting to www.nwsmith.net|NNN.NNN.NNN.NNN|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 11,774 (11K) [text/html]
index.htm: Operation not applicable
Cannot write to `index.htm' (Operation not applicable).

Did you spot my mistake?
I must have thought I was using a Linux PC, because then the '/home' directory would have been fine. But on Solaris...
# ls -ld /home
dr-xr-xr-x 1 root root 1 Apr 18 00:03 /home

...you cannot write to that directory.
Choose a directory that is writeable, and then wget will work without error.

Thursday, August 16, 2007

fdisk, sfdisk, mdadm and SCSI hard drive geometry

At work, one of our servers, uses Linux software RAIDand we have two mirrored hard drives setup as RAID1.
Smartmontools reported that one of the hard drives was starting to fail:
# smartctl -a /dev/sda
SMART Health Status: LOGICAL UNIT FAILURE PREDICTION THRESHOLD EXCEEDED [asc=5d,ascq=2]
# smartctl -l selftest /dev/sda
SMART Self-test log
Num Test Status segment LifeTime LBA_first_err [SK ASC ASQ]
Description number (hours)
# 1 Background long Failed in segment --> 2 10572 0x 22f0e6c [0x4 0x40 0x85]
# 2 Background long Failed in segment --> 2 10404 0x 22f0e6c [0x3 0x11 0x0]
# 3 Background long Failed in segment --> 2 10236 0x 22f0e63 [0x4 0x40 0x85]

So we executed the following commands:
mdadm --manage /dev/md0 --set-faulty  /dev/sda1
mdadm --manage /dev/md0 --remove /dev/sda1
mdadm --manage /dev/md1 --set-faulty /dev/sda2
mdadm --manage /dev/md1 --remove /dev/sda2
mdadm --manage /dev/md2 --set-faulty /dev/sda3
mdadm --manage /dev/md2 --remove /dev/sda3
mdadm --manage /dev/md3 --set-faulty /dev/sda5
mdadm --manage /dev/md3 --remove /dev/sda5

And then hot un-plugged the drive.
When the replacement drive arrived, although it was an identical model
to the original, and had an identical total size, the new drive had a different geometry.
[root@ifsclstr02 ~]# smartctl -i /dev/sda
Device: IBM-ESXS BBD036C3ESTT0ZFN Version: JP86
Device type: disk
Transport protocol: Parallel SCSI (SPI-4)

[root@ifsclstr02 ~]# smartctl -i /dev/sdb
Device: IBM-ESXS BBD036C3ESTT0ZFN Version: JP85
Device type: disk
Transport protocol: Parallel SCSI (SPI-4)

# fdisk -l /dev/sda
Disk /dev/sda: 36.4 GB, 36401479680 bytes
64 heads, 32 sectors/track, 34715 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

# fdisk -l /dev/sdb
Disk /dev/sdb: 36.4 GB, 36401479680 bytes
255 heads, 63 sectors/track, 4425 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

The potential problem was that if we had to specify the start and end of the partition in terms of cylinders, then we would not be able to get an exact match in the size of the partitions between the new disk and the existing working half of the mirror.
After some googling, we concluded that having to align the partition boundaries with the cylinders was a DOS legacy issue, and was not something that would cause a problem for Linux.
So to copy the partitions from the working disk to the new disk we used the following:
# sfdisk -d /dev/sdb | sfdisk --Linux /dev/sda
Checking that no-one is using this disk right now ...
OK
Disk /dev/sda: 34715 cylinders, 64 heads, 32 sectors/track
Old situation:
Units = cylinders of 1048576 bytes, blocks of 1024 bytes, counting from 0

Device Boot Start End #cyls #blocks Id System
/dev/sda1 0 - 0 0 0 Empty
/dev/sda2 0 - 0 0 0 Empty
/dev/sda3 0 - 0 0 0 Empty
/dev/sda4 0 - 0 0 0 Empty
New situation:
Units = sectors of 512 bytes, counting from 0

Device Boot Start End #sectors Id System
/dev/sda1 * 63 208844 208782 fd Linux raid autodetect
/dev/sda2 208845 16980704 16771860 fd Linux raid autodetect
/dev/sda3 16980705 25366634 8385930 fd Linux raid autodetect
/dev/sda4 25366635 71087624 45720990 5 Extended
/dev/sda5 25366698 71087624 45720927 fd Linux raid autodetect
Warning: partition 1 does not end at a cylinder boundary
Warning: partition 2 does not start at a cylinder boundary
Warning: partition 2 does not end at a cylinder boundary
Warning: partition 3 does not start at a cylinder boundary
Warning: partition 3 does not end at a cylinder boundary
Warning: partition 4 does not start at a cylinder boundary
Warning: partition 4 does not end at a cylinder boundary
Warning: partition 5 does not end at a cylinder boundary
Successfully wrote the new partition table
Re-reading the partition table ...
# mdadm --manage /dev/md0 --add /dev/sda1
# mdadm --manage /dev/md1 --add /dev/sda2
# mdadm --manage /dev/md2 --add /dev/sda3
# mdadm --manage /dev/md3 --add /dev/sda5
# cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 sda2[0] sdb2[1]
8385856 blocks [2/2] [UU]

md2 : active raid1 sda3[2] sdb3[1]
4192896 blocks [2/1] [_U]
resync=DELAYED
md3 : active raid1 sda5[2] sdb5[1]
22860352 blocks [2/1] [_U]
[============>........] recovery = 61.8% (14148928/22860352) finish=2.1min speed=67707K/sec
md0 : active raid1 sda1[0] sdb1[1]
104320 blocks [2/2] [UU]

unused devices:

Using the sfdisk command, you can specify the unit of measure when listing the partition table. Use '-uS' for Sectors and '-uC' for Cylinders:
# sfdisk -l -uS /dev/sda
Disk /dev/sda: 34715 cylinders, 64 heads, 32 sectors/track
Warning: extended partition does not start at a cylinder boundary.
DOS and Linux will interpret the contents differently.
Units = sectors of 512 bytes, counting from 0

Device Boot Start End #sectors Id System
/dev/sda1 * 63 208844 208782 fd Linux raid autodetect
/dev/sda2 208845 16980704 16771860 fd Linux raid autodetect
/dev/sda3 16980705 25366634 8385930 fd Linux raid autodetect
/dev/sda4 25366635 71087624 45720990 5 Extended
/dev/sda5 25366698 71087624 45720927 fd Linux raid autodetect

# sfdisk -l -uS /dev/sdb
Disk /dev/sdb: 4425 cylinders, 255 heads, 63 sectors/track
Units = sectors of 512 bytes, counting from 0

Device Boot Start End #sectors Id System
/dev/sdb1 * 63 208844 208782 fd Linux raid autodetect
/dev/sdb2 208845 16980704 16771860 fd Linux raid autodetect
/dev/sdb3 16980705 25366634 8385930 fd Linux raid autodetect
/dev/sdb4 25366635 71087624 45720990 5 Extended
/dev/sdb5 25366698 71087624 45720927 fd Linux raid autodetect

It's only when you think in terms of cylinders, that there appears to be a problem:
# sfdisk -l -uC /dev/sda
Disk /dev/sda: 34715 cylinders, 64 heads, 32 sectors/track
Warning: extended partition does not start at a cylinder boundary.
DOS and Linux will interpret the contents differently.
Units = cylinders of 1048576 bytes, blocks of 1024 bytes, counting from 0

Device Boot Start End #cyls #blocks Id System
/dev/sda1 * 0+ 101- 102- 104391 fd Linux raid autodetect
/dev/sda2 101+ 8291- 8190- 8385930 fd Linux raid autodetect
/dev/sda3 8291+ 12386- 4095- 4192965 fd Linux raid autodetect
/dev/sda4 12386+ 34710- 22325- 22860495 5 Extended
/dev/sda5 12386+ 34710- 22325- 22860463+ fd Linux raid autodetect

# sfdisk -l -uC /dev/sdb
Disk /dev/sdb: 4425 cylinders, 255 heads, 63 sectors/track
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

Device Boot Start End #cyls #blocks Id System
/dev/sdb1 * 0+ 12 13- 104391 fd Linux raid autodetect
/dev/sdb2 13 1056 1044 8385930 fd Linux raid autodetect
/dev/sdb3 1057 1578 522 4192965 fd Linux raid autodetect
/dev/sdb4 1579 4424 2846 22860495 5 Extended
/dev/sdb5 1579+ 4424 2846- 22860463+ fd Linux raid autodetect

The pluses and minuses, just mean that the numbers are not exact and are rounded up or down.
For comparison, here is what fdisk reports:
# fdisk -l /dev/sda
Disk /dev/sda: 36.4 GB, 36401479680 bytes
64 heads, 32 sectors/track, 34715 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 102 104391 fd Linux raid autodetect
Partition 1 does not end on cylinder boundary.
/dev/sda2 102 8292 8385930 fd Linux raid autodetect
/dev/sda3 8292 12387 4192965 fd Linux raid autodetect
/dev/sda4 12387 34711 22860495 5 Extended
/dev/sda5 12387 34711 22860463+ fd Linux raid autodetect

# fdisk -l /dev/sdb
Disk /dev/sdb: 36.4 GB, 36401479680 bytes
255 heads, 63 sectors/track, 4425 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 * 1 13 104391 fd Linux raid autodetect
/dev/sdb2 14 1057 8385930 fd Linux raid autodetect
/dev/sdb3 1058 1579 4192965 fd Linux raid autodetect
/dev/sdb4 1580 4425 22860495 5 Extended
/dev/sdb5 1580 4425 22860463+ fd Linux raid autodetect