Blue Screens and SSDs

Over the past weekend I spent 3 days troubleshooting a constant blue screen of death problem. It was like no problem I've ever dealt with as the symptoms were very unusual. When I was using the computer, whether playing a game, browsing the internet or simply just working, it would freeze up. It wouldn't freeze in the usual sense, it would freeze up program by program (when I clicked to each one) until I couldn't do anything except move my mouse and wait for the unavoidable BSOD. It would even BSOD while my computer was idle, weird!

Like any competent PC owner, I tested all the hardware piece by piece. I started by disassembling the computer, cleaning everything, checking for damage, and reassembling; all good. I checked all drivers and updates. I tested each memory stick one by one. I monitored the temperature and voltage, and found nothing out of the ordinary. That only left the video card, power supply, hard drives (1 SSD, 2 HDD) and possibly the motherboard. I ruled out the power supply by monitoring the voltage. I ran disk cleanup, disk check and defragment on all the drives and they all passed. I never tested another video card as I believed it wasn't a video issue, since the symptoms had nothing to do with display. That left me with the MOBO, which I was really hoping wasn't the problem.

Before I went any further, I queried all my tech knowledgeable friends for a solution... they had none. They all suggested doing a system wipe, which I think is absurd until you determine whether it's a hardware or software issue. So I enabled BSOD logging which would allow me to read the dumps and discover a solution. However, another problem arose when the BSOD dumps were never written during a crash, and the administrative event logs weren't helpful either. I was at a loss at this point and really didn't want to spend money building a new system.

Since BSOD logs weren't being generated, a friend suggested waiting for a BSOD to occur and to write down the error message that appears. So I did. The following is a summary of the BSOD.

A process or thread crucial to system operation has unexpectedly exited or been terminated. Stop: 0x000000F4 (0x0000000000000003, 0xFFFFFA800C13D060, 0xFFFFFA800C13D340, 0XFFFFF800039D9350).

At a glance it doesn't come off as helpful, but that didn't stop me. I Googled around using "BSOD 0x000000F4" as my term coupled with each piece of hardware I was utilizing, until I found something. It just so happens that my Crucial M4 SSD that I installed a little over a year ago was the culprit. After 5,000 hours of on-time, the SSD will crash unexpectedly. The math since installation checks out: (12 average hours a day * 30 days a month) * 14 months = 5,040. With a little firmware update from the Crucial guys, I've been BSOD free for a couple days now.

I felt the need to blog this as I'm sure it would be helpful to others who encounter such weird issues, especially with new tech like SSDs. You've been warned!

Version Two

It's been 5 years since the launch of milesj.me, and 5 years of the same design. I spent my recent free time working on a new design. The new design, aptly named version 2, boasts some of the latest in technology. It utilizes HTML5, CSS3, Sass, MooTools, Titon, CakePHP, and more.

Why the change?

After 5 years, you get tired of looking at the same old design. I really wanted to utilize new HTML5 tags, as well as attempting some new CSS3 features like transitions and media queries. Releasing a new version allows for removal of certain features (like snippets), and the refactoring of old ones.

Another annoyance with the previous version was the usage of Decoda (a very very old version at that) in articles and code documentation. It caused nothing but headaches and restricted any customizability that I wanted to achieve. Decoda has its usage in certain situations; that was not one of them.

What technology is being used?

At the lowest level, HTML5 and CSS3 is used for the layout structure. Sass and Compass is used heavily to achieve responsive design at the following breakpoints: 1440, 1366, 1024, 768, 480, 320 (give it a try!). It took me a while to really enjoy Sass, but in the end, its variables, mixins and extremely easy support for responsiveness was welcoming. The Sass files relating to this site can be found by replacing css in the path to scss; for example, the style.scss and skeleton.scss.

On the outside, the Tooltip and Pin component from the Titon Toolkit, a UI toolkit for MooTools, is currently integrated. For code syntax highlighting, I am using the very powerful and nicely built Prism.js by Lea Verou. On the inside, a custom built CakePHP CMS powers everything.

What's next?

With many of my GitHub and website projects out of the way, I hope to find more time to blog about current technology. I mean, what else is there really to do?

Upgrading My Desktop: Transferring the OS to the SSD

