Install macOS Sierra Using Bootable USB Flash Drive

Mac OS X No Comments

To perform a clean installation of macOS Sierra (basically, Mac OS X 10.12), I recommend using a bootable USB flash drive containing the macOS Sierra installer. Below are the steps I took to create the bootable USB flash drive and how I used it to install macOS Sierra.

Note: The macOS Sierra Disk Utility and installer appears to be more buggy and much slower than previous versions. The best advice for installing macOS Sierra is to try again and be very patient (if you expect an operation to complete in 5 minutes, then give it at least 50 minutes).

Download macOS Sierra Installer

The macOS Sierra installer is available from the Mac App Store. Run the “App Store” application, search for “macOS Sierra”, and download it. It will save the installer as an “/Applications/Install macOS Sierra.app” file (about 4.97GB in size).

Note: If you run the macOS Sierra installer to upgrade your Mac, the downloaded file will be deleted automatically after the upgrade is completed. To keep that file, you will want to move it out of the Applications folder so it won’t be deleted after an upgrade. Launch the “Terminal” application and run this command to move the downloaded installer to your user’s “Downloads” folder:

sudo mv /Applications/Install\ macOS\ Sierra.app/ ~/Downloads/

If you are paranoid (doesn’t hurt), you can verify that the installer file was downloaded correctly by verify its checksum. Run the “Terminal” application and this command:

hdiutil verify /Applications/Install\ macOS\ Sierra.app/Contents/SharedSupport/InstallESD.dmg

# If successful, the last output line should read:
# hdiutil: verify: checksum of "/Applications/Install macOS Sierra.app/Contents/SharedSupport/InstallESD.dmg" is VALID

Format USB Flash Drive

The macOS Sierra installer takes up 5.1GB of space on the USB flash drive, so you will need a flash drive with a capacity of 8GB or greater.

Note: If the flash drive is mounted under “/Volumes” successfully when you plug it in, you can skip the following steps to reformat the flash drive. This is because the script we run to create the bootable drive will reformat the flash drive as an initial step. Because I am paranoid, I recommend reformatting the USB flash drive manually anyhow.

Format the USB flash drive using these steps:

  1. Plug in the USB flash drive to your Mac.
  2. Launch the “Disk Utility” application.
  3. On the left-hand pane, select the USB drive (not the partition under it, if any).
  4. Click on the “Erase” tab (or button at the top).
    1. Input a name like “Sierra” (this name will be overwritten later).
    2. Select “Mac OS Extended (Journaled)” for “Format”.
    3. Select “Master Boot Record” for “Scheme”.
    4. Click the “Erase…” button at the bottom. Click the “Erase” button in the warning popup dialog if you get one.
      • The format operation may take several minutes to complete. (USB 2.0 and large capacity drives will take longer.) After the format completes, the partition will be mounted under “/Volumes/Sierra” (or whatever name you selected above).
      • Note: Under macOS Sierra, the Erase function will fail if the USB drive’s partition is mounted. You can manually unmount the partition before running Erase. Or you can run Erase twice; the first time will unmount the partition and fail, and the second time will actually do the format (which will succeed).
  5. Close the “Disk Utility” application.

Create Bootable USB Flash Drive Installer

To create the bootable USB macOS Sierra installer, run the “Terminal” application and this command:

# The --volume value is the mounted USB flash drive partition; in this case, named /Volumes/Sierra

sudo /Applications/Install\ macOS\ Sierra.app/Contents/Resources/createinstallmedia --volume /Volumes/Sierra --applicationpath /Applications/Install\ macOS\ Sierra.app --nointeraction

# You will be prompted for your user's administrative password.

The “createinstallmedia” program will erase the USB flash drive, create a new partition named “Install macOS Sierra”, and copy the installation files to that partition. The output will look like:

Erasing Disk: 0%... 10%... 20%... 30%...100%...
Copying installer files to disk...
Copy complete.
Making disk bootable...
Copying boot files...
Copy complete.
Done.

The program will pause at the “Copying installer files to disk…” output line above. This step took 20-30 minutes with my Kingston 16GB USB 2.0 flash drive. Yours may take a shorter or longer time. I recommend giving it at least an hour, maybe two, before giving up.

Note: Mac hardware is very finicky about USB flash drives. Initially, I used a Corsair 32GB USB 3.0 drive; however, when I held down the Option key to try to boot with it, the Mac would freeze with a black startup screen. The Kingston 16GB USB 2.0 drive did not have this problem. So if you enounter issues (when erasing and copying) or weirdness (when booting), consider changing to another brand of USB flash drive. If you don’t have another drive, consider at least testing the flash drive to make sure it is not bad or corrupted (“First Aid” in “Disk Utility” is the minimum; google for more powerful tools).

Boot With USB Flash Drive

Note: I recommending connecting the Mac to its AC power adapter before beginning the macOS Sierra installation. The installation may take a long time (an hour or more) and you don’t want the battery to die in the middle.

To boot a Mac with the USB flash drive:

  1. Shutdown the Mac.
  2. Insert the USB flash drive.
  3. While holding the “option/alt” key down, turn on the Mac to display the boot Startup Manager.
  4. You should see one or more icons, one of which should be called “Install macOS Sierra” for the USB flash drive. (The internal hard drive may not be visible if it does not have a valid, bootable partition installed.)
    • Note: If you don’t see the USB flash drive’s “Install macOS Sierra”, try removing and re-inserting the USB flash drive while viewing the Startup Manager screen. The USB flash drive should then appear after a few seconds.
  5. Select the “Install macOS Sierra” (with left/right arrow keys) and hit the “return/enter” key to boot from the USB flash drive.

It may take 5-10 minutes or longer to load the installer from the USB flash drive. Sometimes the progress bar may appear to be frozen… just be patient. I would give it at least 30-60 minutes to load before giving up.

Format the Hard Drive

When the installer finishes loading, you will see a “macOS Utilities” window appear. Do the following to format the internal hard drive:

  1. Click on the “Disk Utility” option and click the “Continue” button on the bottom to launch the “Disk Utility” application.
  2. On the left-hand pane, select the hard drive (not the partition under it, if any).
  3. Click on the “Erase” button at the top.
    1. Input a name like “macOS”.
    2. Select “Mac OS Extended (Journaled)” for “Format”.
    3. Select “GUID Partition Map” for “Scheme”.
    4. Click the “Erase…” button at the bottom.
      • For SSD (Solid State Drive), the format operation may take less than a minute to complete. For mechanical hard drive, it may several minutes to hours, depending upon the size, speed, and condition of your hard drive.
      • Note: Again, the Erase function will fail if the hard drive’s partition is mounted. You can manually unmount the partition before running Erase. Or you can run Erase twice; the first time will unmount the partition and fail, and the second time will actually do the format (which will succeed).
  4. Close the “Disk Utility” application.

Note: Now and then, I noticed the output of the Erase seems to erroneously double the size of the hard drive. For a 128GB hard drive, the graph shows 120.88GB macOS (in blue) and 120.37 GB Unformatted (in red). I think it is just a user interface bug because when I close Disk Utility and re-open it, the graph then only shows the 120.88GB macOS (in blue).

Install macOS Sierra

Back at the “macOS Utilities” window, do the following to begin the macOS Sierra installation process:

  1. Click on the “Install macOS” option and click the “Continue” button.
  2. The “macOS Sierra” installer’s splash screen will appear. Click the “Continue” button.
  3. Click on the “Agree” button to agree to the license. A popup confirmation window will appear; click on the popup’s “Agree” button.
  4. Select the hard drive and click the “Install” button.

Note: You may encounter strange hardware behavior. On my 13 inch Macbook Pro Retina, the macOS Sierra installer turned the fan on to maximum for the whole duration of the installation. Thankfully, once it finished and rebooted, the fan turned off and stayed off.

The macOS Sierra installer tries to be helpful by telling you how long it will take. Unfortunately, it lies. You should take whatever remaining time it tells you and multiple by 10 (for minutes) or 100 (for seconds). If it says “6 minutes remaining”, that could mean 60 minutes or one hour remaining. Worse, if it says “6 seconds remaining”, you may be staring at that message for 600 seconds or one hour.

The best solution is to be patient. Go grab a bite to eat and watch a movie. Take a long nap or better yet, sleep your 8 hours. I would wait at least 4 hours before giving up.

Note: You can display the installer’s log window (using the menu or pressing Cmd+L). I didn’t find this helpful at all. Even for a successful install, numerous errors are logged; I don’t know what is a critical or non-critical error. And often, you won’t see a progress/status log output for a long time, easily 20-30 minutes. Not seeing any new log statements does not mean that the installer froze. So the logs didn’t do anything for me.

What Does Giving Up Mean?

