Wednesday, May 17, 2006

USB/BIOS hangs computer on boot

A friend of mine asked me to have a look at her computer, because it would not boot up anymore. It just showed a splash screen of the BIOS and waited there for several minutes. After that time it would suddenly continue booting, with normal speed and without any further problems.

I had seen such a thing before, however not that early after switching the power on: In one case an iPod had been connected to a USB port, another machine had a USB card reader attached. In both cases the machine hung right after all the power on self test (POST) messages and hardware detection at the point where it normally boots from a configured boot device. On both computers disconnecting the USB devices solved the delay immediately. It does not seem to affect USB devices other than storage devices. A mouse or keyboard did not cause any problems.

The computer at hand now had an internal card reader. I opened the case and unplugged it from the mainboard. That made it run through the POST in no time, no hangs, no delays. I could even plug it back onto the board, without getting the problem back (I wonder what caused it to fail in the first place, the reader has been there ever since). Seems to be some sort of a common BIOS or maybe even a hardware problem (just Google for "usb boot hang bios"), but it sure as hell is very annoying, especially with internally connected devices that cannot simply be unplugged.

Disk died of heat

In my previous post "S.M.A.R.T is your friend" I wrote about my Samsung SP1614C getting too hot, because I did not monitor its life signs with a S.M.A.R.T. tool.

I believe it has really taken damage, because Windows has been nagging me with several warnings about data not being read or written correctly in several files, e. g. the event log. So I decided to try to save whatever I could. I went to the shop and bought a new disk. Back home using another machine I then downloaded Acronis TrueImage as a trial version and created the rescue CD with it.

I mounted a new drive into the first computer and booted from the CD. Apparently it is Linux based, but they spent some effort to make it look like a Windows XP Luna GUI. Probably to comfort the "Windows only" people. :)

However, only after clicking my way all through the cloning-wizard it told me, that this particular function was unavailable in the trial version's rescue media. Very nice not to disable the whole thing in the first place... Only later did I notice the remark on their web site, that rescue media created with the trial version will not be able to clone hard drives. So, being somewhat unnerved, I got back to the shop to buy the full version. At least the installation CD is bootable and provides the rescue functions, so I did not have to burn another one.

Using that CD it was now very easy to set up the cloning. Cloning the whole disk with several partitions took around 45min. This means about 60MB/s if I am not mistaken. Not so bad I guess; I would have expected the process to take longer. I sure hope that getting no error messages about unreadable sectors means that the data made it over intact, not that it just did not notice that some garbage was copied... I guess if that happened I will sure find out in the worst possible moment in the future >:(.

Before rebooting I exchanged the SATA cables to make the new disk take the place the old one had before. Since then everything has worked perfectly. The old drive is still present, however as TrueImage removed the old disk's drive letter assignment, on the surface nothing has changed. Great tool, Acronis!

I will try and run Samsung's drive test utility on the old disk, maybe it will tell me something about its health. Surely it will never again see any important data, but maybe it is still suitable for e. g. the browser cache and things alike...

Monday, May 15, 2006

InnoDB fragmentation is NTFS fragmentation

In a previous post I wrote about a strange fragmentation of newly created InnoDB data files. Turns out that it's not InnoDB's fault, but Windows'.

I did some more tests and used a little script to just fill a bunch of files with 2GBs of garbage on a freshly defragmented partition. Same result: The files were not contiguous as one would expect, but scattered around the free space. So this clearly has something to do with NTFS's allocation strategy. If someone knows more about this, please feel free to leave a comment or drop me a line via email.

So if you really want contiguous data files for your MySQL database, first defrag your partition to get contiguous free space. After the create the data files and shutdown the database. Now defrag again, to have the data files be put together. From my experience more files of smaller size are easier to handle, because in order to have the defragmentation tool put them together it needs enough contiguous space to effectively put a copy there. I switched from ibdata files with 2GB each to 4x the number of files with 512MB each.

Sunday, May 14, 2006

Show non-present devices in Device Manager

Time and again I forget the environment variable that makes the Windows device manager show devices that are not connected to the system, but installed anyway. I note it here now to have point for myself to find it more easily in the future :)

The easiest way to use it (if you don't want to configure it permanently through the "System" applet in the control panel) is to first start a command line (cmd.exe) and then type the following commands:

set DEVMGR_SHOW_NONPRESENT_DEVICES=1
devmgmt.msc

In the device manager that starts up, you still need to enable the "Show Hidden devices" option in the "View" menu ("Ansicht/Ausgeblendete Geräte anzeigen" in a German Windows).

This will make the device manager show all devices that you installed but do not use anymore, e. g. USB drives you just connected once, mice and keyboards that have long been replaced etc. Sometimes those entries cause problems when you plug a similar device in, so deleting them might solve problems in that area.

S.M.A.R.T. is your friend

Yesterday I heard a frightening noise out of my PC. You know that sound when the hard disk reinitializes in the middle of the day, making a sound somewhat like "squeeeak-smack" (sorry, don't know how to describe it better)? As this is normally not a sound a healthy disk should ever make, I was immediately very tense.

Only then I realised that when I had installed my system the last time I forgot to install Panterasoft's HDD Health freeware. It is a tool that monitors your hard drives vital signs through the S.M.A.R.T. (Self-Monitoring Analysis and Reporting Technology; see Wikipedia for more details) interface incorporated in (almost) all modern drives.

I have always been wondering why there is no such thing in Windows out of the box, as it certainly is no very new standard and it is really a good thing to know in advance, when a hard drive is going to fail. Anyway, when I installed and started HDD Health it immediately told me about a disk temperature exceeding the critical limit on my Samsung hard drive. It was at 58°C, the recommended maximum specified by Samsung for my SP1614C (specifications here) being 55°C.

I don't know how long it has been exceeding the limit, but I sure ask myself why I mounted my hard drives into neighboring drive slots when I had another one free. So I re-mounted the lower disk to leave a 3.5" slot free between the two drives. Since then, the temperature has not risen above 38°C. I just hope, it did not take any permanent damage. Sure as hell I'll remember having the S.M.A.R.T. monitoring tool running from now on!

Tuesday, May 02, 2006

Strange InnoDB fragmentation

Follow-up posted here, have a look at it as well.

On my development machine I have been using an auto-extending ibdata table space file for several months (using MySQL 4.1.12 on Windows 2000 SP4 on an NTFS drive). Over time that file grew to some 20GB and was scattered around the whole hard drive. As this does not exactly boost database performance I decided to swipe everything clean and start with a set of new ibdata files, 2GB each and all created from scratch.

So I shut down the database server and deleted all tablespace files from the data directory. After that I ran a full defrag using O&O Defrag V8 Professional (trial available here) to create a continuous free area on the disk. I then reconfigured the MySQL configuration file and started the server.

It took its time to create 11 ibdata files of 2GB each. Then, just for curiosity, I let the defragger analyse the disk again, and could not believe my eyes: All those newly created files were wildly scattered around!

The following image shows the analysis result, taken immediately after the creation process. Red squares represent the ibdata files; all that space was free (white) before.

Defragger Screenshot

I do not really get it. Right now I am running the defragger again and it is puzzling the files together in a way I would have expected them to be in the first place (this being the whole point of recreating them). This is the mess it is cleaning now:

Cluster Inspector View

Any comments warmly appreciated. Is this an InnoDB/MySQL problem or is Windows/NTFS to blame for this?