2012-11-26

Untangling HBA multipath

How can you check what HBA is used for a given device?
If you are using multipath, which device is using which port?

Let's say we need to check /dev/sdc
First, check which scsi_device belongs to it:

# ls -l /sys/class/block/sdc/device/scsi_device/
drwxr-xr-x 3 root root 0 Jul 20 12:22 1:0:0:0/


The "1" above means that the device is seen through host1.
Now we can look at host1:

# cat /sys/class/scsi_host/host1/info
Emulex LPe11002-M4 4Gb 2port FC: PCIe SFF HBA on PCI bus 02 device 00 irq 66 port 1

so, it's the second port of an Emulex adapter.

2012-11-03

Calling out for a car key standard

Here are a couple of car keys from two different brands:


On the left, you have the lock button up the unlock button down.
On the right you have the unlock button up, and the unlock down.
The first has two raised bumps on the lock button and no bumps on the unlock.
The second has one bump on the unlock and no bumps on the lock button.

It's simply impossible to lock and unlock the car without getting the keys out of the pocket and looking at them.

2012-10-26

Nmap Portable

Sometimes you may have to run nmap from a Windows machine without installing anything.
It's possible to build a portable version of nmap that is somewhat limited (no winpcap), but still usable for a quick port scan.

First you'll need to build the portable package: use a windows machine where you have administrative access.
Download the Nmap windows binary file from here.
Install and run it at least one time to make sure all the DLLs were correctly extracted.
Now you'll have to manually put DLL from the MS VC Runtime in the same directory of nmap.

You'll need:
  • Microsoft.VC90.CRT.manifest
  • msvcp90.dll
  • msvcr90.dll
  • msvcp100.dll
  • msvcr100.dll
They may be in some unusual places like C:\Windows\winsxs\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.5570_none_509463cabcb6ef2aCopy them in the same directory of nmap.exe.

Now copy the whole nmap installation directory on an USB key, and you'll be able to run it from another machine without installing.

2012-10-21

Hillclimbing with the Yaris Hybrid

It's a common belief that hybrid cars are best suited for urban usage.
Last evening I went for dinner hillside near my home town.
It was a 68 Km round trip.
Here is the elevation profile of the road:



It's a 34 Km road that crosses several small towns, max speed was 80 Km/h due to several speed cameras.
Starting elevation is 97 meters, ending is 329.

Ending mileage was 3.9 L/100Km.
By comparison, the week-long average consumption of my all-urban travelling was 4.4.
It seems that hybrid cars are not only for the city.

2012-10-15

Mounting a disk image

Dumping a full disk is a quick way to perform a backup:

# dd if=/dev/sdb of=filename.dsk

But once you have such a dump, you can't directly mount it, you must use kpartx:

# kpartx -av filename.dsk
add map loop0p1 (252:0): 0 7830408 linear /dev/loop0 1144

You can see the partitions with fdisk

# fdisk -l /dev/loop0

Disk /dev/loop0: 4009 MB, 4009754624 bytes
128 heads, 22 sectors/track, 2781 cylinders, total 7831552 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xc3072e18

      Device Boot      Start         End      Blocks   Id  System
/dev/loop0p1   *        1144     7831551     3915204    b  W95 FAT32


Now you can mount the partitions that are inside the disk image.

# mount /dev/mapper/loop0p1 /mnt
# df -h
Filesystem           Size  Used Avail Use% Mounted on
/dev/sda5             31G   12G   18G  41% /
udev                 3.9G  8.0K  3.9G   1% /dev
tmpfs                1.6G  960K  1.6G   1% /run
none                 5.0M     0  5.0M   0% /run/lock
none                 3.9G  200K  3.9G   1% /run/shm
/dev/sdb5             20G  1.4G   18G   8% /home
/dev/mapper/loop0p1  3.8G  1.1G  2.7G  29% /mnt


Once you've done, you can umount it with

# umount /mnt
# kpartx -dv filename.dsk
del devmap : loop0p1
loop deleted : /dev/loop0


Note:
Ubuntu doesn't have kpartx installed by default:

# sudo apt-get install kpartx