TideLog Archive for the “Home Computing” Category

I’ve had this problem a few times on my laptop. It occurs mostly when the power suddenly goes off and it switches to battery. You lose all capacity monitoring, and can’t tell how much is left. The system tray icon changes to this:

no battery detected

Microsoft’s forums are hilarious. Their “Most Valuable Professionals” give the funniest canned cut ‘n’ paste responses, from, “Your power driver is corrupt” to your “Windows needs reinstalling!”. I know exactly what causes it, and it ain’t anything to do with “power drivers” or corrupt Windows. It’s the little monitoring chip in the battery. Like a lot of integrated electronics, it sometimes gets confused. Sudden switchovers from mains to battery tend to cause it, especially if there’s any surges from the battery as it kicks in.

The age old advice of “Reboot!” is the wise advice. If that doesn’t cure it, turn your machine off, remove the mains and battery, and hold your power button down to discharge the circuitry in your device (apart from the RTC circuit, but this doesn’t matter), that should cure it. Removing the battery opens the circuit to the sensing system in the battery, and resets it.

Simples. I hate MVP’s, they go on a 5 day course and think that gives them a Professional title? I’ve done MVP courses, but have the skills and years of software and electrical experience to further and back them up

Comments No Comments »

Bad sectors are little clusters of data on your hard disk that cannot be read. More than that, though, they have the potential to cause real damage to your hard drive (catastrophic failure) if they build up over time, stressing your hard drive’s arm, which contains the read/write head, there are two for each platter, one for each side. Bad sectors are fairly common with normal computer use and the imperfections of the world we live in. Like chip fabrication and LCD panel manufacturing, HDD manufacture is a very critical, precise process, and like a TFT with bad pixels from the factory, you do get bad sectors with a HDD due to imperfections when it’s made. The manufacturers make legal allowances for a certain limit to these imperfections before warranty claims can be made, like the legal limit of 5 dead pixels on a TFT. However, there are several simple steps you can take to prevent HDD bad sectors and to repair any that you do have. Having bad sectors will slow down computer performance as well, as your drive takes time attempting to read them. Here is a step-by-step guide. The most common questions I get as a computer engineer are “What is a sector?”, and “How are HDD bad sectors created?”

A sector is simply a unit of information stored on your hard disk. Rather than being a mass of fluid information, your hard disk stores things neatly into “sectors”, a bit like us humans putting things into boxes, and the box only holds so much, and all boxes are the same size. The standard sector size is 512 bytes.

There are various problems that can cause HDD bad sectors:

  • Improper shutdown of Windows, especially power loss while the HDD is writing data;
  • Defects of the hard disk, including general surface wear, pollution of the air inside the unit due to a dirty or clogged air filter, or the head touching the surface of the disk;
  • Other poor quality or aging hardware, including dodgy data cables, an overheated hard drive, and even a power supply problem, if your drive’s power is erratic;
  • Malware.

Hard and soft bad sectors

There are two types of bad sectors – hard and soft.

Hard bad sectors are the ones that are physically damaged (that can happen because of a head crash if your drive is dropped while running and writing data), or in a fixed magnetic state. If your computer is bumped while the hard disk is writing data, is exposed to extreme heat, or simply has a faulty mechanical part that is allowing the head to contact the disk surface, a “hard bad sector” might be created. Hard bad sectors cannot be repaired, but they can be prevented. The heads of a hard drive float on the air cushion generated by the platters spinning, they fly less than the width of a human hair away from the platters, even a small speck of dust is like a mountain, so knocks are definitely to be avoided.

Soft bad sectors occur when an error correction code (ECC) found in the sector does not match the content of the sector. Whenever a file is written to a sector, the drive calculates a “checksum”, which is used to verify the data, if it doesn’t match upon read, the drive knows the sector is weak. A soft bad sector is sometimes explained as the “hard drive formatting wearing out”, in other words the magnetic field is weakening, like an old video cassette – they are logical errors, not physical damage ones. These are repairable by overwriting everything on the disk with zeros. Like tapes and CD’s, the magnetic surface on a hard disk is not infinite, it is affected by other magnetic fields around it, so data recovery guys like me recommend regularly imaging a drive directly to another, frequently, to keep the data fresh and readable.

Preventing bad sectors