After preparing my new SSD, the hard part (or rather easy part) was transferring the current Windows 7 operating system and all its contents (users, documents, etc) off the old HD and into the new SSD. What I wanted to achieve was to mirror the contents of my C: drive onto the SSD and simply swap out the drives and re-use the old SATA cables. To create the C: image I used Acronis True Image Home (free trial) -- which according to the internet, is one of the better products to do this with. The paid version of Acronis comes bundles within a "Clone disk" tool that would of made this process far easier (in case you want to do that).

1) Creating the backup

Before creating the image, I ran the disk cleanup utility on my C: drive to clear out any unneeded or temp files. This is also a great thing to do, as you can lower the filesize of your drive so that it will fit on the new SSD (since they are much smaller in size; this can be a problem). Once the disk cleanup was done, I simply ran the Disk and partition backup command under Backup and Recovery within Acronis. This created a backup file that I will later use in the SSD.

2) Restoring the backup to the SSD

With my shiny new backup, it was now time to restore it to the SSD. This was rather simple, actually it was extremely simple to do. Within Acronis next to each backup is a Recover button that can be used to restore the backup. All I had to do was set the destination for the SSD, and presto, I now have a mirrored drive. A few things to note however: the SSD must be large enough to house the backup and the SSD must not have a drive letter assigned to it so that swapping can easily be done.

3) Swapping out the drives

Now that the drives are mirrored, the easiest step is swapping them. This can be done by shutting down the computer, taking out the old C: drive, plugging its SATA cable into the SSD and inserting the SSD into the computer. When swapped, fire up the computer and let it boot. When it reached the desktop it recognized the SSD and installed new hardware. It then asked to restart the computer to apply the new changes. Once restarted, I noticed that everything was multitudes faster, and is just too beautiful for words to explain.

Since I now had an extra 300GB HD, I decided to plug it back in and re-format it. This drive is now used to store all my Windows backups and restore points. I felt it could still be useful, and in the event that something happens, I have a backup to fix the problem.

Upgrading My Desktop: Migrating Programs and Hard Drives

The next step in my system upgrade was to install and format the new hard drives, migrate all program files over to the new drive, and setup symlink's for legacy paths. For my upgrade I was installing a 1TB internal HD that will house all my program and game installations, and a 128GB SSD that will house the Windows 7 OS. This process was pretty tedious, so bare with me and follow closely.

1) Installing and formatting the new hard drives

The first thing I had to do was physically install the hard drive into my computer (of course), connect any SATA and power cables and make sure it was fastened in the HD bay slot. Once installed and the computer turned on, I opened the Computer Management program; you can locate this program by searching for "computer" in your start menu search.

Selecting the Disk Management tab on the left should populate with all the installed drives. If your newly installed drive does not show up, shutdown your computer and diagnose the problem by checking that all cables are connected correctly. Otherwise, right clicking on the drive allows you to format and create a partition (or volume) by selecting the New Simple Volume Wizard.

When formatting my drives, I used the default volume size as I was only creating 1 partition per drive. When it gave me the option of selecting the drive letter, I chose E: for my 1TB HD and opted out of using a letter for my 128GB SSD, as I will be replacing my old C: with the SSD.

Lastly, in the format partition dialog, I chose NTFS as the file system (this is critical) and the non-quick format option. I didn't use the quick format as I wanted to stay on the safe side and ensure that everything was erased and cleaned (even though it was a new drive).

Restart the computer when the formatting is done (I restart a lot).

For a more in depth guide on this process, checkout the following articles:

2) Uninstalling current programs

The next big step was to uninstall all my programs. I am not too positive this is necessary compared to dragging the current Program Files folder over to the new drive, but I uninstalled and reinstalled all my programs to validate they all have the correct paths in the registry, startup, configuration, shortcuts, targets, etc.

Note: During the uninstallation process, be sure to keep all saved data and settings if the program gives you the option. Since I was not doing a clean install of the OS, the AppData and related folders will continue to persist all my program settings and cache once I reinstall it.

When all available programs were uninstalled, I restarted my computer.

3) Overriding the Windows registry

Now this is the first important piece. Changing the Windows registry that points to the Program Files path allows any program to automatically install to the new location (on the new drive) without me manually having to define it. However, some programs are just plain idiotic and will still set the path to C:/Program Files/ instead of the new path.

For reference, here are my old and new system paths:

C:\Program Files\		-> E:\Programs\
C:\Program Files (x86)\	-> E:\Programs (32)\

Additionally, I added the following folders on my E: drive:

E:\Backups\		Location of system restores and backups
E:\Data\		Temporary file and cache location for Programs
E:\Games\		Installation path for all games (separate from regular Programs)
E:\Installers\	Program installer executables (I like to save them)
E:\Tools\		System tools like Process Explorer and SIW

After the uninstallation process, I continued to find programs left over in the C:\Program Files and C:\Program Files (x86) folders. These leftovers are more than likely Windows related programs and should be left alone for now. Do not delete these programs nor delete the parent folder.

The next step was to edit the Windows registry. You can open the registry editor by typing "regedit" in your start menu search and pressing enter. In the editor, drill down into the following path: HKEY_LOCAL_MACHINE -> SOFTWARE -> Microsoft -> Windows -> CurrentVersion

Click on the CurrentVersion folder -- this is where we will edit the program files paths. I modified the registy by changing the following fields to the new paths (note the non-trailing slash):

CommonFilesDir			-> E:\Programs\Common Files
CommonFilesDir (x86)	-> E:\Programs (32)\Common Files
CommonW6432Dir			-> E:\Programs\Common Files
ProgramFilesDir			-> E:\Programs
ProgramFilesDir (x86)	-> E:\Programs (32)
ProgramW6432Dir			-> E:\Programs

After a compute restart, any new program installations should install to this new location.

4) Installing and migrating programs

This part is pretty easy, I simply re-installed all the programs back onto my computer. If the installer gives you the option to do a custom install (allowing you to choose the install location), select it. This allows you to verify the program is installing to the new path and is a required step as some programs will still attempt to install to C: -- if this happens, just change the path yourself.

When all program installations were complete, it was time to migrate the leftover programs. All I did was select and copy all the folders in C:\Program Files and paste them into E:\Programs. I also did the same by copying all folders in C:\Program Files (x86) and pasting them into E:\Programs (32).

Probably the easiest step in the process, but also the most time consuming.

5) Legacy folder cleanup

Before symlink's can be created, the origin folder must not exist. The next step I had to take was deleting the old C:\Program Files and C:\Program Files (x86) folders... which turned out to be quite difficult. Doing a delete or shift + delete didn't work as I would get basic access denied alerts. I then switched over to the command prompt to attempt some deletion magic... the following did not work.

"rd" - This command *should* remove a directory and all files within. Still received access denied errors.

rd /S "C:\Program Files"
rd /S "C:\Program Files (x86)"

"takeown" and "icacls" - These commands basically change the ACL (access control) of all files and folders, and give ownership to the Administrators group (This is basically the same as changing ownership in the right click properties dialog). This also did not work.

takeown /f "C:\Programs Files" /r /d n
icacls "C:/Programs Files" /grant Administrators:F /t
takeown /f "C:\Programs Files (x86)" /r /d n
icacls "C:\Programs Files (x86)" /grant Administrators:F /t

Now after many hours and much frustration, I was ready to give up. But after much Googling, I found the answer -- it was time to bring out the big guns. The following did work. This command enables the hidden Administrator account on all Windows Vista/7 systems.

net user administrator /active:yes

Once enabled, I switched over and logged into the Administrator account. I was now able to shift + delete the folders with no problem. When deleted, I logged off the Administrator account. Running the following command disabled the account.

net user administrator /active:no

Easy right? I thought so as well.

6) Setting up symbolic links

The final step -- never thought I would get this far. Seeing as how I have successfully installed a new hard drive, migrated all programs over, modified the Windows registry and cleaned up legacy folders, it is now time to setup symbolic links. Like I stated before, symlink's are a way to have anything that points to the C: drive, reference the same files within the E: drive. The same goes for writing data -- anything written to C: is actually being written to E:.

Note: Since I named my programs folder E:\Programs instead of E:\Program Files, anything referencing C:\Program Files will not find a symlink match. However, I have yet to run into any problems after weeks of testing.

Setting up the symlink's was easy:

mklink /D "C:\Program Files" "E:\Programs"
mklink /D "C:\Program Files (x86)" "E:\Programs (32)"

Tada, magic! I now see a shortcut within C: that references E:.

Conclusion

It took me hours over the course of a couple days to do all of this. The hardest part was Googling around for solutions as many of them lead to dead ends. It also helped me figure out problems during the migration as I would run into weird cases where startup items would fail, or programs could not be located. Most of these problems disappeared once symlink's were created.

