ysflight.com


2013/11/10 Hard-disk crash!

Good news is I didn't lose anything important. I am taking multiple redundant backups of my source files. Also I take whole-drive back up once a month, and am keeping older version for several months. What is falling apart is the internal hard drive of my Late 2008 MacBook Pro.

Strictly speaking, the hard drive started falling apart as soon as it arrived about a year ago. I bought it as a replacement for my working drive. I replace my working drive once a year even if it is working ok. I don't take a chance. After replacing, the previous hard drive is kept as a backup copy. But, when I started using this particular hard drive, I noticed some file corruption every a few days. I compiled my program and saw weird errors. I opened the source file and saw unreadable characters everywhere.

What most troubled was this drive didn't even give an error message. It silently broke files. If I can see an error message, I can stop and recover from the back up copy. But, since it broke silently, I didn't know if my files are stored all right, or some are already broken. Since I never knew when the file was broken, if I kept using it longer, I would overwrite back up copy with broken files, and the recovery will become more difficult.

I always use an external enclosure for my working drive because I can grab and run in case of fire breaks out. I suspected my enclosure and tried the hard drive with different enclosures, but didn't help. I kept getting broken files once every a few days. No error messages are given.

The situation was like this. The sanity of the file was not known until I really observed. The files in this hard drive were as if intact and were broken at the same time. It's just like a Schledinger's cat. It is called the uncertainty principle of the quantum theory. (Not really. It was just a defect!) I like to study quantum theory, but I didn't have time to deal with the uncertainty principle in my hard drive.

I thought about returning it for replacement. But, the support engineer won't probably see the error unless he spends long time on this drive. The hard drive was thinking it was working. But, it was not. My request for replacement may be rejected. Or, they may simply ship the same drive back to me. I just didn't want to waste time to deal with the return.

I then suspected that this drive doesn't like to be in an enclosure. I plugged it to my MacBook Pro as its internal drive. This time I had to full-install OSX and Windows 7 in this hard drive. It then worked somewhat stable. I still had a problem of file corruption when I download a large file. I had thirty or forty bytes altered when I downloaded 1 or 2GB. I was certainly not fully comfortable with this drive, but I kept it as the internal drive about a year.

This time, my virtual machine of VirtualBox broke a few days ago. Some critical bytes of the hard-disk image of the virtual machine probably broke due to the hard-drive defect. Of course I had a backup of my virtual machines. I didn't lose it. But, I had enough. I decided to replace it.

I can wait until Cyber-Monday sale to buy a new hard drive, but I didn't want to clean-reinstall the systems. I can take Time-Machine backup of the OSX partition, but the problem was my Bootcamp partition. Many Mac users are having problems in backing up the Bootcamp partition. A typical Windows backup program can make a backup copy but fails to restore. The most popular solution to this problem seemed to be software called WinClone. The price was reasonable. I paid $29.99 and bought the program.

I tried to install it, and didn't work. Turned out the latest version required Mac OSX version 10.7 Lion or newer. I was still using 10.6 Snow Leopard. I didn't have a reason to upgrade. I also didn't want to waste time to get used to the new environment.

I really don't understand why Microsoft and Apple don't learn that people don't want them to come up with a new operating system. People want them to keep the same operating system and fix bugs and improve security. Every time they start a new operating system, they abandon some older hardware. What a waste! I have no reason to throw away my 10-year old HP 1012 laser printer. It's still working perfectly ok. Also, with a rare exception of Windows 8, every new operating system requires faster CPU and bigger memory. Good software can do the same task with less memory and less computational power. Therefore those venders are making the operating system worse and worse. I never imagined I could use up 128MB of RAM several years ago. Now does the operating system require 8GB? If a software vender makes the users frown and keeps selling worse-quality software, for sure their business will nose dive.

So, I was sticking with OSX Snow Leopard until then. But, the timing was perfect for me. Apple just opened the new version of OSX 10.9 Mavericks for free. It supports my 5-year old MacBook Pro. Apple didn't abandon my old Mac this time. It may not be too bad to upgrade to OSX Mavericks.

I started upgrade process, went shopping, and came home. The upgrade was successful. I could install WinClone 4 and could take an image-backup of my Bootcamp partition. Things were going ok.

I knew I had to also upgrade my Mac OSX developing environment. Newer version of OSX doesn't support XCode 3.x any more. One concern for me was Apple wanted to phase out GCC and switch to a compiler called clang. I think GCC 4.x is a good compiler, but I can also understand the reason why Apple wants to get out of GCC. Anyway, I didn't want to change my makefiles to accommodate clang all together. I wanted to gradually shift to the new compiler. For that purpose, I wanted to install XCode 4.x, which comes with both GCC and clang.

I downloaded XCode 4.8 and tried to install on my OSX Mavericks, and failed. Why!? Turned out Apple requires XCode 5 or newer on Mavericks. I hated the new operating system again.

I had three choices:

  1. Go back to Snow Leopard from the Time-Machine back up. I can upgrade again when I need to restore Windows partition, and then come back again.
  2. Go back to Snow Leopard from the Time Machine back up, and pay for OSX 10.7 or 10.8.
  3. Make up my mind and switch to the clang compiler now.

Should the option 3 have failed, I could always fall back to option 1 or 2. I made up my mind and started studying the clang compiler.

If you search for GCC to clang transition, the internet is full of horrific outcry and agony of the programmers. But, my YSFLIGHT have been tested by Visual C++ and GCC. I thought I killed all the compiler-dependent expressions by now. My hope was the transition was not going to be too bad.

Nonetheless I didn't expect I could simply change g++ to clang and could compile whole YSFLIGHT code. I started with smaller sample codes and test codes. To my surprise, all of them worked just by replacing CC=g++ to CC=clang in my makefiles. I spent this weekend to change makefiles of YSFLIGHT and necessary libraries. I had a few gotchas, but I was able to successfully transition to the clang compiler. One thing was that clang doesn't support OpenMP yet. I like OpenMP. It is unfortunate that I cannot use OpenMP in clang. I had to drop -fopenmp options (or I got a link error). Another issue was sometimes the compiler didn't automatically link C++ standard library. I had to add -lstdc++. I haven't figured what makes the compiler ignore the standard C++ library. At this time, I add -lstdc++ when I get a link error. The compiler also gives an error if I try to keep a pointer of the base class inside a privately-inherited sub class. The sub-class must not have access to the base-class members in this case, but I think it should be allowed to keep a pointer of the base class or pass a pointer from left to right. I think clang is not interpreting C++ specification correctly in this matter. For that problem, I had to change private inheritance to protected inheritance. Which made me a bit uncomfortable, but I was able to compile at least.

Now YSFLIGHT can be compiled with the clang compiler that comes with XCode 5. I just flew a few minutes to confirm that YSFLIGHT runs on OSX Mavericks. I was worried about joysticks and sound effects, but I had no problem with these.

Also, I think I can live with my Late 2008 MacBook Pro for another two years or so.

 

Comments are welcome.  Send E-Mail to: 

RETURN TO TOP PAGE

This page is link free, but please link to http://www.ysflight.com.  Please use one of following banners.