You can help prevent bad sectors (always better than trying to repair them, as they say prevention is better than cure!) by paying attention to both the hardware and the software on your computer.

Preventing bad sectors caused by hardware:

  • Make sure your computer is kept cool and dust free;
  • Make sure you buy good quality hardware from respected brands. Cheap RAM and power supplies are my biggest culprits from experience;
  • Always move your computer carefully, and make sure it is TURNED OFF, not in Sleep mode, it can wake up while being moved, especially a laptop;
  • Keep your data cables as short as possible;
  • Always shut down your computer correctly – use an uninterrupted power supply if your house is prone to blackouts.

Preventing bad sectors using software

  • Use a quality disk defragmenter program with automated scheduling to help prevent head crashes (head crashes can create hard bad sectors). Disk defragmentation reduces hard drive wear and tear, thus prolonging its lifetime and preventing bad sectors;
  • Run a quality anti-virus and anti-malware software and keep the programs updated.

Monitoring bad sectors

If you use a tool like HD Sentinel, or CrystalDiskInfo, and you notice bad sectors on your drive, keep an eye on it. A few sectors bad is not normally a problem, as I mentioned at the start of the article, up to 5 bad pixels on a new TFT is allowed before it becomes a warranty claim, hard drives are allowed a few bad sectors due to the imperfections of their manufacturing process. They are manufactured with what are known as “reserved sectors”, a spare area of the disk only accessible by the controller board. If a sector is weak, the controller will attempt to move the data to the reserved area, if this is successful it then attempts a quick read/write test on the old sector (takes less than a few milliseconds), if it fails it marks it as bad in the sector map, also stored in the drive reserved area, along with drive firmware, so that it doesn’t attempt to use it again.

If the number of bad sectors starts increasing, or you start to experience other symptoms, such as the drive dropping out completely as if you unplugged it, or any clicking, and data taking longer to read or copy, this could indicate a fault with the read/write heads, or the control circuitry. Stop using it immediately and back up any important data to another drive. If the failing drive is under warranty, print a log off from HD Sentinel and take it along with you to return the drive, as evidence.

S.M.A.R.T Values to look for

When looking at S.M.A.R.T (Smart Monitoring And Reporting Tool) analysis, the two main areas to look out for are:

Reallocated Sector Count

This shows how many of the drive’s Reserved sectors have been used. If too many of these are used it generally indicates a problem with the disk surface.

Current Pending Sector

This shows how many bad sectors are currently pending a rewrite. A hard drive will always try to rewrite the sector, if it fails, the sector is reallocated into the reserved, the drive adds the sector on to the Reallocated Sector Count, and the original sector is then marked as unusable. If the rewrite is successful, the Pending Sector count will drop.


Comments No Comments »

I’ve had a keen interest on the Elementary OS Project. Now, you might think from reading my blog, that I’m extremely anti-Apple, so you’re thinking, “Why does he like an OS that LOOKS like Mac OS? Well, firstly it’s Her Ladyship Kana’s fault for introducing me, and secondly, the looks are where the similarities stop dead. It’s an exciting and kinda novel concept: bringing a rigorous focus on user experience  (Apple’s main focus, style over substance) to the Linux desktop, as Elementary only comes with a very bare set of apps, such as Midori (Kana’s mum’s name, such a sweet name for a Japanese woman!) as a web browser, it doesn’t come with an office suite, like Mint, it’s quite lightweight. Recently, they released their second beta of the second version, v0.2, of their operating system, called Luna. It’s been a while since I’ve run Luna (last time my experience was too unstable for a production environment), so I decided to install VirtualBox and virtualize this second beta. My experience was riddled with problems and gotchas until I tweaked it, so I thought I would share my notes with everyone in case any are interested in trying it themselves.

Note one, this is a biggie, DO NOT settle for running this VM at default Virtualbox settings, it WILL run like a dog chasing a stick in treacle. I’ll walk you through optimizing it later.

Installing/Setting-up VirtualBox

Even installing VirtualBox is arduous under Linux, I always prefer Windows as host for virtualization, but seeing as I’m considering a switch to Linux from Windows, I thought I’d test my skills from Kana’s training me. For some reason, VirtualBox under recent versions of Ubuntu is a miserable experience. It seems like I always get this error when I try to set up a new virtual machine:

Kernel driver not installed (rc=-1908)

The VirtualBox Linux kernel driver (vboxdrv) is either not loaded or there is a permission problem with /dev/vboxdrv. Please reinstall the kernel module by executing

‘/etc/init.d/vboxdrv setup’

as root. If it is available in your distribution, you should install the DKMS package first. This package keeps track of Linux kernel changes and recompiles the vboxdrv kernel module if necessary.

And when I follow its advice (by running `/etc/init.d/vboxdrv setup`), the program fails. Apparently, Kana told me as she settled next to me after watching me pull my hair out, the key is installing the generic linux headers FIRST, like so: `sudo apt-get install linux-headers-generic`; however, Kana also tweaked it for per-user, try it in case your environment differs from mine:

sudo apt-get install linux-headers-`uname -r`

Download the Elementary Beta 2 ISO

The next step is downloading the ISO, links for torrents and traditional downloads which can be found on this page. I used wget to download the ISO; however, my connection was interrupted and trying to resume it seemed to have corrupted the file (or at least VirtualBox didn’t like it), so if you really want to use a traditional download (that is, over HTTP, like me), make sure you get it in one shot. Otherwise, I recommend using a torrent, but depending on the version, an age of torrent, the number of seeders, hence the speed, may vary. Once you have that, setup a new VM, point its CD drive at the ISO, and then make the following changes:

Under Display, make SURE you check, “2D & 3D Acceleration”, and make double sure you give it enough System and Video RAM, other wise the forementioned dog-chasing-stick-in-treacle symptom will appear, and it’s laggy as hell. Elementary relies heavily on GPU acceleration. IMPORTANT: If you install Elementary and change the settings afterwards, you WILL need TWO restarts to get everything working properly, as Linux configures itself, as far as it’s concerned you’ve swapped out the graphics card for an accelerated one so it’ll need to adjust itself, and the VirtualBox additions files configs.

Putting the final touches on your VM

Now that you have your Luna VM set up and the OS installed, you may find that the default resolutions provided by VirtualBox (I think I had 800×600 and ~1200×700) too small for your monitor (my laptop supports 1920×1200), so you’ll want to change your VirtualBox configuration.

The first step is installing what VirtualBox calls “Guest Additions”, which are essentially a package of utilities that smooth communications between your host OS (in my case, Ubuntu) and your guest (Luna). For example, Guest Additions allows you to configure your VM to support a shared clipboard so you can copy in the guest and paste in the host or vice-versa. It also supports drag-and-drop between host and guest. To do this, click on your VM’s “Devices” menu, and click “Install Guest Additions”. If you have problems with this, it is also well-documented online, so I won’t rehash it here either. I always find that Linux installs VirtualBox additions via its Online Update, Mint and Debian do, so you can do either, whichever works, but the Devices>Install Additions option can sometimes be the most up-to-date drivers.

The following instructions are host-specific. Now that you have your Guest Additions installed, switch back to your host OS (Ubuntu, in my case), open a terminal, and type the following, replacing the ’1920,1200′ with the max resolution of your monitor:

VBoxManage setextradata global GUI/MaxGuestResolution 1920,1200

I had to restart my guest (Luna) VM in order for the changes to take effect correctly, otherwise I got loads of graphics glitches. I forget what exactly I had to do to make it take effect, but I think it is something along the lines of choosing “Auto-Resize Guest Display” under your VM’s “View” menu (I run my VM in fullscreen mode, also available under the View menu). I believe that’s all that is necessary to enable a sane, full-resolution VM. If that still doesn’t do it, you can try resizing your VM’s window a couple times (to try to get VirtualBox to force a resize the guest resolution) or you can try playing with the resolution in the Settings app’s (on the dock) ‘Displays’ view.

Also, the default menu-bar position for a VirtualBox VM’s toolbar (when in full-screen mode) is at the bottom, directly in front of the dock. This is annoying, but configurable. Select the VM’s “Machine” menu’s ‘Settings’ item, and under ‘General’->’Advanced’->’Mini toolbar’, check ‘show at top’.

Also, for performance reasons, you will want to enable 3D hardware acceleration under Machine->Settings->Display, if you didn’t follow my earlier advice to stop it running like a dog in treacle.