Giving up means you have accepted defeat. The next step is to retreat and try again. Some suggestions on how to proceed:

  • Reset your Mac by doing the following:
    1. Reset the SMC (see step 3 under the “Reset the SMC on Mac notebook computers” section).
    2. Reset the NVRAM (aka PRAM).
    3. Run the Apple Hardware Diagnostic or Test to make sure you don’t have a hardware failure.
    4. Finally, retry the macOS Sierra install.
  • Use a different USB port on the Mac.
  • Use another brand of USB flash drive.
  • Delete and re-download the macOS Sierra installer (especially if you downloaded it a long while ago). Even if the checksum was okay, you may want to re-download in case there is a newer version of the installer with a bug fix for your very problem.
  • Download an older Mac OS X version, say Mac OS X El Capitan, install that, and then upgrade to macOS Sierra. If you know the Mac OS X version which came with your Mac originally, consider downloading (if you still have access) and installing that version first.
  • Use the Mac Recovery System to download and install the original OS version that came with your Mac. Then upgrade from that to macOS Sierra.
  • Buy a more recent model Mac (at most a couple of years old). It may be that your current Mac is too old or slow to support macOS Sierra. It’s okay to keep running an old Mac OS version. (For example, if I had a Core 2 Duo Mac, I would not run anything later than Mac OS X Mavericks on it.)

Hopefully, this post will help you to do a fresh installation of macOS Sierra.

Some info above taken from:

No Comments

Node.js Express with Nginx Reverse Proxy and Cache

Mac OS X No Comments

As a web developer, have you ever asked yourself whether to use a period or a plus sign to concatenate two strings? The former is used by PHP and the latter by Javascript. If you switch between the frontend Javascript and the backend PHP languages often, you’ll find yourself asking this and other syntax questions.

nodejs-logoNode.js eliminates that problem by supporting the use of Javascript in the backend. It is a Javascript runtime that replaces the PHP backend. However, using Javascript for both frontend and backend is not the best reason to migrate to Node.js. You will want to use Node.js because of the Node Package Manager (NPM). NPM makes finding, sharing, and reusing Javascript code packages a breeze. When implementing a backend function, the first step to take is to search for an NPM package that provides that function already.

Node.js Express is a simple but powerful Node.js web application framework. We’ll use it as the backend to serve web pages. While Express can serve static files, Nginx is much faster at that task and provides many other benefits.

Using Nginx as a reverse proxy (browsers query Nginx which then calls Express) and cache for Express provides the following benefits:

  • Nginx is built as a high performance server with many optimizations. It can handle many concurrent connections and can perform load balancing. Nginx can serve (or cache and serve) static files like HTML, javascript, images, and CSS more efficiently than Node.js.
  • As the point of entry, Nginx provides better security because it is an older, proven web server solution. Nginx supports both the older SSL/TLS and newer HTTP/2 protocols.
  • Nginx can be used for port 80 and 433 binding to avoid having to run Node.js as a root user, which is bad practice and possible vulnerability. (Under Unix, the first 1024 ports require root privileges to bind to.)

Below are the steps I took to setup Node.js and configure a Nginx reverse proxy and cache. Though I’m doing the steps below on Mac OS X 10 Yosemite, the Node.js code and Nginx configuration should be applicable to other platforms.

Install Node.js

We will install Node.js using MacPorts. Launch the Terminal app and run these commands:

# Node.js uses python scripts; python 2.7 is included with Mac OS X since v10.8
python --version

# Install Node.js
sudo port install nodejs
node -v

# Install Node Package Manager
sudo port install npm
npm -v

# Create a project directory
mkdir myproject
cd myproject
mkdir static

# Create a NPM project package.json file
npm init

# Install Express package
npm install express --save

The “npm init” command will prompt for the project name, version, and description in order to generate a “package.json” file. You can accept the defaults and edit the “package.json” file later.

The “npm install express –save” command will download the Express package to a node_modules subdirectory. The optional “–save” flag will add the Express package and its version as a dependency in the “package.json” file. (The alternative “–save-dev” flag will save the package as a development dependency instead.)

The benefit of the above is that you can give the “package.json” file to another developer and they can run the “npm install” command to install the specific versions of all dependent packages (as listed in the “package.json”).

Express Server

Create a a file named “server.js” with the following content:

// Require Express package
var express = require('express');

// Create an Express app
var app = express();

// Serve static files from static dir
app.use(express.static('static'));

// Handle get on root / request
app.get('/', function (req, res) {
  res.send('Hello World!');
});

// Bind to port 8080
var server = app.listen(8080, function () {
  var port = server.address().port;
  console.log('Listening on port %s', port);
});

To test, do the following:

  1. Put an image file, say “earth.gif”, under the static subdirectory.
  2. In a Terminal window, launch the server with this command:
    node server.js
  3. Browse to http://localhost:8080/ and you will see a “Hello World!” response.
  4. Browse to http://localhost:8080/earth.gif to see the static image file.
  5. In the Terminal window running Node.js, press Ctrl-C to quit.

Instead of using the “node server.js” command, you can use the “npm start” command. If you look inside the “package.json” file, you will see that there exists a script target named “start” which runs the “node server.js” command.

Install Nginx

Install Nginx with this command:

sudo port install nginx

The Nginx configuration file is located at “/opt/local/etc/nginx/nginx.conf”. The default document root is set to “share/nginx/html”, which maps to the “/opt/local/share/nginx/html” directory.

You can start, reload, and stop Nginx using these commands:

# Start Nginx
sudo port load nginx

# Reload the config (actually restarts)
sudo nginx -s reload

# Stop Nginx
sudo port unload nginx

# Check to see if Nginx is running
ps -e | grep nginx

While Nginx is running, browse to http://localhost/ to see the Nginx welcome page.

If you need to troubleshoot, the Nginx error log file is located at “/opt/local/var/log/nginx/error.log”.

Nginx Reverse Proxy

When Nginx proxies a request to Node.js, it will optimized the request headers it receives from the client:

  • Nginx gets rid of any empty headers from the proxied request.
  • Nginx considers any header names with underscores as invalid. It will remove them. If you wish to preserve these headers, set the Nginx “underscores_in_headers” directive to “on”.
  • The “Host” header is re-written to the value defined by the $proxy_host variable. This will be the IP address or hostname and port number of the upstream, as defined by the “proxy_pass” directive.
  • The “Connection” header is changed to “close” to indicate to the upstream server that this connection will be closed once the original request is responded to.

Configure the Nginx reverse proxy by running “sudo nano /opt/local/etc/nginx/nginx.conf” and making the following changes to the root location:

    server {
        # ...

        # Helpful headers to pass to Node.js
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Proto $scheme; #http pr https
        proxy_set_header X-Real-IP $remote_addr; #client IP address
        # List of IP addresses client has been proxied through until now
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        location / {
            #root   share/nginx/html;
            #index  index.html index.htm;

            proxy_pass http://localhost:8080;
        }

Reload the Nginx config with the “sudo nginx -s reload” command. Browsing to http://localhost/ will now show the Node.js “Hello World!” message, instead of the Nginx welcome page.

By default, the “Host” header is set to “$proxy_host”, which is the upstream hostname or IP address and port defined in the “proxy_pass” definition. In the above, we have overridden it to be “$host” which is set to, in order of preference: the hostname from the request line itself, the optional “Host” header from the client request, or the server name matching the request. This is a best practice for Nginx and ensures that the “Host” header passed to the proxied server is as accurate as possible.

Note: The headers sent by the client are available in Nginx as variables. The variables start with an “$http_” prefix, followed by the header name in lowercase, and with any dashes replaced by underscores. So the client “Host” header is available in Nginx as “$http_host”.

If you wish to reverse proxy a non-root path location, use this Nginx location configuration:

        location /proxy/ {
            # Ending slash prevents passing /proxy/ path to Node.js
            proxy_pass http://localhost:8080/; # Ending slash required!
        }

Browse to http://localhost/proxy/ to test.

Nginx Serves Static Files

If Nginx has access to the Node.js project directory (for example, “/Users/myuser/myproject”), it is best to configure Nginx to serve the static files directly.

Run “sudo nano /opt/local/etc/nginx/nginx.conf” and add the following “/static/” location:

        location /static/ {
            root /Users/myuser/myproject; # Node.js project location
            expires 30d; # Cache-Control: client cache valid for 30 days
        }

Browse to http://localhost/static/earth.gif to test.

The “expires 30d” command adds a “Cache-Control” response header telling the browser client to only cache the static resource for 30 days maximum. Install Curl and dump the response header to see the “Cache-Control” value:

# Install Curl
sudo port install curl

# Run Curl to dump response headers
curl -X GET -I http://localhost/static/earth.gif
    # Cache-Control: max-age=2592000

Unfortunately, the above solution requires the URL to contain the “/static/” path. One workaround to avoid the “/static/” path is to have Nginx serve static files with specific extensions like so:

        # location ~* means to use case-insensitive match
        location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|bmp|js|html|htm)$ {
            root /Users/chvuong/nodejs/static;
            expires 30d;
        }

Because Node.js returns “Cache-Control” with an immediate expiration, we can verify that Nginx is serving the static file by doing the following:

# Get static image file from Nginx
curl -X GET -I http://localhost/earth.gif
    # Cache-Control: max-age=2592000

# Get static image file directly from Node.js
curl -X GET -I http://localhost:8080/earth.gif
    # Cache-Control: public, max-age=0

