2011-12-31

IPv6

The end of the year is time for some balance.
Even though I'm no network admin, knowledge of IP networking is the single most used technical skill in my day-to-day activities.
So, good will for the next year:



2011-12-30

OpenWRT on Asus WL-550gE


Recently my home wireless connection has been shaky: from 20% packet drops to lost connection from time to time.
So, after 6 years of flawless work, I've tried to install OpenWRT on my WL-550gE.
Even though the device is listed as supported, I haven't found any detailed procedure about installing the firmware.
Here is mine:
  • Download and install on a windows machine, the Asus Firmware Recovery Tool.
  • Get the latest OpenWRT image for the asus: note that even if it's a .trx file, upgrading with the router web interface isn't working.
  • Set the windows machine IP as 192.168.1.1/24 and connect it to the LAN1 port of the router.
  • Select openwrt-brcm-2.4-squashfs.trx in the Asus Firmware Recovery Tool but don't press Upload.
  • Launch a ping -t 192.168.1.1
  • Power off the router.
  • Keep the black RESTORE button on the back of the router, pressed and power on. Keep it pressed until the POWER LED begins flashing.
  • When the already running ping shows that the router is responding, press the Upload button in the Asus Firmware Recovery Tool.
  • The firmware will be uploaded and the router will reboot: note that after reboot the POWER LED will remain off.
  • Follow the firstlogin FAQ page to configure the router.

2011-12-25

Move the Start button to a better place, please

Redmond, UI Drawing Board committee, early nineties:

"Where should we put the menu bar?"
"Top border!"

"Where should we click the window to drag it?"
"Top border!"

"Where should we put the close button?"
"Top right!"

"Where should we put the minimize and maximize buttons?"
"Top right!"

"And finally, where should we put the Start button?"
"mmmmh... Bottom left!"



Who made that decision may be the Inspector Clouseau of UI Design.
He's responsible for billions of km of useless mouse travel between to most important elements of the user interface.
A better place would be the top row of the screen, as the Mac did in '84:


But I suspect that it wasn't done due to a possible legal issue.

Now that widescreens are the norm, there's a better place to put the taskbask: the right side of the screen:
It's closer to the menu, the gadgets and, by taking up some vertical space, it allows more 4:3-like space to the windows.



Even Unity has its deadly sins too...

2011-12-23

libfipscheck

Another yum mess:
After an apparently successfull yum update, sshd didn't start with the following error message:

/usr/lib/libfipscheck.so.1: file too short

The file was 0 bytes.
Where does it come from?

# yum provides libfipscheck.so.1

fipscheck-lib-1.2.0-1.el5.i386 : Library files for fipscheck
Repo        : rhel-5.5-x86_64
Matched from:
Other       : libfipscheck.so.1

the package was installed but somewhat corrupted, so I reinstalled it:

# yum reinstall fipscheck-lib

after that, sshd started fine.

2011-12-22

Ubuntu-style Putty

Designing a custom font was a stroke of genius from the Ubuntu team.
It gave instant recognisability to the distribution and it boosted ergonomics as well.

I'm currently using the same font even on Windows in my Putty sessions:



The Ubuntu fonts can be downloaded from http://font.ubuntu.com/
Unzip and copy into the Windows fonts folder.
Set Putty to use "Ubuntu Mono 12" with the Antialiased flag.

Here's the reg file for the above configuration:

--- CUT HERE ---

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\Default%20Settings]
"Font"="Ubuntu Mono"
"FontIsBold"=dword:00000000
"FontCharSet"=dword:00000000
"FontHeight"=dword:0000000c
"FontVTMode"=dword:00000004
"UseSystemColours"=dword:00000000
"TryPalette"=dword:00000000
"BoldAsColour"=dword:00000001
"Colour0"="187,187,187"
"Colour1"="255,255,255"
"Colour2"="45,15,44"
"Colour3"="85,85,85"
"Colour4"="0,0,0"
"Colour5"="0,255,0"
"Colour6"="0,0,0"
"Colour7"="85,85,85"
"Colour8"="187,0,0"
"Colour9"="255,85,85"
"Colour10"="0,187,0"
"Colour11"="85,255,85"
"Colour12"="187,187,0"
"Colour13"="255,255,85"
"Colour14"="0,150,187"
"Colour15"="85,170,255"
"Colour16"="187,0,187"
"Colour17"="255,85,255"
"Colour18"="0,187,187"
"Colour19"="85,255,255"
"Colour20"="187,187,187"
"Colour21"="255,255,255"
"BoldFont"=""
"BoldFontIsBold"=dword:01000000
"BoldFontCharSet"=dword:00000007
"BoldFontHeight"=dword:00000000
"WideFont"=""
"WideFontIsBold"=dword:00000003
"WideFontCharSet"=dword:00000000
"WideFontHeight"=dword:0000000a
"WideBoldFont"=""
"WideBoldFontIsBold"=dword:00000000
"WideBoldFontCharSet"=dword:00000000
"WideBoldFontHeight"=dword:343232e8
"ShadowBold"=dword:00000000
"ShadowBoldOffset"=dword:00000001
"FontQuality"=dword:00000003
"ANSIColour"=dword:00000001

