Saturday, March 22, 2008

Finding The Fastest Host

I play on Server 3 of Travian UAE, and the domain name points at 19 different hosts, and most are slow for me.

The lines below show how to get the server with the lowest average ping time. This assumes the servers will reply to ping requests (only one doesn't), and that you're not blocking ping requests from your end.

for i in $(host | awk '{print $4}'); do echo -n "$i:" >> trav.txt \
&& ping -qc5 $i | tail -n1 | cut -d/ -f5 >> trav.txt; done
sort -t: -k2 trav.txt | head -n1
rm trav.txt

Put the result in /etc/hosts and you're all set! This should save you time when querying for DNS, and wouldn't depend on your luck at which server you get (even though Travian employ round robin)

* This is not to be used with any website, since most have MX records (mail server records) and the script above doesn't work in such cases.

* You can remove the backslashes above and write the whole thing in one line. I put on multiple lines to make it readable.

The script is no longer useful since they moved to one server now. Seems like they distribute to multiples during registration period.

Sunday, March 16, 2008

NFS Mapping and Mass Group Ownership Change

Right to the point: 2 Unix (AIX 5.3L) servers with NFS directory one needs to be mounted on the other. The catch? Both must have the same user & group, and both the user & group must have the same IDs.

Since the target server (NFS Client) must stay intact, I had to change the group ID (GID) on the other box, then apply the new ID to all the files & directories on the system.

I changed the GID from old to new using smitty, AIX's administration interface utility. Then I applied the following script to all files & directories on the NFS Server:
find / -group 206 -exec chgrp 320 {} \;

"find" will look for all files & directories with the old GID, which is 206*, and when found, it will run "chgrp" to change its group to 320.

* Since there is no longer a group name associated with the old GID, it shows as a number when "ls"

chgrp can take the group name: chgrp "groupname" -- but I used the numerical value anyway.

P.S.: I had a moronic idea of running chgrp recursively, that is:
find / -group 206 -exec chgrp -R 320 {} \;

Thank God, I had a wakeup call before running that, because if I did, it would change the GID of ALL files & directories under a directory that matched the old GID, so this would've changed directories & files that might have had a different GID.

After all that, mounting NFS worked like charm & I no longer had mapping issues. Mounting was done as:
mount blade6:/path/to/dir /path/to/dir

P.S.: mounting the directory, then running chown on it is a dumb idea, because it would change the GID on the NFS Server.

Thursday, March 13, 2008

RAM and BIOS Upgrade

I've been contemplating buying new RAMs for months and been looking for the proper brand, price, capacity & speed.

My machine, code name: Adrenalin, has 2x 1GB of Kingston RAM; they're beautiful, fast & do the job, but they're just not quite enough for my kind of [ab]usage.

I tried buying from and, and as newegg was clear that they won't accept VISA, AFTER registering & reaching the payment page, failed at it, and not only that, my questions via email went unanswered for days and when got a response, it was totally irrelevant to my questions!!! The only quick response I got from them, is when I emailed them to cancel my order, in which they did within 2 hours!

Luckily, I found the same piece I was looking for on Amazon, at the same price of TigerDirect; In fact, Amazon gets the item from TigerDirect themselves!

I was after Corsair XMS2 DHX 2x 2GB kit RAM, and though the CAS latency is higher than the Kingston that I had, it wouldn't make much of a difference to me.
This piece of RAM is absolutely amazing: Not only do you get high-grade RAMs, you also get an amazing heat-sink design and a life-time warranty!

I ordered 2 kits, totalling in 8GB of RAM to fill all my 4 DIMMs, and have been waiting for them to arrive for 2 weeks, and today I got them, went back home and started the upgrade ritual.

0) Open a shell and write down the uptime: "up 42 days, 10:52"
1) Download memtest+ ISO file & burnt it
2) Shutdown machine & keep power cord connected
3) Clean dust & wash fan filter
4) Open case and touch internal metal body to discharge static electricity
5) Remove old RAMs & grab a pocket-knife & start cutting the cover of new RAMs before checking if it can be opened by hand
6) Open RAM cover by hand
7) Enjoy the beauty & smell the fresh scent of the hardware pieces
8) Anxiously & carefully install new RAMs
9) Power up & enter BIOS to make sure correct values for RAM are detected
A) insert memtest+ media to thoroughly test all RAMs -- passed

After that, I booted into Windows (XP 64-bit) to check for BIOS updates, which I found, and downloaded manually after the ASUSupdate program failed to download the needed file.
It was straight forward: Open AsusUpdate & choose "Update From File" then select the BIOS .BIN file and click away. Almost.

There was an option to reset the BIOS settings to the factory default after flashing the new BIOS version, and since I didn't want to go through the whole configuration process, I unselected it and flashed the new BIOS. After rebooting, the machine wouldn't start. PANIC ATTACK!
I thought the BIOS is being flashed after a reboot, which is not what used to happen before, and waited for 2 minutes, yet nothing happened, so I shutdown & powered up again, and nothing happened.