Other Issues

From time to time, I’ve experienced weird focus issues in which my host machine (Ubuntu) will intercept some common keyboard events–namely those using the <super> (aka ‘Windows’ key), which is important for both Ubuntu and Luna–which is extremely annoying.

Also, even with hardware acceleration, I’m having problems with inconsistently laggy/slow Gala (the Window manager) transitions, specifically when it comes to switching workspaces using the <super>+<left/right> shortcuts.


Now you’re ready to explore. If you’re experiencing any difficulties related to the above tutorial, leave a comment and I’ll try to elaborate or clarify if necessary. I find Elementary OS, plus LAMPP, a very lightweight webserver combo, hint, hint 😉

Comments No Comments »

A big bug in the Linux version of Pinta has stopped me from using it as my Photoshop replacement. Here’s my situation: I have an image of one of our Superwoman models, for example, that is quite large, but Superwoman herself is quite tiny, in the middle of the background. I select the whole image, and copy it to the clipboard as-is. I don’t want to use the select or crop tool. I create a new canvas that is smaller than the source image in either height or width, and then paste in my image to the new canvas, so I can move it around and position it just right without having to guess using the select tool on the original.

Make sense? Hopefully! Anyhow, Pinta in its default state, SQUASHES the image to fit the canvas, if you tell it not to resize the canvas, and it looks completely wrong, it literally squashes the image from top down, you know what that looks like without a screenshot, right? I’ve fixed it in my own sourcecode copy and Pinta now behaves as I want it to. I’m not sure the devs would want my changes, but I’ll ask anyhow.

1. Grab a copy of the source, by whatever means by using Terminal (install Git first using “sudo apt-get install git”).

2. Then clone the repo with: “git clone git://github.com/PintaProject/Pinta.git”.

3. Now your source tree is ready, it will be in your Home folder under a folder called ‘pinta’. Install MonoDevelop, and open the Pinta.sln solution file using it.

4. Once open, find the Pinta.Core/Classes/Document.cs file, and after line 806, find:

            // If the pasted image would fall off bottom- or right-
// side of image, adjust paste position
x = Math.Max (0, Math.Min (x, canvas_size.Width – cbImage.Width));
y = Math.Max (0, Math.Min (y, canvas_size.Height – cbImage.Height));

Simply change it so it looks like this:

             // Modified by Tidosho. Image would be stretched/squashed if canvas was smaller and user chooses not to resize it.
// If the pasted image would fall off bottom- or right-
// side of image, adjust paste position
//x = Math.Max (0, Math.Min (x, canvas_size.Width – cbImage.Width));
//y = Math.Max (0, Math.Min (y, canvas_size.Height – cbImage.Height));

It’s a bit of a dirty hack, as it simply comments the procedure out, but it works. A possible fulltime modification could be a controllable scale type operation like in Photoshop where you control the scale using handles round the image, but I don’t think Pinta has a scale API.

UPDATE: It isn’t as serious as I first thought, but still annoying. The reason the image is squashed when pasted is because Pinta uses squashed thumbnails for use in the open documents list, and the History. As soon as you drag the layer pasted in, it corrects itself, but then you have to drag it back into position.


Comments No Comments »

Mika recently gave me her old eMachines E625 laptop after she bought a new one from me. I dual booted it with Linux Mint, as there was still some of Mika’s files under Vista that she wanted to keep. The only thing that didn’t work was the wireless. The card appeared to be installed under Device Driver Manager, but I received the message “Device not ready – firmware missing.”

I was scratching my head for ages. Using Ethernet for the time being, I tried downloading official Broadcom wireless Linux drivers and building them, but that hit a wall with Error 3 (I never did find out what that was). I swapped drivers under Device Driver Manager, still no luck. Admitting defeat, I phoned my linux chick, Kana, and her simple solution made us both laugh! She told me to open Software Manager, search for “b43”, and install the package “firmware-b43-installer”. It worked! The wireless on/off button light also worked!

She said you can also use Terminal by typing “sudo apt-get install firmware-b43-installer”, but to do that you’d need to have known the package name first. I love you, Kana, my gorgeous Japanese geek goddess xxx Seriously, everyone should have a Japanese geeky programmer for a ladyfriend!

Comments No Comments »