If we use Node.js to provide APIs only, we can configure Nginx to return static files only if they exist. Because API paths don’t usually correspond to existing directories and/or static files, Nginx will pass the API calls to Node.js. Here’s the Nginx configuration to use:

        location / {
            root /Users/chvuong/nodejs/static;
            expires 30d;

            # Return static file if exist; otherwise pass to Node.js            
            try_files $uri @nodejs;
        }

        location @nodejs {
            proxy_pass http://localhost:8080;
        }

Please remove or comment out the previous “location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|bmp|js|html|htm)$” block because it will interfere with the above configuration.

Test using the Curl commands above to get the “earth.gif” static file. You can also edit “server.js” to remove or comment out the line below to prevent Node.js from serving static files:

// Serve static files from static dir
//app.use(express.static('static'));

Nginx Cache

If Nginx does not have access to the static files (for example, Nginx is running on another server), you can configure Nginx to cache the static files returned by Node.js. If the browser client requests a static file which is already cached, Nginx will return it without having to request that file from Node.js again.

Run “sudo nano /opt/local/etc/nginx/nginx.conf” and add the following cache configuration:

http {
    # ...

    # Cache for static files
    proxy_cache_path /tmp/nginx-cache levels=1:2 keys_zone=staticcache:8m max_size=100m inactive=60m use_temp_path=off;
        # keyzone size 8MB, cache size 100MB, inactive delete 60min
    proxy_cache_key "$scheme$request_method$host$request_uri";
    proxy_cache_valid 200 302 60m; # cache successful responses for 60 minutes
    proxy_cache_valid 404 1m; # expire 404 responses 1 minute

    server {
        # ...

        location / {
            proxy_pass http://localhost:8080;
        }

        # Only cache static files; don't cache the dynamic API response!
        location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|bmp|js|html|htm)$ {
            proxy_cache staticcache; # Use "staticcache" we defined above
            proxy_cache_bypass $http_cache_control; # Support client "Cache-Control: no-cache" directive
            add_header X-Proxy-Cache $upstream_cache_status; # Hit or Miss

            # Nginx cache to ignore Node.js default "Cache-Control: public, max-age=0"
            # and don't pass it on to clients
            proxy_ignore_headers Cache-Control;
            proxy_hide_header Cache-Control;
            expires 60m; # "Cache-Control: max-age=3600" tells client to cache for 60 minutes

            proxy_pass http://localhost:8080;
       }

Caveats:

  • Double-check that “server.js” is configured to serve static files:
    // Serve static files from static dir
    app.use(express.static('static'));
  • Nginx will create the “/tmp/nginx-cache” directory because “/tmp” allows write access to everyone. If you change the cache directory location, please make sure to manually create the necessary directories. You will see an error in the Nginx error log if Nginx can’t create or access the cache directory.

You can test the cache by using Curl and taking note of the “X-Proxy-Cache” response header:

# First try will result in cache miss
curl -X GET -I http://localhost/earth.gif
    # X-Proxy-Cache: MISS

# Second try will result in cache hit
curl -X GET -I http://localhost/earth.gif
    # X-Proxy-Cache: HIT

If you wish to cache a non-root path location, use this Nginx location configuration:

        location /proxy/ {
            proxy_pass http://localhost:8080/; # Ending slash required!        
        }

        # Match string changed to capture path after /proxy/
        location ~* ^/proxy/(.+\.(jpg|jpeg|gif|png|ico|css|bmp|js|html|htm))$ {
            proxy_cache staticcache;
            proxy_cache_bypass $http_cache_control;
            add_header X-Proxy-Cache $upstream_cache_status;

            proxy_ignore_headers Cache-Control;
            proxy_hide_header Cache-Control;
            expires 60m;

            # Pass captured path string without /proxy/ to Node.js
            proxy_pass http://localhost:8080/$1;
        }

Nginx Load Balancing

Once you have Nginx reverse proxy working, load balancing is very simple. Here’s the Nginx load balancing configuration:

http {
    # ...

    # Node.js servers for load balancing
    upstream nodejs-backend {
        least_conn; # Give new connection to backend with least active connections
        localhost:8080;
        nodejs2.example.com; # default port 80
        nodejs2.example.com:8080;
    }

    server {
        # ...

        location / {
            # Pass to the upstream name, instead of the specific nodejs hostname
            proxy_pass http://nodejs-backend;
        }

I only tested the above with one Node.js server in the upstream definition (because I only have one server). It worked for one server and it should work for more.

Most info derived from:

No Comments

Setup LAMP (Linux, Apache, MySQL, PHP) on Mac OS X 10.10 Yosemite

Mac OS X No Comments

I downloaded a HTML5 and Javascript demo. When I attempted to browse to it, I encountered the infamous “XMLHttpRequest cannot load file:///” error.  The latest Chrome (and other modern browsers) won’t allow cross domain (a.k.a. cross origin) communication, which would occur when a page from one website domain attempts to read data from another domain.   The demo Javascript code was attempting to read a text file in the same file location using GET, but the local “file:///” protocol was not recognized as a proper website domain and Chrome assumed it was a cross domain security violation.

The only certain solution to the above problem is to run a local web server to host the demo code.  I have a previous post on setting up Apache on Mac OS X (Install Apache, PHP, MySQL, and phpMyAdmin on Mac OS X 10.6 Snow Leopard) which looks to be helpful, but it was outdated.  I have adjusted the instructions for Mac OS X 10.10 Yosemite below.

Configure PHP and Start Apache HTTP Server

Mac OS X 10.10 Yosemite continues to ship with PHP and Apache installed.   (The Apache HTTP server is stopped by default.)  You can check their versions by opening the Terminal app and running these commands:

php -v
httpd -v

Before we start the Apache HTTP Server, enable PHP support by editing the Apache config file (“sudo nano /etc/apache2/httpd.conf”) and uncommenting this line (by removing the initial pound # character):

#LoadModule php5_module libexec/apache2/libphp5.so

The “Web Sharing” option was removed from the “System Preferences” dialog so we have to use the command line to start the Apache server.  You can start, stop, or restart using the following commands:

# Start, stop, or restart Apache HTTP Server
sudo apachectl start
sudo apachectl stop
sudo apachectl restart

# Check to see if Apache HTTP Server is running
ps -e | grep httpd

Note: The “apachectl start/restart” command will configure Apache to start on bootup. (Internally, “apachectl start” calls “launchctl load” and “apachectl stop” calls “launchctl unload”.)

Start the Apache HTTP Server. Browse to http://localhost/ and you should see the “It Works!” message.

Create a test PHP file under the Apache document root directory, “sudo nano /Library/WebServer/Documents/phpinfo.php”, with the following content:

<?php
// Show all information about PHP
phpinfo();
?>

Browse to http://localhost/phpinfo.php and you should see the PHP configuration information.

If you have problems, check the Apache error log file at “/var/log/apache2/error_log” directory.

You can change the Apache document root to point to a different directory by editing “/etc/apache2/httpd.conf” and modifying the values for these two declarations:

DocumentRoot "/Library/WebServer/Documents"
<Directory "/Library/WebServer/Documents">

Restart the Apache HTTP Server for the change to take effect. Make sure that your new document root directory and its contents have read permission set for others (for example, “chmod 755” for directories and “chmod 644” for files).

Install and Start MySQL Server

Download the free MySQL Community Server distribution; I selected the “Mac OS X 10.10 (x86, 64-bit), DMG Archive” package.  You don’t need to login or sign up; just select the “No thanks, just start my download” link at the bottom.  Open the downloaded “mysql-5.7.11-osx10.10-x86_64.dmg” disk image file and run the “mysql-5.7.11-osx10.9-x86_64.pkg” package inside to install MySQL Server. (Strangely, even though I downloaded the 10.10 version, the names of the disk image and package files refer to the 10.9 version.)

Note: When the installation completes, you will see a dialog containing the temporary password for the MySQL root user. Please make a copy of it because you will need it below. If you forget to do so, you can follow the MySQL website’s How to Reset the Root Password page to reset the root password.

mysql_sys_prefsThe MySQL Server will be installed under the “/usr/local/mysql-5.7.11-osx10.9-x86_64” directory. In addition, a symbolic link to that directory is created as “/usr/local/mysql”.

You can start the MySQL Server and configure whether it will run on bootup under “System Preferences, MySQL”. Alternatively, you can start and stop the MySQL Server from the command line:

# Start or stop MySQL Server
sudo /usr/local/mysql/support-files/mysql.server start
sudo /usr/local/mysql/support-files/mysql.server stop

# Check to see if MySQL Server is running
ps -e | grep mysql

Add the following line to your user environment profile, “nano ~/.profile”, to avoid inputting the full path when executing mysql commands:

export PATH=$PATH:/usr/local/mysql/bin

Start the MySQL Server and try these commands:

# Show MySQL version
mysql -u root --version

# Connect to MySQL Server
mysql -u root -p
# Input the temporary root password when prompted

# Reset the root password to blank
mysql> alter user 'root'@'localhost' identified by '';
# Put your password inside the '' at the end if you don't want a blank password

# Some example queries
mysql> show databases;
mysql> use mysql;
mysql> show tables;

# Exit the MySQL interpreter
mysql> quit

Additional info about LAMP setup can be found at Get Apache, MySQL, PHP and phpMyAdmin working on OSX 10.10 Yosemite.

No Comments

Windows 8.1 Boot Camp on 2015 Macbook Pro Retina 13 Inch

Mac OS X, Windows No Comments

I recently upgraded to a 2015 Macbook Pro Retina 13 inch laptop. I attempted to install Windows 7 using the Boot Camp Assistant, which immediately asked for a Windows 8 or later installation media to be inserted. Darn it. I managed to create and insert a USB flash drive containing the latest Windows 8.1 with Update. After that, the Boot Camp Assistant asked me for the Boot Camp Support Software (Windows drivers). I inserted a second USB flash drive containing the latest Boot Camp Support Software I had manually downloaded from the Apple website, but Boot Camp Assistant still complained that it couldn’t be found. It turned out that for newer Macbooks, I must download the Boot Camp Support Software using the Boot Camp Assistant.

After I overcame the above and other issues, I was able to get a Windows 8.1 Boot Camp working. I’ve documented the steps I took below.

Create a Windows 8.1 Install USB Flash Drive

I used my Windows 7 desktop to create a USB flash drive containing the 64-bit version of Windows 8.1 with Update. (2015 Macbooks only support 64-bit Windows 8 or later.) Because Windows 8.1 setup requires 4.5GB of space, you must use an 8GB or larger USB flash drive; I ended up using a spare 16GB flash drive that I had.

Update: Instead of using the WinToFlash utility below and dealing with its browser plugin spam, use Window’s built-in DiskPart command-line utility to create a bootable USB flash drive containing the Windows Setup.

NovicorpWinToFlashLiteI used the free Novicorp WinToFlash Lite utility to copy the contents of my Windows 8.1 with Update ISO file (alternatively, you can use a Windows 8.1 DVD) to the USB flash drive. WinToFlash will re-format the USB flash drive using FAT32 format before copying the content over.

Note: Strangely, WinToFlash won’t throw an error even if you use a USB flash drive that is too small. I tried a 1GB USB flash drive and WinToFlash completed successfully. So make sure to use an 8GB USB flash drive or larger.

Unfortunately, the first time you run the latest version of WinToFlash, it will install a browser plugin called “WinToFlash Suggestor” which adds advertisements to search suggestions. Go ahead and uninstall this unnecessary browser plugin using the Control Panel’s “Uninstall a program” function.

Note: The Microsoft website has a Windows USB/DVD Download Tool which can do what WinToFlash does. Unfortunately, that tool re-formats the USB flash drive as NTFS. Because the Macbook uses UEFI BIOS boot up which only works with FAT32, the USB flash drive created by the Windows USB/DVD Download Tool won’t be bootable.

Download The Boot Camp Support Software

For Macs released in 2014 and 2015, you must use the Boot Camp Assistant to download a specific version of the 64-bit Boot Camp Support Software for your Mac. Apple does not provide links to manually download all the available Boot Camp Support Software versions. (You can manually download the older Boot Camp Support Software 5.1.5640 64bit for Mid and Late 2013 Macs here and Boot Camp Support Software 5.1.5621 64bit for Early 2013 or previous Macs here.) For 32-bit Windows installation and other options, check Apple’s System requirements to install Windows on your Mac using Boot Camp page.

BootCampAssistantWindows8In order to install Windows 8.1, the Boot Camp Support Software needs to be incorporated into the Windows 8.1 Install USB flash drive. The simplest method is to have the Boot Camp Assistant download the Boot Camp Support Software directly to the Windows 8.1 Install USB flash drive.

Note: I tried installing with two USB flash drives, one containing the Windows 8.1 Install and the other containing the Boot Camp Support Software, but the Windows 8.1 setup threw a “No new devices drivers were found” error even after I had manually selected the I/O driver on the Boot Camp Support Software USB flash drive.

To download the latest Windows drivers from Apple:

  1. Insert the FAT32-formatted Windows 8.1 Install USB flash drive.
  2. Run Boot Camp Assistant.
  3. Select the “Download the latest Windows support software from Apple” option. Click Continue.
  4. Select the Windows 8.1 Install USB flash drive. (Boot Camp Assistant requires FAT32 format and at least 500MB free.) Click Continue.
  5. Boot Camp Assistant will copy all the Boot Camp Support Software content (“$WinPEDriver$” directory, “BootCamp” directory, and “AutoUnattend.xml” file) to the USB flash drive’s root directory (which is where the Windows 8.1 setup will expect them to be).

Install Windows 8.1

To install Windows 8.1, run the Boot Camp Assistant and select the option to “Install Windows 8 or later version”. Follow the instructions to create a BOOTCAMP partition. With the Windows 8.1 Install USB flash drive still inserted, agree to restart the Macbook.

On reboot, the Macbook will boot from the Windows 8.1 Install USB flash drive. (If it doesn’t, shutdown the Macbook and power it up while holding the alt/option key. When the boot screen appears, select the USB flash drive’s “EFI Boot” option.)

The Windows 8.1 setup will automatically use the Boot Camp Support Software’s I/O driver to access the hard drive and show the list of partitions. Select the BOOTCAMP partition and allow it to be re-formatted as NTFS. Windows 8.1 setup will then install itself onto that NTFS partition.

After reboot and once the Windows 8.1 initial setup is completed (can take several minutes), the Boot Camp Support Software installer will automatically execute to install the necessary Apple hardware drivers.

Note: The Windows 8 version of Windows Defender is different from the Windows 7 version. Windows 7 Defender only protects against spyware, so the recommendation is to disable it and install Microsoft Security Essentials which protects against virus, spyware, and malware. However, Windows 8 Defender protects against virus, spyware, and malware so there is no need to replace it. (Microsoft Security Essentials can’t be installed on Windows 8.)

All in all, the Windows 8.1 Boot Camp installation went smoothly once I knew to creat a USB flash drive containing both Windows 8.1 and the Boot Camp Support Software.

Some info above derived from:

No Comments

Revert Mac OS X Yosemite Core Storage Back to Mac OS Extended HFS+

Mac OS X 7 Comments

My Macbook Pro’s hard drive died recently, again. The Apple Store had to order the replacement Hitachi 750GB hard drive which took several days. I have a suspicion that Apple is using refurbished hard drives because it has just been two months since the last hard drive replacement. Hitachi is a brand I can trust… to fail quickly… because in addition to these two failures, when I first got my brand new Macbook years ago, the Hitachi drive died within three months. This time, I decided to install a Samsung EVO 850 500GB solid state hard drive to avoid having to visit the Apple Store again.

I also decided to do a fresh installation using the latest Mac OS X 10.10 Yosemite version. When I attempted to partition the hard drive into a Mac OS X Yosemite, a Windows 7 Boot Camp, and a shared FAT32 partition, I found that I couldn’t merge or resize the Mac partition to create the shared FAT32 partition using either Disk Utility or the diskutil command line.

The problem is that Yosemite installs the Mac OS X partition using a new Core Storage volume manager, which in turn uses the HFS+ (aka Mac OS Extended) file system. Unfortunately, Apple has not yet updated the Disk Utility or diskutil command line to resize, merge, or delete a Core Storage volume. Boot Camp does know how to resize the Core Storage volume correctly though. (Supposedly, there is an undocumented “diskutil coreStorage resizeVolume” command that supports resizing a Core Storage volume, but I hesitate to use it. And I couldn’t find an undocumented command to merge a Core Storage volume with a blank partition.)

Run the Terminal app and execute the “diskutil list” command to show the Core Storage volume (under “/dev/disk0”), which wraps the old HFS+ partition (under “/dev/disk1”).

yosemite_corestorage_1

The Core Storage volume manager is the basis for Apple’s Fusion Drive technology, which is used to present several partitions on multiple drives as a single logical volume. Because I had only one hard drive on my Macbook, I didn’t need that function. (I can see using the Fusion Drive feature on a server which usually has more than one hard drive.) Thankfully, I found a way to convert the Core Storage volume back to a plain old HFS+ partition. Note that this method only works if the Core Storage volume is not encrypted.

To start, you need to find the Core Storage Logical Volume identifier used by the wrapped HFS+ partition. It is the long alpha-numeric string (“1FC06AF9-EED2-4066-BE3F-FE47166A2190” on my machine) listed under the HFS+ partition (“/dev/disk1/”) in the “diskutil list” command output above.

You can also find the Logical Volume identifier and encryption status by running the “diskutil cs list” command in the Terminal app.

yosemite_corestorage_2

Locate the bottom-most “Logical Volume” entry which has the identifier listed. Underneath that is the “Revertible: Yes (no decryption required)” line which indicates that the volume is not encrypted and can be reverted.

Once you have the Logical Volume identifier, you can revert the Core Storage volume back to a plain HFS+ partition using the “diskutil coreStorage revert” command like so:

yosemite_corestorage_3

You will need to reboot the Macbook. If you don’t reboot and run the “diskutil list” command, it will incorrectly show the logical volume (under “/dev/disk1”) even though the Core Storage has been replaced by HFS+ (under “/dev/disk0”).

yosemite_corestorage_4

Once the old HFS+ partition was back in place, I was able to delete, merge, and resize to my heart’s content. The solid state hard drive makes Mac OS X blazing fast; I regret waiting so long before installing one.

7 Comments

Bootable USB Flash Drive to Install Mac OS X 10.10 Yosemite

Mac OS X No Comments

Update: Go to Install macOS Sierra Using Bootable USB Flash Drive if you want to install macOS Sierra instead.

In this post, I will go over instructions on how to create a bootable USB flash drive containing the Mac OS X 10.10 Yosemite installer. These instructions will also work for Mac OS X 10.9 Mavericks (excluding a Yosemite-specific step) and differ significantly from the instructions for creating a Mac OS X 10.6 Snow Leopard installer. You will need an 8GB USB flash drive for Mac OS X Yosemite or Mavericks.

I tried several methods which failed to create a bootable USB flash drive before finding one that succeeded. The instructions I found that worked, using Disk Utility, were located at How to Make a Bootable OS X Mavericks USB Install Drive and How to Create a Bootable Install USB Drive of Mac OS X 10.10 Yosemite.

Download the Mac OS X 10.10 Yosemite

First, download the latest Mac OS X version, which is 10.10 Yosemite. It is the version currently available for download from the “App Store”. (If you want an earlier version like Mac OS X 10.9 Mavericks, you’ll need to get it from elsewhere.)

Launch “App Store” and search for “OS X Yosemite”. Download it. (It is 5.16GB in size.)

Note: If you run the Yosemite installer to upgrade your Mac, the downloaded installer file will be deleted automatically after the upgrade is completed. To keep that file, you will want to move it out of the Applications folder so it won’t be deleted after an upgrade. Launch the “Terminal” app and run this command to move the downloaded installer app to your user’s “Downloads” folder:

sudo mv /Applications/Install\ OS\ Yosemite.app/ ~/Downloads/

Create Bootable USB Flash Drive Installer

By default, the Finder will hide system files which we will need to see. Run these commands in the “Terminal” app to expose the hidden files:

# Configure Finder to show hidden system files.
defaults write com.apple.finder AppleShowAllFiles TRUE

# Close all Finder instances (and re-launch so settings take effect).
killall Finder

Prepare the USB flash drive:

  1. Plug in a USB flash drive of size 8GB or larger.
  2. Launch the “Disk Utility” to format the USB Flash drive.
  3. On the left-hand pane, select the USB drive (not the partition under it, if any).
  4. Click on the “Erase” tab, select “Mac OS Extended (Journaled)” for “Format” and input a name like “Install Yosemite” (or anything because this name will be overwritten later).
  5. Click the “Erase…” button at the bottom and then the “Erase” button in the popup dialog. This format operation should take less than a minute to complete.

Restore the Yosemite installation image to the USB flash drive:

    bootable_usb_yosemite_1

  1. Launch the Finder and locate the “Install OS Yosemite.app” file. Right-click (hold the “control” key and click) on it and select “Show Package Contents”.
  2. Open Contents, then SharedSupport, and double-click on the InstallESD.dmg (disk image) file to mount it. A volume called “OS X Install ESD” will show up on the desktop and under DEVICES in the Finder.
  3. In the “OS X Install ESD” volume, right-click on the “BaseSystem.dmg” file and select “Open” to mount it. (Double-click won’t perform any action because it is a hidden file.)
  4. Use Disk Utility to clone the “BaseSystem.dmg” to the USB flash drive:
      bootable_usb_yosemite_2

    1. Select the “BaseSystem.dmg” in the left-hand pane and click on the “Restore” tab. The “Source” field will be populated with “BaseSystem.dmg”.
    2. Drag the “Install Yosemite” partition under the USB flash drive to the “Destination” field.
    3. Click the Restore button and then the Erase button.
    4. The USB flash drive will be written with the contents of “BaseSystem.dmg” file. Depending on the speed of your USB flash drive, it may take several minutes or longer to complete this operation.
    5. Once complete, the “Install Yosemite” partition will be renamed to “OS X Base System”.

    bootable_usb_yosemite_3

  5. Use the Finder to navigate to the USB flash drive. You will see two “OS X Base System” volumes in the Finder’s left-hand pane. The USB flash drive is the last one.
  6. Under the USB flash drive’s “OS X Base System” partition, open the “System/Installation” folder. You will see an alias file named “Packages”. Delete it because we will replace it with a “Packages” folder below.
  7. Use a second Finder window to open the “OS X Install ESD” volume. (To open a second Finder window, you can use the Finder menu’s “File/New Finder Window” command.)
  8. Copy the “Packages” folder from the “OS X Install ESD” volume to the USB flash drive’s “System/Installation” folder.
    bootable_usb_yosemite_4

  9. Required for Yosemite (not required for Mavericks): Copy the “BaseSystem.chunklist” and “BaseSystem.dmg” files from the “OS X Install ESD” volume to the USB flash drive’s root “/” folder. If you don’t do this, you will get an “undefined error 0” when attempting to install Yosemite.
  10. The USB flash drive is now complete. You can use it to boot a Mac to install Mac OS X 10.10 Yosemite.
  11. Unmount all the Yosemite installer volumes by ejecting them; you must eject “OS X Base System” before “OS X Install ESD”.

Re-configure the Finder to hide system files. Run these commands in the “Terminal” app:

# Configure Finder to not show hidden system files.
defaults write com.apple.finder AppleShowAllFiles FALSE

# Close all Finder instances (and re-launch so settings take effect).
killall Finder

Boot With USB Flash Drive

To boot a Mac with the USB flash drive:

  1. Insert the USB flash drive.
  2. While holding the “option/alt” key down, turn on the Mac to display the boot Startup Manager.
  3. You should see one or two icons, one for the internal hard drive and/or another called “OS X Base System” for the USB flash drive. (The internal hard drive may not be visible if it does not have a bootable partition installed.)
    • Note: If you don’t see the USB flash drive’s “OS X Base System”, try removing and re-inserting the USB flash drive while viewing the Startup Manager screen. The USB flash drive should then appear after a few seconds.
  4. Select the “OS X Base System” and hit the “return/enter” key to boot from the USB flash drive.

Hopefully, this post will help you to create your own bootable USB flash drive installer for Mac OS X 10.10 Yosemite or Mac OS X 10.9 Mavericks.

No Comments

Update to Latest Subversion Using MacPorts

Mac OS X No Comments

Because I make use of MacPorts to install my developmental tools on Mac OS X, installing or updating Subversion is simple, consisting of a single command line.

Install MacPorts

If you don’t already have MacPorts, go ahead and install it. MacPorts depends upon Xcode and the Xcode Command Line Tool. Instructions for installing both are provided on the MacPorts website.

Notes:

  • MacPorts is specific to the Mac OS X version, so download and install the correct version.
  • After you install the Xcode Developer Tools (free from the Mac’s App Store), run this Terminal command to install the Command Line Developer Tools:
    xcode-select --install

Update MacPorts

Before installing or updating Subversion, you will want to update MacPorts by issuing this command:

sudo port -v selfupdate

Install Subversion

To install Subversion, issue a MacPorts command to install it like so:

sudo port install subversion subversion-javahlbindings

The Subversion JavaHL Bindings (“subversion-javahlbindings”) package is necessary to support integration with Eclipse, specifically using the Subclipse plugin. Thank heaven that MacPorts got around to supporting the Subversion JavaHL Bindings installation. Before, I had to manually find a compatible version of the JavaHL Bindings, download, and install it myself.

Note: When installing the Eclipse Subclipse plugin, you will need to select the specific Subclipse version that uses a Subversion version that is the same as your installed Subversion and JavaHL Bindings. The version numbers don’t match so you will need to look at the Subclipse documentation to determine which version of Subclipse to install. For example, Subclipse 1.10 uses the latest Subversion 1.8.

Update Subversion

You can update Subversion specifically or update all outdated MacPorts-installed packages by issuing these commands:

# Update only Subversion and JavaHL Bindings
sudo port –v upgrade subversion subversion-javahlbindings

# Update all outdated installed packages including Subversion
sudo port -v upgrade outdated

Install or Update Subclipse

To install or update the Eclipse Subclipse plugin, you will use the same installation instructions. Subclipse doesn’t have a separate update mechanism. To update Subclipse, you would basically install a newer version of it (without needing to remove the older version first).

Note: Eclipse has a menu item, Help->Check for Updates, which will update itself and supported plugins; unfortunately, Subclipse does not support this function.

To install or update Subclipse, follow these steps:

  1. Go to Eclipse menu: Help->Install New Software…
  2. Input “http://subclipse.tigris.org/update_1.10.x” into the “Work with” field and the table will be updated with installation packages available at that location. (Note: Subclipse 1.10 uses the latest Subversion 1.8.)
  3. Check just the Subclipse package and keep clicking Next until the end. Half-way through, you will be asked to accept the license agreement. Select the “I accept the terms of the license agreements” radio button and click Finish.
  4. You will get a security warning popup with the message, “Warning: You are installing software that contains unsigned content.” Click the OK button to proceed.
  5. Eclipse will need to restart. You will be prompted with a “Software Updates” popup asking “You will need to restart Eclipse for the changes to take effect. Would you like to restart now?” Answer Yes.

Use Older Subversion

MacPorts allows you to select an older version of its packages for use, instead of using the latest version. This is useful in case you do an update and realize that you can’t use the latest version of a particular package, perhaps due to software version incompatibility with one of your tools or applications. For example, because the latest version of Subclipse may not support the latest version of Subversion, you may need to force the use of the previous version of Subversion.

To see all the installed versions of Subversion, run this command:

sudo port installed | grep -i subversion

You should see something like the following output:

subversion @1.7.8_2
subversion @1.7.10_1
subversion @1.8.8_0 (active)
subversion-javahlbindings @1.7.8_2
subversion-javahlbindings @1.7.10_0
subversion-javahlbindings @1.8.8_0 (active)

To activate the previous version of Subversion, use these commands:

sudo port activate subversion @1.7.10_1
sudo port activate subversion-javahlbindings @1.7.10_0

If you are using the latest Subversion and want to uninstall all the older versions, run either of these commands:

# To uninstall a specific version of Subversion
sudo port uninstall subversion @1.7.10_1
sudo port uninstall subversion-javahlbindings @1.7.10_0

# To uninstall inactive versions for all packages including Subversion
sudo port uninstall inactive

I’m very glad that MacPorts exist to make installations and updates so painless.

Eclipse Keeps Asking For Subversion Password

I encountered a bug where Eclipse kept prompting me to input the Subversion password whenever I attempted to run a Subversion command such as update. Even though I checked the save password option, Eclipse would still prompt me each time. I did not encounter this issue using the command line Subversion, so I thought it was a Subclipse bug.

Turns out that this was an Eclipse bug, involving how Eclipse interacted with the Mac OS X Keychain where the subversion password was stored. I used the solution found at the bottom of this page, Subclipse 1.10.0 not saving passwords, to update the Eclipse code signature, which eliminated the password prompts.

Quit Eclipse and run this command:

codesign --force --sign - /Applications/eclipse/Eclipse.app

Run Eclipse and issue a Subversion command like update. If you get a Keychain access dialog, select “Always Allow”.

Note: The above command will also fix the problem where the latest Eclipse Mars.2 version keeps asking for permission to “Accept Incoming Network Connections” on startup. Just run the “codesign” command and you will need to answer that prompt once only.

codesign --force --sign - /Applications/Eclipse.app
No Comments

Make Mac Screen Lock Secure and Convenient

Mac OS X No Comments

The Macbook I got for work is configured to require the password after the screensaver turns on or the display goes to sleep. By default, the screen is set to sleep after 2 minutes of inactivity on battery and 10 minutes on power adapter. When I work on two computers, alternating between the Macbook and a desktop, I hate having to keep inputting the password on the Macbook to unlock it.

I understand the need for security, but I draw the line when it makes using the Macbook too inconvenient. I don’t want to eliminate the password requirement, I just want the screen locks (which require the password to exit from) not to occur so often.

I considered adjusting the power settings so that the Macbook won’t go to sleep until an hour of inactivity occurs on either battery or power adapter. (Likewise, changing the screen saver to wait an hour.) However, making such a change would cause the battery usage to increase (the display uses a lot of power) and require a shorter interval between charges. (To preserve the battery capacity, I usually use the battery until it is very low before charging. And when charging, I try to give it an opportunity to charge to 100 percent.) While I don’t use the Macbook differently on battery versus power adapter, having to charge and being tethered to the wall socket more often is inconvenient.

macbook_screen_lockI found the solution in “System Preferences”, under the “Security & Privacy” section. There is an option named “Require password [time interval] after sleep or screen saver beings” that controls when the screen lock activates. I changed the time interval from the initial 5 seconds to 1 hour. (There are 7 selectable time intervals ranging from immediately to “4 hours”.) Now, when the screen saver runs or the Macbook goes to sleep (for example, when I close the lid), I don’t need to input the password when I wake the Macbook before the 1 hour interval expires.

This setting gave me a good compromise between security and convenience. I am not required to input the password for any inactivity less than an hour and I can leave the power (and screen saver) settings on battery conservation mode.

But what if I need to put the Macbook immediately into screen lock mode? The answer surprisingly lies in the “Keychain Access” application. To support manually locking the Mac, do the following:

  1. Run the “Keychain Access” application (under /Applications/Utilities directory).
  2. Go to the “Keychain Access” menu, Preferences, General, and check the “Show keychain status in menu bar” option.

You should now see a lock icon on the top-right menu bar. When you want to manually lock the Mac, click on the lock icon and select “Lock Screen”.

Hopefully the above will help you to secure your Mac without making it too inconvenience to use.

Note: The “Lock Screen” method above was gotten from Quickly lock your screen. Unfortunately, on Mac OS X Mountain Lion, the re-arrange menu bar icon function (hold Cmd and drag icon left or right) didn’t work so I was not able to get a keyboard shortcut working for “Lock Screen”.

No Comments

Sharing Applications Between Mac OS X and Windows

Mac OS X, Windows No Comments

In my previous post, Setup Mac OS X 10.8 Mountain Lion, Windows 7 Boot Camp, and Shared FAT32 Partition, I decided to use Mac OS X as much as possible and in addition to Windows 7. It would be nice if I could use the same applications (or equivalents) on both operating systems. And it would be great if those apps made use of the same data whether running on Mac OS X or Windows 7. Effectively, I would like to share my apps between Mac OS X and Windows 7.

My methods for “App Sharing” in order of preference are:

  1. If both the Mac OS X and Windows 7 application versions use the same data format, then store that application data in a shared FAT32 partition (I had corruption issues with exFAT). If you don’t have a shared partition, you can use a private network share or even a cloud-based drive like DropBox (which introduces some security concerns).
    • My favorite secured information storage apps, Keepass and Truecrypt, run under both Mac OS X and Windows 7 and use the same data files on the shared partition. (Note: I saw some comments that using a large Truecrypt file with Dropbox may have issues such as sync not working 100% or not working in a timely manner.)
    • To a lesser extent, iTunes on Mac OS X and Windows 7 can use the same music and video files on the shared partition. Just run each iTunes and use the Mac OS X “File->Add to Library” or Windows 7 “File->Add Folder to Library” menu option. If you wish to sync your iPod, iPhone, or iPad to either the Mac OS X or Windows 7 iTunes, make sure they share the same library identifier; see my post, Sync an iPod Touch to Two Computers, for instructions.
  2. If the Mac OS X and Windows 7 application versions don’t use the same data format, then they might support cloud sync’ing. My primary concern with the cloud is security, because a copy of my information will be accessible on the Internet and stored in a hard drive belonging to a company which might not always have my privacy as its top priority. It is a lot less secure than just having a local copy on my hard drive. To mitigate this, I will remove all sensitive information before using the cloud.
    • The browser I use, Chrome, supports sync’ing bookmarks, tabs and extensions to/from Google. It’s as simple as going to Settings, “Signing in to Chrome” (specifically, providing your Google account’s username and password), and clicking on “OK, sync everything”. If you sign in from multiple machines, the bookmarks will be merged. To see tabs opened on other machines, create a new blank tab and click on the “Other devices” link at the bottom.
    • The latest version of my favorite note taking application, Evernote, runs on both Mac OS X and Windows and supports cloud sync’ing. For sensitive info, the latest Evernote offers an option to password-protect-encrypt a note. I am using an old, non-cloud-enabled version 2.1 of Evernote for Windows and plan to upgrade to the latest cloud-enabled versions on Mac OS X and Windows 7.
    • My contact information and notes are stored in a Personal Storage Table (PST) file used by Microsoft Outlook for Windows. I found that Outlook 2003, 2007, and 2010 for Windows used the same PST file without any issues. And Outlook 2010 for Windows can cloud sync directly to Google Contacts and Notes (Google provides sync tools for Outlook for Windows). Unfortunately, Outlook 2011 for Mac OS X does not use PST and does not support cloud sync’ing directly to Google. However, Outlook 2011 for Mac OS X can sync to the Mac OS X Mountain Lion’s Contacts (new name for Address Book) and Notes applications, and the Contacts and Notes application can cloud sync directly to Google. (If you don’t want to use Google, there is a way to use iCloud instead for the same purpose.)
    • If I wish to sync my contacts and notes in Outlook to an iPhone or Android phone, the above method of cloud-sync’ing to Google Contacts and Notes will help. I can sync contacts and notes on the iPhone and Android phone directly to/from Google. Alternatively, for iPhone, I can use iTunes sync with Outlook on Windows, or iTunes sync with Contacts and Notes on Mac OS X.
  3. If the Mac OS X and Windows 7 application versions don’t use the same data format and don’t support cloud sync’ing, they will usually provide an export/import migration path between the Mac OS X and Windows 7 application versions. In this case, I would just migrate to using the application solely on Mac OS X. In the future, if I need to, I can migrate back to Windows 7.
    • My expense tracking application, Quicken, supports migrating data from the Windows version to Mac OS X version. Because Quicken for Mac OS X may not have the same set of features as for Windows, you will want to research whether the Mac OS X version will fit your needs. I plan to upgrade from Quicken 2003 for Windows to Quicken Essentials 2010 for Mac OS X.

Moving from Evernote 2.1 for Windows to Evernote 4.5 for Windows and Evernote 3.3 for Mac OS X

Evernote supports export/import but there was an export data format change between Evernote 2.1 and the latest Evernote versions. I found a forum post, New user help-importing Evernote 2.0 files into Evernote 4.1, which indicated that we need to use Evernote 3.1 for Windows to import the old Evernote 2.1 format and then export to the new data format. Actually, I found that Evernote 3.1 was cloud-enabled, so there was no need to export because the imported 2.1 notes were sync’ed directly to the cloud.

Here’s how I migrated from Evernote 2.1 to the latest version:

  1. Run Evernote 2.1 for Windows. There is no need to do an export because the exported “ENExport.enx” file won’t be usable.
  2. Look at the bottom status bar to see the total number of notes. It will say something like “Notes: 272” or “Notes: 15 of 272”.
  3. Quit Evernote 2.1. Do not uninstall it yet because we may need to use it later to verify that all notes were migrated.
  4. Install Evernote 3.1 for Windows (it will co-exist fine with Evernote 2.1). I was able to download a version of Evernote 3.1 from FileHippo.
  5. Run Evernote 3.1 and sign-in. You will need to register for an Evernote account, if you don’t already have one, to use Evernote. Even if you plan to only use locally stored notes, and not the cloud-sync’ed notes, you still need to have an account.
  6. Go to menu File->Import->Evernote 2.x Databases… and select your 2.1 database file “EverNote.enb”, which is usually located under the Evernote 2.1 install directory; for example: “C:\Program Files\Evernote\Evernote 2”. (Note: There is a menu option File->Import->Evernote Export Files… but it will ask for the new .enex export file which we don’t have.)
  7. The import will occur. At the end, I got a warning message saying that some of my imported notes contained “Premium File Attachments” which are not supported under the free account. I didn’t think I was attaching any files that were not in the list of supported free file attachment types (also listed in the warning dialog), so I clicked on the “Restricted Import” button. “Restricted Import” appears to import all notes except the ones that have the premium file attachments.
  8. Once the import completed, a “Data import successful” dialog appeared and asked if I wanted to “Place all imported notes into a synchronized notebook now?” I answered Yes.
  9. Back in the main Evernote window, in the left navigation pane, I noticed a new notebook called “EverNote” under the Notebooks section. There is a sync icon before the name, which I guess means it is synchronized to the cloud. After the name is the number of notes in parenthesis; in my case, it shows as “Evernote (271)”.
  10. Since I had 272 notes in Evernote 2.1, it looks like one note was not imported, probably the one with the premium file attachment. Now to track down the missing note.
    • I checked the log file by going to menu Tools->Options->General->Open Log folder and opening the “AppLog_[date].txt” file. (There is a “SyncLog_[date].txt” but it just contains logs from the cloud sync function, not the import function.) I scrolled to the bottom of the AppLog and saw this message, “272 notes successfully imported”. There wasn’t any message about which note was not imported. Darn.
    • Looks like I have to do a brute-force comparison with the old Evernote 2.1 notes. Thankfully, I filed my notes under many manual categories so it really helped to facilitate the comparison. On Evernote 3.1, in the left navigation pane, I opened up Tags->Manual categories. I started Evernote 2.1 and opened its Manual Categories. Then I checked the count of notes in each category to find a mismatch in the number. I was able to locate the missing note in Evernote 2.1. Strangely, it only had an embedded image and I was able to copy and paste it into Evernote 3.1 successfully. The count of notes in Evernote 3.1 went to 272. Problem solved.
  11. I noticed that all my imported notes had text saying “(needs sync)” in its title. Looks like I needed to synchronize the imported data to the cloud.
    • I was concerned about the 60MB/month upload limit on a free Evernote account. To see the size of my database, I went to menu Tools->Account Properties and Database tab. My notes are mostly text so it was only 2.4MB in size. I think if your data is larger than 60MB, you might need to sign up for the premium account.
    • In that same Account Properties dialog, under the Account Usage tab, I found how much of the 60MB/month limit I had already used; it said “”0.5MB out of 60 MB used” so far. You can also get to this tab by clicking on the “Current Monthly Usage” in the top ribbon-like bar.
    • I clicked the Synchronize button at the top-left to sync against the cloud. The progress was reported in the bottom status bar to the right and looked like “Updating server database, 55% done”. Strangely, “Updating server database” went to 100% about 3-4 times, interspersed with “Updating client database…” progress messages.
    • Once the sync was complete (no more status updates), my notes no longer had the “(needs sync)” text in the title. I double-checked the monthly usage and it still said “0.5MB out of 60 MB used”, instead of the 2.9MB that I expected. Oh well.
  12. Exit Evernote 3.1. If you exit with unsynchronized notes (even notes in the trash), you will see a warning dialog. Just cancel the exit and do the sync and/or empty the trash.
  13. Uninstall Evernote 3.1 and re-install the latest Evernote 4.5 for Windows. You can also install the latest Evernote 3.3 for Mac OS X (from the Mac App Store).
  14. Once you sign-in to Evernote, the notes will sync down from the cloud. You can see the sync progress in the status bar; under Evernote 4.5, to show the status bar, go to menu View->Show status bar.

Sync’ing Contacts and Notes between Outlook 2010 for Windows and Outlook 2011 for Mac OS X

As described above, sync’ing contacts and notes between the Windows and Mac OS X versions of Outlook is complex, involving intermediate applications. I will do a separate post later about how to do the Outlook sync between Windows and Mac OS X.

Moving from Quicken 2003 for Windows to Quicken Essentials 2010 for Mac OS X

Because I use Intuit Quicken as a glorified expense tracking application where I manually input all the expenses and run summary reports, I was fine with using the very old Quicken 2003 for Windows. I used one Quicken file for each year and in the file, I used one account for each month. So, for each year, I could see the trend of how much I spent monthly (accounts listing) and how much I spent per category (itemized report).

From the reviews complaining that Quicken Essentials for Mac OS X is a glorified checkbook with transaction downloads from banks, it looks to be more than what I need because I didn’t want to download transactions from a bank. I don’t plan to provide my bank’s login credentials to anyone! After testing Quicken Essentials, I found that it was fine for my needs: manual expense input works great and the pre-defined summary, trend, and itemized category reports provided the info I wanted.

Unfortunately, to migrate from Quicken 2003 for Windows to Quicken Essentials for Mac OS X, I needed to upgrade to Quicken 2004 for Windows as an intermediate step. How do I know this? The Quicken Essentials’ converter tool told me so when I attempted to open a Quicken 2003 file.

Thankfully, Intuit provides a copy of Quicken 2004 free for anyone who needs to upgrade to Quicken 2005 and later from a version earlier than Quicken 2004. To download and install Quicken 2004 Deluxe, do the following:

  1. Browse to Using an Intermediate Version To Convert Older Versions of Quicken.
  2. Expand “Quicken for Microsoft Windows” and click on “Quicken 2004 for Windows” to download it. (Note: If you use Chrome, Chrome may report that the download page contains malware, but this is a false positive. Ignore it and click on the “proceed anyway” link.)
  3. Once downloaded, run “QW04DLX.exe” to install Quicken 2004 Deluxe.

To upgrade your data files from Quicken 2003 to Quicken 2004:

  1. Locate your Quicken 2003 data files (they come in file sets with extensions .QDF, .QEL, .QPH, and .QSD). By default, the data files are located in the Quicken installation directory under “C:\Program Files\Quicken” or “C:\Program Files (x86)\Quicken”, or they could be under the “My Documents\Quicken” or “Documents\Quicken” folder.
  2. Run Quicken 2004, go to File->Open, and select the 2003 .QDF file. Quicken 2004 will show a “Convert your data file” dialog, so confirm it by clicking on the OK button.
  3. Quicken 2004 will save the original 2003 data files under a “Q03Files” sub-directory and generate the updated 2004 data files (file sets using extensions .IDX, .QDF, QEL, .QPH, and .QSD).
  4. Repeat the above to upgrade other 2003 files.

To export the Quicken 2004 files to a format compatible with Quicken Essentials for Mac OS X (and Quicken 2012 for Windows):

  1. The Quicken Essentials install CD comes with a Windows converter program (insert the CD under Windows to access it) and a PowerPC converter program (which can only run in Mac OS X Snow Leopard or earlier) which can be used to convert Quicken 2004 files and later for use by Quicken Essentials.
  2. Because I didn’t have a Mac OS X Snow Leopard or earlier machine, I decided to run the converter under Windows. Instead of using the converter on the CD, I downloaded the latest Windows Quicken_converter.exe from Converting to Quicken Essentials for Mac from Quicken for Windows or MS Money: expand the “Convert your data from Quicken for Windows” section, look for the “Quicken_Converter_Setup.exe” reference, and click on the “you can download the converter here” link. (Note: If you use Chrome, Chrome will display a false malware warning which you can ignore by clicking on the “proceed anyway” link.)
  3. Run the downloaded “Quicken_Converter.exe” to install “Quicken Converter 2012”.
  4. Launch “Quicken Converter”.
  5. Select “I’m transferring data from Quicken for Windows”, click “Get Started”, select “Open a data file located on this computer” and click “Select File”.
  6. Select your Quicken 2004 .QDF file and click “Convert it!” in the confirmation dialog.
  7. Once done, you will be asked to indicate the location to save the transfer file to. Click OK and select a directory. I selected the automatically created “Q12Files” sub-directory.
  8. Click Save and the resulting export .QXF file (and a new updated 2012 .QDF file) will be saved to the selected directory. This .QXF can be imported into Quicken Essentials for Mac OS X or Quicken 2012 for Windows. (I also think that Quicken 2012 for Windows can open the updated .QDF file directly.)
  9. Click “Convert Another” and repeat the above to convert other Quicken 2004 .QDF files.

To import the exported .QXF files into Quicken Essentails for Mac OS X:

  1. Copy the exported .QXF files from Windows to your Mac OS X machine. I suggest using the shared partition or a USB flash drive.
  2. Launch Quicken Essential for Mac OS X.
  3. Click “Create a New Document”, modify the file name (with extension .quickendata), and click Save. Quick Essentials will open with an initial blank setup.
  4. Go to menu “File->Import…” option.
  5. Select an exported .QXF file and click Open. Your data will be imported.
    • Note: If you import data from more than a year ago, you might be concern that the import failed when Quicken Essential shows you an empty register. This is because almost all of the Quicken Essentials pages will filter on the “Last 12 Months” (look for the filter bar at the top). You will want to change that to “All Dates” in order to see entries older than one year.
    • To import another .QXF file, go to menu File->New…, type the new filename (without the .quickendata extension) into “Save As:”, click Save, and repeat the import steps above.
    • Note: Unfortunately, we can only import one .QXF into one Quicken Essentials file. If you attempt to import a second .QXF file, you will get a error message saying that it is not allowed.

Besides selecting “All Dates” to view older entries, I noticed that the accounts listing is sorted alphabetically and there is no way to override that. I had to rename the accounts to re-order the list to match my needs; for example, changing “Jan” to “01 Jan” and “Apr” to “04 Apr” so January will come before April instead of after. I also hid some columns that I didn’t use. Unfortunately, I had to make these changes for each account because there was no way to change things globally.

No Comments

Customize My Own Mac OS X 10.8 Mountain Leopard

Mac OS X 2 Comments

I recently got a new macbook with Mac OS X 10.7 Lion. I did not like some of the useability changes made (more on that below), but thankfully did not experience the slowdown, crashes, or bad battery life that others had reported. I upgraded to Mac OS X 10.8 Mountain Lion in the hope that those useability changes would be improved. My hopes were dashed, but I was determined to create an unholy combination of the old and the new which I will call Mac OS X Mountain Leopard. Grrr… meow.

Here are the tweaks that I made:

  1. Disable natural scrolling. The reverse scroll seems so unnatural to me. Because I will be switching between Mac OS X and Windows often, adapting to natural scrolling would also cause confusion on Windows.
    • To disable natural scrolling, go to System Preferences->Trackpad->Scroll & Zoom, and uncheck the “Scroll direction: natural” box.
  2. Enable tap-click, two-finger-tap-2nd-click and two-finger-tap-drag in addition to the new three-finger-drag. My fingers are trained to do a two-finger tap or drag so I wanted to enable it and use it alternatively with the three-finger-drag. The three-finger drag is still useful for rearranging icons on the dock; whereas, the two-finger-tap-drag would launch the application instead. I was expecting a three-finger scroll inside an application window in addition to the two-finger scroll, but it wasn’t supported.
    • To enable tap-click and two-finger-tap-2nd-click, go to System Preferences->Trackpad->Point & Click, check the “Tap to click” and “Secondary click” with “Click or tap with two fingers” boxes.
    • To enable two-finger-tap-drag, go to System Preferences->Accessibility->Mouse & Trackpad->Trackpad Options…, check the “Enable dragging” box and leave the default “without Drag Lock” selection.
  3. Globally disable application restore. This feature was very confusing and a bit annoying. For example, when I would run the TextEdit application to open up a new document, I would get 3 or 4 of the previously opened documents also and would have to hunt for the new document. I’m sure that others may find this useful but it wasn’t for me.
    • To disable application restore, go to System Preferences->General and check the “Close windows when quitting an application” box.
    • On OS X Lion, this option is labeled “Restore windows when quitting and re-opening apps” and you would uncheck it to disable the application restore.
  4. Change Gatekeeper to allow installation of programs from anywhere, not just only from the Mac App Store. I ran into this issue when attempting to install GNU Emacs, which I had to download separately because it is not in the App Store.
    • To allow installation from anywhere, go to System Preferences->Security & Privacy and select the “Anywhere” option under the “Allow applications downloaded from:” section.
  5. Disable notifications from programs like gfxCardStatus or Game Center. I’m okay with the Notification Center but too many non-critical notifications can train me to ignore all notifications (like ignoring the boy who cried wolf too many times).
    • To disable specific notifications, go to System Preferences->Notifications, select the application, and then uncheck any or all three options: “Show in Notification Center:”, “Badge app icon”, and “Play sound when receiving notifications”.
    • FYI, the “Badge app icon” is a red circle with a number inside that appears on the top-right of the application icon in the dock . The best example is the Mail program showing the number of unread emails.
    • There does not seem to be any option to only display the banner (which appears in the upper-right of the screen briefly and then disappears) without leaving at least the last notification message in the Notifcation Center.
  6. Disable automatic system updates during sleep. I don’t trust automatic updates and want to be asked if I wish to install them or not.
    • To disable automatic updates, go to System Preferences->Software Update and uncheck the “Install system data files and security updates” box.
  7. Turn on indicator lights on the dock to show that an application is running. This was checked already on my macbook (maybe because I upgraded from Snow Leopard and it persisted that setting).
    • To enable indicator lights on the dock, go to System Preferences->Dock and check the “Show indicator lights for open applications” box.
  8. Turn off Auto Correct. I usually make sure to disable automatic correction in programs like Outlook, Mail, and Word because most of the time, the corrections are wrong. I hated having my technical words replaced by common words because the dictionary used didn’t have those words, or having an acronym re-capitalized. On Mac OS X, I noticed that disabling Auto Correct in the applicatons’ Preferences did not stop all auto corrections from occurring. It turns out I have to disable it at the system level also.
    • To disable Auto Correct, go to System Preferences->Language & Text->Text and uncheck the “Use symbol and text substition” and/or “Correct spelling automatically” boxes.
    • I do uncheck the “Use symbol and text substitution” box because when I type a), b), and c), it is annoying when the c) ends up as a copyright symbol.
  9. Make scrollbars visible all the time. Hiding the scroll bars was a bad idea for two reasons. One, I can’t see the vertical scroll bar until I do a two-finger scroll. Hovering over the location of the vertical scroll bar does not show it; but strangely, doing the same for the horizontal scroll bar will show it. Two, the horizontal scroll bar appears, overlaps an item, and prevents selection of that item. For example, when attempting to move a file that is in the last display line of the Finder’s list mode, the horizontal bar will appear and prevent the selection of that file.
    • To make the scrollbars visible all the time, go to System Preferences->General and select the “Always” option for “Show scroll bars:”.
  10. Show Finder status bar. I like the Finder’s bottom status bar because it provides useful info at a glance.
    • To show the Finder status bar, go to the Finder’s View menu and click the “Show Status Bar” option.
  11. Make hard drives visible in Finder’s left-hand navigation pane. I think the reasoning behind hiding the hard drives is to force the usage of the favorites folder to access files. Unfortunately, I organize my files differently than Apple imagines I would, so I do need a way to quickly view the root folder of my hard drive.
    • To make the hard drives visible in Finder, go to Finder’s Preferences menu, Sidebar tab, and check the “Hard disks” box under DEVICES.
  12. Make the ~/Library folder permanently visible in the Finder. I could use Finder’s “Go->Go to folder” menu and input “~/Library”, but that’s slower than just clicking on the Library folder.
    • To make the ~/Library folder permanently visible, launch the Terminal application and run the following command:
      sudo chflags nohidden ~/Library

    Note: If you use Disk Utility’s Repair Permissions function, it will re-hide the ~/Library folder and you would need to do the above again.

The information above was mostly derived from:

2 Comments

« Previous Entries