I run to my sister's room to find that she's not there, but her laptop is; PERFECT! I snag it and surf away to Asus's website and grab the manual, then I find that I'm downloading the Chinese manual, so I cancel & hunt for the English manual.
After the manual downloaded & unpacked, the BIOS has a recovery mode for cases where flashing the BIOS goes wrong (EXCELLENT!) -- the problem is that the screenshots assume that the machine would boot and I'd be able to see text on the monitor, which I didn't. Failure.

I go back to my room, calculating the cost of sending the motherboard to Asus and the time I'd have to spend without my baby -- then I remembered the option which I unselected.
I remove the BIOS battery & unplug the power for a minute, then put the battery back & hook the power. Power up. IT'S ALIVE!
Seems like the nwe BIOS wasn't fond of the old BIOS's settings! Anyway, I configure my stuff again and all goes smooth.

Lessons learned: None.

-> Pictures.

Internet Shopping: Dreaming of Things You Will Never Purchase

The Internet provided means of reaching people without boundaries, beyond borders and resulted in a huge expansion in International freight & logistics services expansion.

However, post 9/11 events, the US & EU have "tightened security", along with credit card companies, and made everyone outside their region miserable, by requireing ridiculous set of rules that reduced (if not prevented) International trade over the Internet.

Many great websites like & wee considered the best places to purchase computer hardware & accessories, because of the low prices compared to the local market (assuming the local market had it in the first place) and because of the wide variety of items, that they offer. Unfortunately, due to the reasons mentioned, those websites can't sell to anyone unless they verify his/her identity, by requesting name, VISA card, social security number & residence, and all this info must match that registered on the VISA, otherwise, you're considered a fraudster and denied transaction (if not reported to VISA & police as well!!)

The problem with such websites (I had personal experience with them), is that they do not mention that they accept American credit cards or paypal accounts only, and people like me end up going through the whole search-purchase-wait-disappointment process. It would help a lot, if they would mention that fact in their FAQ or at least in the payment page... It would save us the time and look for other sites, and them the time to attend to useless orders & emails.

In the past 2 years, our local market has become a monopoly where most shops agree on a certain price for all items, and the victim is the consumer, and the only way out is to purchase from the Internet, and now that famous websites are being locked out, we're forced to turn to non-famous websites that may in fact be a total rip-off. So how did the credit card companies reduce fraud? I have no idea.

So, where do I get my stuff from? Mostly, which for some reason, does accept International VISA and doesn't enforce ridiculous rules on the buyers.
The problem? They're not a computer house, and even though have some things, it's just not the place for the computer-holic to get his/her dosage of hardware & accessories, not to mention price differences, as they tend to be higher than websites like newegg.

If any of you have a way to purchase things from the US or EU without pleading & begging in emails to companies, please let me know!

Monday, March 3, 2008

Data Recovery: Hard Disk Surgery

A friend of mine brought a disk that wouldn't work when connected to a machine.

As soon as I hooked the disk to my box, it restarted and refused to start, with all lights blinking madly. Seems like a short-circuit caused that to heappen, so I replaced his case and put the disk in my case and this time: No short-circuit.

The OS booted, but running "lsusb" command showed nothing on the USB bus. When I replaced the case, the pins of his disk interface were a bit bent and I had to straighten them to be able to hook my case's PATA-to-USB (PATA = Parallel ATA) interface.

So, I thought, maybe the controller board itself, which has the PATA interface is damaged somewhere. Lucky for him, I had a disk of the same brand & model number, so I took mine out and put it on his disk. After doing that, I hooked it to the USB port on my machine, and still nothing on the USB bus.

After all easy & safe attempts were futile, the next step was to open the disk's case and look inside at what's really going on. During the previous attempts, I could hear a tiny sound of an attempt to read then failure, so hopefully now I'd be able to inspect further more.

After unscrewing all these tiny pesky screws with proper tools, it turned out that the disk's mechanical head was jammed. I tried nudging it and moving it with the screwdriver, but it seems it was stuck for good. This means, the whole disk housing is useless now, and the only way to get the data is by moving the disks from one hard disk to another. This was much tougher than I had anticipated and took me around 2 hours to carefully move the parts.

The disk heads rest at the edge of the disk, barely touching it, but they don't allow you to take the disks out. In order to do that, there's a white plastic piece, which has grooves where disks lay in, that should be removed first, in order to properly remove the disks. The heads, also partially rest on this plastic piece, and to take the piece out without damaging the heads, the heads must be moved to the inner-side of the disks -- This is by no means an easy task!!!

Pushing the heads by finger also got them bent. To be exact: The heads have small buds that hang by a very tiny piece of wire. These buds are the parts that touch the disks and read/write the data; the heads only work on moving these buds around the disks while the disks spin. I pushed one of the buds a bit to the top, to be able to push the heads safely to the inner part of the disk -- This was a major mistake. Pushing the bud inside rendered it dead and MY disk was no longer readable!!!

So, the whole salvation operation failed and resulted in 2 deaths. The only thing gained from this was experience on how to deal with these in the future, and the fact that I need a magnifier to be able to deal with the heads.

I should mention that I got my screwdrivers from: Al-Nisif warehouse, in Canada-Dry street, Shuwaikh. I'll get their exact info later.

Below are pictures I took while performing the operation.