There are few things better than the joy of getting a new machine and walking through Apple’s convenient Migration Assistant that comes up the first time you boot your new Mac. In most cases the Migration Assistant does a wonderful job of taking all the data and applications from your old Mac and moving them on to the new one so that your transition to the new machine is seamless.

As a tech, one of the occasional situations I encounter is a call letting me know that a customer attempted a migration and it failed citing I/O errors. What does that mean? “I/O” stands for “input/output” and the error quite literally means that it was not able to access that particular piece of data. The most common reason behind that is that the hard drive on the old machine has bad blocks; it’s a failing hard drive. Considering many people like to upgrade their machines when their old machine starts getting “slow,” and one common cause of slowness is a failing hard drive, this isn’t that uncommon of a situation. The question is, where does one go from here?

There are several other applications out there that can help you from here, but if you’re not afraid to get your hands dirty and you’re looking for something quick and efficient then I’d like to share my personal method with you. I’ll give the caveat that in an ideal world you’d be able to pull the hard drive from your computer, put it in an enclosure and keep a fan running on it to keep it cool during this transfer process. However, you’re also welcome to just leave the old machine in target disk mode and give this a go. Before proceeding please note that this is novice level and above. Those who are are less tech-savvy might not be up for the challenge.

To make this easy, first create a test account on your computer (just go through the Setup Assistant and name the account “Test”). Next you need to enable the root user. In Leopard, open Directory Utility (/Applications/Utilities/Directory Utility), go to the “Edit” menu and select “Enable Root User”. Simply give the root user a password. In Tiger, open the Netinfo Manager (/Applications/Utilities/Netinfo Manager), go to the “Security” menu and select “Enable Root User”.

Once the root user is enabled log out of the user account you’re in (Apple Menu-> Log Out). This will bring you to the login window. Select “Other” and type “root” for the username and enter the password you created. Once in the root account open up a Finder window and navigate to the Users folder on the root of the drive. Now, open up a second Finder window and navigate to the Users folder on that drive. Create a new folder in that Users folder that is the exact same name as the user folder on the old drive; this step is important!

Now, open Terminal (/Applications/Utilities/Terminal). Set up your screen so you can easily see the Terminal window and both Finder windows with the Users folders open. Type the following:

sudo ditto -V

Then drag the user folder from the old hard drive (the one with the shortname of the old user account) to the Terminal window. That should auto-populate its pathname. Now drag the user folder from the new hard drive (the one you just created with that same user shortname) to the Terminal window; its address should populate in the Terminal window. You should be left with a command that looks like this:

sudo ditto -V OldHD/Users/shortname /Users/shortname

Press “return,” enter your password when prompted, press “return” again and watch the magic. You’d suddenly see that all of the files from your older user account will begin transferring to the new folder that you created. Basically, the “ditto” command is what copies all of the files and the “-V” sets it to do that verbosely, which means it displays it’s work. This also means that it will specifically show you what files it receives I/O errors on. There are several other ways to use ditto but this is the way that I use it the most. It should also be mentioned that adding the “sudo” in front of the command is redundant in this situation. Sudo basically means “root”, and since you’re already the root user it’s unnecessary to add that in. I like to show it in the example so if you decide to try this from another user account you know to type in “sudo” first so that you don’t run into any permissions errors.

Go get a cup of coffee or take a nap and let ditto do it’s thing. If you haven’t seen it do anything in a while, but it hasn’t brought you a new prompt yet (which is the signal that it’s done) just let it go! If your hard drive really is failing then it might stall during the ditto but I promise that if you stay patient (sometimes for hours) it will continue. If it can’t get anything else it will bring you a new command prompt.

You’re not done yet! Once the folder has finished copying, you need to create the user account on your new machine. Open System Preferences and hit Accounts. Now hit the “+” sign on the bottom left of the Accounts pane. Enter the same exact shortname that is used for the folder in “Users”. Do not change that shortname. Ever. All of the permissions on the account are based on that shortname so even if you misspelled your name you’re stuck with it for now. When you press “ok” the system will automatically notice that there is already a folder in your user account and it will ask if you’d like to use that folder for this account, simply say “yes” and it will hook you up.

If you’re running Leopard, you’re done! Just log out of the root account and log into your migrated account. If you’re running Tiger, I’d recommend doing one last step. In Terminal, type in:

sudo chown -R shortname /Users/shortname

Replace “shortname” with the actual shortname of the account. Then hit “enter.” It will prompt you for the password of the account your logged in as (in this case “root”), enter that and hit “enter” again. This will give that user permission to access all of the files in its own account. Purists do tend to scoff at that last step since not every file in the account should have the same permissions, but most techs that I know agree it’s a better choice then ending up being locked out of your own files. It’s always recommended to run a permissions repair (/Applications/Utilities/Disk Utility) after this is all said and done.

Congratulations! You now know how to use the “ditto” command!