I've been using this new setup for a couple weeks now (at the time of writing this) with no problems. I have yet to switch over to the SSD however... so that should be interesting.

Upgrading My Desktop: Preparation

My desktop computer is almost 2 years old, but certain parts of it are way over 5 years. My C: and D: drives were taken from my last computer and re-used in my new custom built desktop (primarily to save money). I really wanted to upgrade my HD space and switch to the latest craze, an SSD. While doing this upgrade, I felt like I should blog about what I did and any problems I ran into. To start this off, here was my old system.

As you can see, my RAM and HD space was abysmal. My C: drive was 90% full of crap, mainly the OS and all installed programs. The plan was to install a new secondary internal drive and migrate all program files into this new drive, the E: drive. I also had to reduce the space used on the C: drive so that I can transfer my OS to the SSD (note: transfer, not a fresh install). Lastly, my F: drive is primarily used for media storage (which is connected to my iTunes): music, tv shows, videos, pictures, docs, etc. Before I continue, here is the new hotness (changes in italics):

Even though I was mainly going to upgrade my HD slots, I kind of splurged and upgraded my RAM, keyboard and monitors. The RAM was relatively cheap, only $40 for another 8GB. My keyboard was getting extremely outdated, so I upgraded to the Sidewinder gaming keyboard as I am always destroying face in Battlefield 3. Lastly, the only reason I bought 2 new monitors is because one of them died during this upgrade process (what are the chances)... so I decided to upgrade both at the same time.

The upgrade process for migrating all programs to another drive and for switching to a new SSD will come shortly. They are pretty in depth, so a full blog post about it should suffice. I hope to inform you all on this journey!

Refactoring is fun

For over a year now I have been eager to redo the backend (built on CakePHP) of this site. I kept putting it off, until last week when I was fixing bugs that I realized it would be more beneficial to just rebuild the whole site. I wanted to redo both the PHP and the database tables, as the old tables were from a previous installation. Here's just a quick list of things I wanted to change:

  • Separate blog tags into its own table and setup a HABTM (was a column in each entry)
  • Remove ENUM fields from the database tables and use class constants
  • Use slugs for all dynamic URLs
  • Use the model's counterCache system instead of a count find()
  • Add a blog series system (example)
  • Fix the bugs in my comments and contact forms
  • Rebuild the code/script section and remove the old "versioning" system (since I use Github now)
  • Build an admin panel

So to begin this huge task, I created new database tables based on the architecture I wanted. Once done, I created all the models for each of these new tables (and made sure to keep the old models for importing). The next step was to create CakePHP shells that use the old models to generate the new data structure and save it into the new tables (while keeping legacy IDs intact). This database changed fixed the dislikes I had with the old table columns (by removing ENUMs), added the slug and ID fields where necessary, and removed the old and useless tables I don't have a need for. First task complete.

Now that the fun step was over, it was time to refactor all the old controllers and views. Most of the old controllers were re-usable (like blog, pages, comments and feeds), all I simply had to do was make sure the new column names were being used and add support for new features (blog series, etc). The most time consuming part in this process was splitting up the old resources controller into two new controllers: code and snippets. Since the code section of my site was re-built from the ground up, these controllers also had to be rebuilt. The new code structure only uses 3 tables compared to the previous 5, win! However, I still had a problem with old legacy URLs. The solution I went with, was to allow the old URLs to redirect to the new ones using a jump controller (which also powers my tiny URL system), as well as allowing the URLs to work with a slug or ID (very important). Example, all of these links lead to the same place.

http://milesj.me/code/cakephp/forum
http://milesj.me/resources/script/forum-plugin
http://milesj.me/c/13

