Thursday, July 23, 2015

Replacing the CD-ROM with a Hard Drive and Freeing up Space on the Boot Volume

Creating the Epic Color Crash Game

Step -1 Replacing the CD-ROM with a Hard Drive and Freeing up Space on the Boot Volume

I have a great MacBook Pro that I inherited from my son. He really wanted a SSD drive in the computer which at the time he bought it was a rare thing. So he got an SSD drive but that meant that it was a 120 gig drive. With all of my pictures and videos of biking I have always been battling the problem of having the drive run out of space and then OS X complains about the startup disk being out of space. I want to use this computer for my iOS development because it allows me to move around, and the room that is housing my Mac Mini is packed full of bike stuff that I am slowly selling on eBay and so it just feels crowded in there.

I hardly ever have used the CD-ROM drive in the computer so the logical solution is to replace the internal CD-ROM drive with a hard drive. There are some nice SSD drive options but I decided to go for the most space for the least amount of money. I selected the MCE OptiBay adaptor with a 2 terabyte drive.

The drive arrived on the day of my daughters wedding so the actual installation would have to wait a couple of days. The drive came pre assembled into the OptiBay adaptor, nice but even if it hadn't been pre installed putting it into the adaptor would be an easy task. Also included with the drive was a little screwdriver for installation. This is a great bonus that I was not expecting. The problem with opening the MacBook is the screws need a fine point screwdriver, which is not something that everyone has.
Drive and Screwdriver
The first step is to shut down the computer. I rarely actually turn the computer off, but before messing around inside the computer you want to make sure the computer is off not just sleeping. Then unscrew the 10 small screws on the bottom of the computer. The screwdriver MCE sent for this has two phillips screwdriver bits. Given the size of the screws it would seem like you would want to use the small bit. However the small bit is too small for these screws and will strip out the screws. The larger bit fits the screws nice and solidly and is perfect for removing the screws. As a basic rule you always use the largest screwdriver bit that will fit.
I like to keep the screws organized as I remove them to make it easy to pick the right screw when replacing them. Another trick that works real well is after removing the cover, stick the screws back into the holes and screw them in a couple of turns. It keeps the screws from getting lost and helps you remember which screw goes where.

Here is the first look inside the computer. The drive I am going to replace is in the top left corner.

First I remove the screws for the speaker unit that is over the drive, and just move it out of the way.
Then carefully remove the cables attached behind the drive. These pop of easily, but you don't want to damage the cable or connectors. I have seen tools used to pry these off but just pulling gently on the connecters works fine.
There are a few small screws holding the drive into the computer. Remove those screws and place them in organized piles, and gently pull the drive out of the computer. There are a couple of items that need to be moved from the old drive to the new adaptor, a cable, and a mounting tab.

There are two screws that attach the mounting tab to the drive.

Simply remove the tab from the CD-ROM drive and install it on the adaptor. Also pull the cable off the CD-ROM drive and install it on the adaptor.

Now everything goes back together. This really is simple, the adaptor with the new drive in it easily slips back into where the CD-ROM drive came out.
Replace the screws that secure the drive in place, and plug the cables back in. Make sure all the cables are securely attached back into their sockets. I found the cable closes to the fan, pictured here, the most difficult to connect. If any of these cables are not fully connected it obviously will not work when you turn the computer back on.
Here is a picture with everything back in place:

Replace the bottom cover and replace the screws. OK, that really was easy. Now lets get things set up.

Open up Disk Utility. The new hard drive shows up in the list of drives. First we need to format the drive so that OS X can use it. Select the drive, and then select the "Erase" option.

Select the format that you want to use. I like to use the "Mac OS Extended (Journaled)" format. Then give the drive a name. Use whatever name you want, but I like something without spaces as it makes it easier to type the name of the drive in Terminal. I chose EpicBiking.
I'm going to move all of my User files to the new hard drive which will leave the SSD drive with plenty of space of memory swapping and other system uses. When I install MySQL in the future it will also end up on the new drive. So, the first step is to create a directory called Users.
 Then I simply copy all of the folders in the Users folder on Macintosh HD to the Users folder on the new hard drive, and sit back and wait a few minutes.
Then open up Terminal. These next steps can be done with the graphical interface but I find it easier to just use Terminal for this.
Change to the root directory:

cd /

Now I'm going to rename the old Users directory to Users.old, but to do this I need Administrator rights. Type the command:

sudo mv /Users /Users.old

sudo makes it so the command is run as "super user", the administrator. mv command renames, or moves, the directory. You will be prompted for the password for the administrator. Which in my case is simply my password since my user account has administrator rights.
Next I am going to create a symbolic link to the Users folder on the new drive. The symbolic link simply makes it so the directory on the new drive shows up in the directory structure where the Users directory is expected to be, in the root of the directory structure.

sudo ln -s /Volumes/EpicBiking/Users /Users

As the super users we create a link using the ln command. -s tells it to create the link as a symbolic link, this is necessary for a few reasons. We are linking between two different physical drives and so a hard link would not work, besides it is rare that you actually want to create a hard link.

At this point I reboot the computer to make sure that all the open files in the old users directory are closed, and that everything is now using the new users directory.

After logging back in, once again go into Terminal.

Now the scary part, deleting all the old files. We copied the files from the old Users directory to the new directory so everything should be fine, but if you are paranoid this is where you would want to make sure there is an additional backup for your files. Once the next command is executed the original Users directory will be permanently gone.

sudo rm -rf /Users.old

This removes the old users directory and everything inside them. The f option says to force the command, or in other words just do it and don't ask any questions. sudo rm -rf can be a deadly command if used improperly.

OK, now my boot disk has plenty of room, my new drive has my users files and things are looking great.

Step 0 in the developing my game will be getting the development environment set up.

No comments:

Post a Comment

My Bicycle Store