Friday, April 22, 2011

How to clean hidden sectors on your hard drive

WARNING: If you have not backed up all your important data somewhere else, stop right here. I will not be held responsible for lost software licenses, precious pictures of your late dog Fluffy, etc. Do the following at your own risk!

I strongly recommend creating a backup file of your hidden sectors before cleaning. See this post for instructions.

When you install certain software products (cough cough Autodesk), secret entries are made on a hidden sector of the computer’s hard drive. These entries are looked for when you attempt to install the software again and are not removed even if your reformat the drive or install a fresh image of your operating system.

To remove these “permanent” records, you need to use a low-level disk utility to zero out the affected sectors. Fortunately, this can be done quite easily using a Linux rescue disk. The following example uses Ubuntu Rescue Remix 10.10:
  1. Insert the rescue disk and reboot the computer. At the “boot” prompt, press Enter and wait for Linux to start (~ 1 minute).

  2. At the command prompt, type the following command:
sudo fdisk -l

(Note: the character at the end is the letter ’l’, as in “lettuce”)

You should see a list of connected drives and their partition information. Find the name of the drive you need to fix (looking at the drives’ capacities should give you a good hint). The drive name will be something like /dev/sda, or /dev/sdb etc.

  1. Now we will zero out some of the sectors on that drive where sneaky programs could be hiding data.
CAUTION: Be very careful with the dd command! One small typo or omission can render the entire drive unreadable! (dd has the nickname “disk destroyer” for a reason)

Type the following command, replacing “/dev/sdx” with the actual drive name:

sudo dd if=/dev/zero of=/dev/sdx seek=32 bs=512 count=30

This zeroes out 30 sectors, starting at sector 32, and leaves the last hidden sector (62) alone. The reason for this is that Norton Ghost hides its license information in sector 62, and zeroing it will cause problems for you if you use that product.


           If you want to zero out all hidden sectors except the Master Boot Record, use the 
           following:

     sudo dd if=/dev/zero of=/dev/sdx seek=1 bs=512 count=62

Whatever you choose to do, make sure 'seek' is at least 1, and that 'seek' plus 'count' is no more than 63!  Also, don't forget to replace "/dev/sdx" with the actual drive name.


NOTE: Linux bootloaders, like GRUB and LILO, also write code to these hidden sectors. If you use Linux on this hard drive, you may be destroying information needed to boot the operating system.

ALSO NOTE: These examples assume the hard drive has 512-byte sectors. Next generation hard drives may have 4096-byte sectors, in which case you will need to update the “bs=512” parameter accordingly.

  1. Reboot the machine (sudo reboot) and proceed to do whatever it was you were doing.

Useful Links:

Ubuntu Rescue Remix: http://ubuntu-rescue-remix.org/

2 comments:

  1. Thanks Zach! This worked perfectly. I was trying to install the trial on a computer with a second hand hard drive and it wouldn't work. I followed the above procedure and deleted the FLEXnet files (C:\ProgramData\FLEXnet for Win 7) and it works a charm. Thanks for figuring that out

    ReplyDelete