Tuesday, November 01, 2011

OS X Lion: Preserve Recovery HD (Partition)

My experience with MBA and Lion soured when I decided to migrate one MBA to the other due to an accident.

Firstly, I tried to restore using Time-Machine backup to migrate the system, however this method would not able to restore my developement environment. (no make!)

Secondly, I triggered recovery mode by pressing "command+r" keys while it's rebooting then restore from Time-Machine backup.

Everything seems went well, until I found the Recovery HD was invalidated, and I can't use File Vault and Recovery Mode as well as Find My Mac feature anymore.

I have searched web and found the only way around at this time is that follwing Varta's method (https://discussions.apple.com/thread/3194269?start=0&tstart=0) which involves downloading of several GBs of data from the net.

Now I'm downloading Lion from the net, another 2 hours to download only hope Varta's method works.

Anyway, lesson here is that do make HDD image backup periodically. You never know when your precious Macbook dropped to floor like me.

Steps you should take before migrating one Mac to the other Mac while preserving Recovery HD.

1. Go into recovery mode from your old Mac (Command+R)
2. Create image of your existing old Mac's HDD to external HDD
3. Go into recovery mode from your new Mac
4. Create image of your existing new Mac's HDD to external HDD (For disaster recovery purpose)
5. Restore your new Mac's HDD from old Mac's HDD image
6. Reboot the system, keep fingers crossed.

Hope Apple fix the problem soon, it is simple madness; install entire OS downloading from the net just to create Recovery HD.

Yes, IT WORKS!

Friday, April 15, 2011

Modified Install.bat for Windows 7 / Vista 32-bit ODBC driver install

In order to install 32-bit ODBC driver on 64-bit Windows 7 / Vista correctly, we need to modify the installation script slightly. It make sure install 32-bit files onto %windows%SysWow64 directory and register the driver correctly using 32-bit ODBC configure.

Modified from mysql-connector-odbc-noinstall-5.1.8-win32\install.bat

Modified sections are marked with bold line


@ECHO OFF
REM #########################################################
REM
REM \brief Install myodbc.
REM
REM This exists for those working with the Windows source
REM distribution.
REM
REM Use this to copy the driver and supporting files
REM to the system directory and register the driver.
REM
REM \sa README.win
REM
REM #########################################################

SET installdir=none
IF EXIST %windir%\system\nul SET installdir=%windir%\system
IF EXIST %windir%\system32\nul SET installdir=%windir%\system32
IF EXIST %windir%\SysWOW64\nul SET installdir=%windir%\SysWOW64
IF %installdir%==none GOTO :doError5

IF EXIST %installdir%\myodbc-installer.exe GOTO :doError4

REM ****
REM * Find out the bin/lib directory, or use default
REM ****
SET libdir=lib
SET bindir=bin
IF EXIST lib\release\myodbc5.lib SET libdir=lib\release
IF EXIST lib\relwithdebinfo\myodbc5.lib SET libdir=lib\relwithdebinfo
IF EXIST bin\release\myodbc-installer.exe SET bindir=bin\release
IF EXIST bin\relwithdebinfo\myodbc-installer.exe SET bindir=bin\relwithdebinfo

REM ****
REM * Copying myodbc libraries and executables to install dir...
REM ****
ECHO Copying installation files
IF NOT EXIST %libdir%\myodbc5.lib GOTO :doError2
IF NOT EXIST %libdir%\myodbc5S.lib GOTO :doError2
IF NOT EXIST %bindir%\myodbc-installer.exe GOTO :doError2
copy %libdir%\myodbc5S.dll %installdir%
copy %libdir%\myodbc5S.lib %installdir%
copy %libdir%\myodbc5.dll %installdir%
copy %libdir%\myodbc5.lib %installdir%
copy %bindir%\myodbc-installer.exe %installdir%

REM ****
REM * Registering driver...
REM *
REM * We can do this with myodbc-installer.exe or the MS Windows ODBCConf.exe. It
REM * may be safer to use the ODBCConf.exe when we think about such things
REM * as 64bit windows.
REM ****
ECHO Registering driver
REM myodbc-installer -d -a -n "MySQL ODBC 5.1 Driver" -t "DRIVER=myodbc5.dll;SETUP=myodbc5S.dll"
%installdir%\odbcconf INSTALLDRIVER "MySQL ODBC 5.1 Driver|DRIVER=myodbc5.dll|SETUP=myodbc5S.dll"


ECHO "+-----------------------------------------------------+"
ECHO "| DONE |"
ECHO "+-----------------------------------------------------+"
ECHO "| |"
ECHO "| Hopefully things went well; the Connector/ODBC |"
ECHO "| files have been copied to the system directory |"
ECHO "| and the driver has been registered. |"
ECHO "| |"
ECHO "| Connector/ODBC is ready to use. |"
ECHO "| |"
ECHO "| The most common thing to do next is to go to the |"
ECHO "| Control Panel and find the ODBC Administrator - |"
ECHO "| then use it to create a Data Source Name (DSN) |"
ECHO "| so you (and your application) can connect to a |"
ECHO "| MySQL server. |"
ECHO "| |"
ECHO "+-----------------------------------------------------+"
EXIT /B 0