At this point, I was extremely pleased with the refactoring process. The next and last step was to create an admin panel system for all types of content on the site (I didn't have one before). I decided to place all of this code within a plugin, as I didn't want to litter my controllers with admin_ methods and it gave me more control of security and management as it was self-contained. I was expecting this process to take weeks to finish, but I completed it in less than 8 hours, win again! I used the technique of having a single view template for both the add() and edit() methods and was able to re-use a lot of code (DRY for the win). I highly suggest this approach for anyone who needs an admin system.

All in all, the process wasn't as back breaking and time consuming as estimated. I basically rebuilt the whole site in under 2 weeks, working about 1 hour a day. If you are interested, here's a quick list of all the changes.

  • Importing of old data into new database tables
  • Refactor of old models, controllers and views
  • Moving tags into a HATBM table and model
  • Adding slugs to all URLs
  • New blog archiving system for date ranges, tags and topics
  • New blog series feature
  • Adding counterCache for comments and tags
  • Adding a jump controller to deal with legacy URLs and tiny URLs
  • Splitting of old resources controller into code and snippets
  • Rebuilding the code packages and versioning system

I wouldn't doubt it if I forgot something! But whats next you ask? The worst part of all, updating my documentation. Now that will take some time.

Service Operational

A little over a week ago I finally got my cast removed from my right hand. It felt so good to get the cast off after 3-4 weeks of wearing one. I was unable to move my pinky finger nor wiggle my wrist for the first hour, but my hand is good as new now. However, the knuckle does not heal back in place so I no longer have a visible pinky knuckle (so weird looking). I still have some pain and discomfort when putting pressure on it, but as long as I can use a computer I don't care.

Anyways, if you have been following me on GitHub or Twitter you may have noticed me updating my scripts a bit. My goal is to do a polish pass for all my scripts and get them to a "final" version. Hopefully this final version will be the last for all my scripts; excluding any critical bug fixes. I'm hoping to be able to finalize these so that I may work on other projects like the Armory websites and my hidden PHP 5.3 framework.

So if you have any feature requests for my scripts before they get polished, be sure to let me know! I will however be updating the Forum and Uploader plugins for a while since those are extremely popular.

I am planning to start blogging again but I am still on mandatory overtime at work, so my free time is basically non-existent. Regardless, I am just glad to be back, so expect more to come in the future!

Out of Service

Time for a short story on my hiatus and current situation. For the past few weeks I have been working mandatory overtime at my job. It basically takes up all my weekdays so now I have no time to update my scripts except on the weekends; but then I usually want to rest and not be on the computer. But last Friday I suffered a Boxers fracture on my right hand (dominant hand) and fractured my pinky metacarpal bone. By doing so, I have a splint and bandages on my right hand rendering it useless for the time being. I now have to code and use the mouse solely with my left hand; which I just did for this whole entry... very annoying.

So during all this, I have been unable to post lately nor have time to update my scripts. I am hoping by May I can start getting back on my regular routine. I can't even play games, and can barely shower (it's quite hard with one hand, especially since I can't get the splint wet). I will see you all in a few weeks!

P.S. Do not punch hard surfaces, the outcome sucks.

GitHub, my new home

As I mentioned in my previous posts, I took the jump and moved over to GitHub. I moved over to a public repository system to make it easier on me pushing my code changes to the public (the current download system on my site isn't too intuitive). So over the past few weeks I have been slowly adding all my scripts to GitHub and pushing the code. Additionally, I have been uploading the old zipped versions of the scripts, which can be found on the respective repo's downloads page. I would of done and SVN import into Git, but it kept stalling every time I did so, oh well!

With the move to GitHub, I have updated all the download links and buttons on the site. It either asks you to download the files, or clone the repo (both of which will bring you to do the GitHub page). I do miss my download counter though... I really wish GitHub had a total downloads/clones feature.

Anyways, you can find my GitHub at the user milesj. I will be pushing all my changes and code here from now on using Git, but will still keep updating the change log on this site, and posting announcements about it. Now get to cloning!

Merry Gitmas

Well Christmas is right around the corner, and I would like to wish all of my readers and visitors a happy holiday! I hope you all enjoy the holidays with your friends and loved ones and get the most out of this break that you can. I know I sure will! Speaking of which, I am leaving tomorrow for Toronto, Canada, where I will be spending the next two weeks with my girlfriend and her fathers family, should be amazing to say the least!

The holidays are not what this blog post is really about, the main point is that I am now a member of GitHub. I know many of you have been asking me to do this for some time now. It took me a while to find a Windows solution that I was happy with, and to say the least, Git Extensions is working wonderfully so far! So wonderfully that I will be posting a few entries on how to install and use it. Right now all my CakePHP scripts are on GitHub for your cloning and forking pleasure. I will be adding my other classes shortly, but I'm sure most of you are more interested in the CakePHP ones, so enjoy!

If you find a bug in my script, either fork it and fix it, or post an issue on the GitHub page. I will merge with your changes if they work. Thanks again and Happy Holidays!

GitHub: http://github.com/milesj