--- CUT HERE ---

Yum headaches

After a yum update on a workstation, I've found the root mailbox full of messages like this:

/etc/cron.daily/0logwatch:
Undefined subroutine &main::TimeBuild called at /etc/cron.daily/0logwatch line 846.
}
{


The yum itself had problems:

# yum
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:

   cannot import name RpmUtilsError

Please install a package which provides this module, or
verify that the module is installed correctly.

It's possible that the above module doesn't match the
current version of Python, which is:
2.4.3 (#1, Apr 14 2011, 20:42:01)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)]

If you cannot solve this problem yourself, please go to
the yum faq at:
  http://wiki.linux.duke.edu/YumFaq

I've reinstalled yum

rpm -iv yum-3.2.22-37.el5.noarch.rpm rpm-python-4.4.2.3-22.el5.i386.rpm rpm-4.4.2.3-22.el5.i386.rpm
rpm-apidocs-4.4.2.3-22.el5.i386.rpm rpm-build-4.4.2.3-22.el5.i386.rpm rpm-devel-4.4.2.3-22.el5.i386.rpm rpm-libs-4.4.2.3-22.el5.i386.rpm

and yum was back in action, but there were other problems:
with an rpm -qa I looked at the installed packages and they appeared to be less than usual.
For example there was no mkinitrd package installed but the mkinitrd command was right there.
Probably the rpm database was corrupted but an

# rpm --rebuilddb

sorted no different effect.
I did an rpm -qa on a similarly configured workstation and compared it with the rpm -qa of this machine: there were more than 140 rpms missing.
I extracted the missing list and reinstalled all of them with a big yum install command

# yum install \
NetworkManager \
NetworkManager-glib \
NetworkManager-gnome \
a2ps \
at-spi \
at-spi-devel \
autofs \
avahi \
avahi-compat-libdns_sd \
...and 140 more...




2011-12-19

VMWare Memory Overhead

While sizing ESX hosts you must include the RAM ESX itself uses for VM book keeping.
Here's a table of Memory Overhead for tipical VM sizes:

VM Size 1G 2G 4G 8G
1cpu 134.80 150.89 183.06 247.39
2cpu 173.29 197.40 245.62 342.05
4cpu 214.05 238.16 286.38 382.80

All values are in MB... or should I say MiB?

The most influential book from my bookshelf

The UNIX Programming Environment, by Brian Kerningham & Rob Pike.


This is the only book from school I still read from time to time.
It wasn't even a mandatory one: just a suggested reading for the computer science lab back in '89.
The title is somewhat misleading: it's not about programming as much as about philosophy.
I can actually say that this book has somewhat shaped my way of thinking.
It's worth reading even for people that doesn't work on unix machines: the Bladelogic Network Shell is based on these concepts as well.

2011-12-14

Kibibyte, Mebibyte and Gibibyte

What's all this nonsense I see more and more?
When I was a child I learned that 1KB was 1024 bytes.
Now someone says that 1024 bytes are really 1KiB.
Wikipedia says: "However, as of 2011 adoption has been slow and usage has been limited in the marketplace and in the press": just ask yourself why...
And all this mess started when HD manufacturers started selling 100.000.000.000 bytes HDs pretending they were 100GB.
It's just like if car manufacturers had measured fuel efficiency in Kilometers per Litre and the gas stations would sell litres of 900 ml.

2011-12-11

Pinball Dreams

My 3 and 1/2 years old daugther is starting to enjoy complex games.
I introduced her to a game that resemble to something physical that she can relate to.
Balls are something kids are always fascinated about, and she is no exception, so I thought about pinball.
Back in the early 90's, the state of the art was Pinball Dreams for Amiga, for which I have very fond memories.
With a little search, I discovered that there's a PC version that's also been declared abandonware and released as freeware.
DOSBox runs it fine, but with default settings the pinball table is vertically compressed.
A little editing of the dosbox.conf file restored proper graphic glory:


Here are the settings other than defaults:

windowresolution=1200x900
output=opengl

edit resolution according to your graphic mode

aspect=true
scaler=none

that's the trick to restore proper aspect ratio to the table itself.

2011-12-06

P2V RedHat 6

While virtualizing a RedHat RHEL 6.2 machine, I've made a pleasent discovery: after cloning the disk, the VM booted without any initrd rebuild.
The source was an HP BL460 G7 and the target VM was created with the VSphere wizard using a typical Red Hat 6 x64 configuration: version 7 vm, paravirtual scsi, vmxnet3 networking.
The VMDK was created as big as the source physical disk.
I've followed the procedure for RedHat 5 P2V, with one notable exception: the internal disk on RedHat 6 is called /dev/sda even if it's really a SmartArray RAID drive.
After the ssh command:

# ssh root@P "cat /dev/sda | gzip -1 | cat" | gzip -d >/dev/sda

I've simply rebooted the VM and it came up on the first try.

2011-12-04

HP-UX disk info

HP-UX seems to be shy about telling info about LUNs in an ioscan.
This little script show WWID and size of all the LUNs known to a system.

scsimgr -v get_info all_lun | awk '      \
/STATUS INFORM/ { buffer = $6" " }       \
/internal stat/ { buffer = buffer$6" " } \
/WWID/          { buffer = buffer$6" " } \
/Vendor/        { buffer = buffer$4" " } \
/Product id/    { buffer = buffer$4" " } \
/Capacity/      { blocks = $7 }          \
/size in byt/   { bsize = $6 ; giga = blocks * bsize / 1073741824 ; buffer = buffer" "giga"GB" ; print buffer } \
'

It's too bad scsimgr in releases before 11.31 works differently.
In older machines, we need to extract info from ioscan and process them with diskinfo.

for i in $(ioscan -nfkC disk | grep rdsk | awk '{ print $2 }')
do
        print -n $i
        diskinfo $i | awk '              \
BEGIN           { buffer = " " }         \
/vendor/        { buffer = buffer$2" " } \
/product/       { buffer = buffer$3 }    \
/size/          { giga = $2 / 1048576 ; buffer = buffer" "giga"GB" } \
END             { print buffer }         \
'
done

Expanding the C drive of a VM

This was tested on Windows 2003 R2

Here's a VM that need its C drive expanded:


Edit VM Setting and set the new VMDK size (this can be done online).


Rescan disks, and you'll see extra free space at the end of the partition.


Now boot into Parted Magic.
Select the first partition, click Resize and set the new size.


You will have to select Apply to actually do the resize.

Reboot into Windows.
CHKDSK will run automatically and finally you will have your expanded C drive.

Shrinking the root filesystem

The default install of RedHat 5 fills the entire disk with the root filesystem: this may backfire later during machine lifetime.
Here's a way to resize the root filesystem.
Note that while the size increase can be done online, as of RedHat 5, size reduction must be performed in rescue mode.

Here's a tipical installation:

# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                      7.7G  3.1G  4.3G  42% /
/dev/sda1              99M   19M   75M  21% /boot
tmpfs                 502M     0  502M   0% /dev/shm

# vgdisplay -v
    Finding all volume groups
    Finding volume group "VolGroup00"
  --- Volume group ---
  VG Name               VolGroup00
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               9.88 GB
  PE Size               32.00 MB
  Total PE              316
  Alloc PE / Size       316 / 9.88 GB
  Free  PE / Size       0 / 0
  VG UUID               CJqD4r-kRQM-Cj9e-XwOr-6dn8-TkPH-MfTTyZ

  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                d4iToX-8m0c-jf9s-sMMN-VDpO-brE8-4kWhf2
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                7.91 GB
  Current LE             253
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol01
  VG Name                VolGroup00
  LV UUID                kEzo7d-AHuv-xiPD-3Qbo-v8yY-6w1D-DFMIwN
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                1.97 GB
  Current LE             63
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

  --- Physical volumes ---
  PV Name               /dev/sda2
  PV UUID               7bPvQd-H8yE-v00N-asPT-WQ92-6oCS-bBh6nj
  PV Status             allocatable
  Total PE / Free PE    316 / 0

The physical volume is full, with 0 free extents.

We are going to reduce / size to 6GB.
Boot in rescue mode

boot: linux rescue

Skip existing installation detection.
Activate existing volume groups:

# lvm vgscan
# lvm vgchange -ay /dev/VolGroup00

Run a filesystem check before resizing:

# e2fsck -f /dev/VolGroup00/LogVol00

Set the filesystem size a litte less than required, so the resizing of the underlying logical volume won't cut short the filesystem itself.

# resize2fs /dev/VolGroup00/LogVol00 5G

Resize the logical volume to the target size.

# lvm lvresize -L 6G /dev/VolGroup00/LogVol00

Now resize again the filesystem without giving any size, so it will fill up the logical volume.

# resize2fs /dev/VolGroup00/LogVol00

Reboot back into the system.
You can see the new / size:

# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                      5.9G  3.1G  2.7G  54% /
/dev/sda1              99M   19M   75M  21% /boot
tmpfs                 502M     0  502M   0% /dev/shm

# vgdisplay -v
    Finding all volume groups
    Finding volume group "VolGroup00"
  --- Volume group ---
  VG Name               VolGroup00
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               9.88 GB
  PE Size               32.00 MB
  Total PE              316
  Alloc PE / Size       255 / 7.97 GB
  Free  PE / Size       61 / 1.91 GB
  VG UUID               CJqD4r-kRQM-Cj9e-XwOr-6dn8-TkPH-MfTTyZ

  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                d4iToX-8m0c-jf9s-sMMN-VDpO-brE8-4kWhf2
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                6.00 GB
  Current LE             192
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol01
  VG Name                VolGroup00
  LV UUID                kEzo7d-AHuv-xiPD-3Qbo-v8yY-6w1D-DFMIwN
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                1.97 GB
  Current LE             63
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

  --- Physical volumes ---
  PV Name               /dev/sda2
  PV UUID               7bPvQd-H8yE-v00N-asPT-WQ92-6oCS-bBh6nj
  PV Status             allocatable
  Total PE / Free PE    316 / 61

And the physical volume now has some spare space left.