:doError2
ECHO "+-----------------------------------------------------+"
ECHO "| ERROR |"
ECHO "+-----------------------------------------------------+"
ECHO "| |"
ECHO "| Connector/ODBC not built. |"
ECHO "| |"
ECHO "+-----------------------------------------------------+"
PAUSE
EXIT /B 1

:doError4
ECHO "+-----------------------------------------------------+"
ECHO "| ERROR |"
ECHO "+-----------------------------------------------------+"
ECHO "| |"
ECHO "| Existing Connector/ODBC installed. Request ignored. |"
ECHO "| |"
ECHO "+-----------------------------------------------------+"
PAUSE
EXIT /B 1

:doError5
ECHO "+-----------------------------------------------------+"
ECHO "| ERROR |"
ECHO "+-----------------------------------------------------+"
ECHO "| |"
ECHO "| Can't find the Windows system directory |"
ECHO "| |"
ECHO "+-----------------------------------------------------+"
PAUSE
EXIT /B 1

D:\tmp\mysql-connector-odbc-noinstall-5.1.8-win32 modified Install.bat for Windows 7 / Vista 32-bit ODBC driver install


@ECHO OFF
REM #########################################################
REM
REM \brief Install myodbc.
REM
REM This exists for those working with the Windows source
REM distribution.
REM
REM Use this to copy the driver and supporting files
REM to the system directory and register the driver.
REM
REM \sa README.win
REM
REM #########################################################

SET installdir=none
IF EXIST %windir%\system\nul SET installdir=%windir%\system
IF EXIST %windir%\system32\nul SET installdir=%windir%\system32
IF EXIST %windir%\SysWOW64\nul SET installdir=%windir%\SysWOW64
IF %installdir%==none GOTO :doError5

IF EXIST %installdir%\myodbc-installer.exe GOTO :doError4

REM ****
REM * Find out the bin/lib directory, or use default
REM ****
SET libdir=lib
SET bindir=bin
IF EXIST lib\release\myodbc5.lib SET libdir=lib\release
IF EXIST lib\relwithdebinfo\myodbc5.lib SET libdir=lib\relwithdebinfo
IF EXIST bin\release\myodbc-installer.exe SET bindir=bin\release
IF EXIST bin\relwithdebinfo\myodbc-installer.exe SET bindir=bin\relwithdebinfo

REM ****
REM * Copying myodbc libraries and executables to install dir...
REM ****
ECHO Copying installation files
IF NOT EXIST %libdir%\myodbc5.lib GOTO :doError2
IF NOT EXIST %libdir%\myodbc5S.lib GOTO :doError2
IF NOT EXIST %bindir%\myodbc-installer.exe GOTO :doError2
copy %libdir%\myodbc5S.dll %installdir%
copy %libdir%\myodbc5S.lib %installdir%
copy %libdir%\myodbc5.dll %installdir%
copy %libdir%\myodbc5.lib %installdir%
copy %bindir%\myodbc-installer.exe %installdir%

REM ****
REM * Registering driver...
REM *
REM * We can do this with myodbc-installer.exe or the MS Windows ODBCConf.exe. It
REM * may be safer to use the ODBCConf.exe when we think about such things
REM * as 64bit windows.
REM ****
ECHO Registering driver
REM myodbc-installer -d -a -n "MySQL ODBC 5.1 Driver" -t "DRIVER=myodbc5.dll;SETUP=myodbc5S.dll"
%installdir%\odbcconf INSTALLDRIVER "MySQL ODBC 5.1 Driver|DRIVER=myodbc5.dll|SETUP=myodbc5S.dll"



ECHO "+-----------------------------------------------------+"
ECHO "| DONE |"
ECHO "+-----------------------------------------------------+"
ECHO "| |"
ECHO "| Hopefully things went well; the Connector/ODBC |"
ECHO "| files have been copied to the system directory |"
ECHO "| and the driver has been registered. |"
ECHO "| |"
ECHO "| Connector/ODBC is ready to use. |"
ECHO "| |"
ECHO "| The most common thing to do next is to go to the |"
ECHO "| Control Panel and find the ODBC Administrator - |"
ECHO "| then use it to create a Data Source Name (DSN) |"
ECHO "| so you (and your application) can connect to a |"
ECHO "| MySQL server. |"
ECHO "| |"
ECHO "+-----------------------------------------------------+"
EXIT /B 0

:doError2
ECHO "+-----------------------------------------------------+"
ECHO "| ERROR |"
ECHO "+-----------------------------------------------------+"
ECHO "| |"
ECHO "| Connector/ODBC not built. |"
ECHO "| |"
ECHO "+-----------------------------------------------------+"
PAUSE
EXIT /B 1

:doError4
ECHO "+-----------------------------------------------------+"
ECHO "| ERROR |"
ECHO "+-----------------------------------------------------+"
ECHO "| |"
ECHO "| Existing Connector/ODBC installed. Request ignored. |"
ECHO "| |"
ECHO "+-----------------------------------------------------+"
PAUSE
EXIT /B 1

:doError5
ECHO "+-----------------------------------------------------+"
ECHO "| ERROR |"
ECHO "+-----------------------------------------------------+"
ECHO "| |"
ECHO "| Can't find the Windows system directory |"
ECHO "| |"
ECHO "+-----------------------------------------------------+"
PAUSE
EXIT /B 1