I have a corrupt .sparsebundle-file (a TimeMachine-backup file), that I would really like to fix, because there’s some files in there that I need.
I have tried using the Disk Utility app, but that didn’t work.
I also read that it should be possible to use the Terminal app to do this, but I’ve never used the Terminal app before, and I can’t find clear directions on how to do it…
What exactly should I do ?
The Terminal app is not a regular OSX-application, it is a command-line tool (a.k.a. console) to program and reprogram in the underlings of OSX (more or less like the DOS-prompt in Windows). So, as you are going out of the ‘OSX comfort zone’ when you start using the Terminal app, you should beware since messing things up there can really mess up OSX, and lead to having to re-install OSX.
Having that said, here’s a step-by-step guide to fixing your .sparsebundle-file using the Terminal app :
– first, connect your backup-drive (the one with the broken .sparsebundle-file on it) to your Mac, using a USB- or FireWire-cable
note : if the backup-drive is inside a Time Capsule, you’ll probably be best of getting the harddrive out of the Time Capsule (as outlined in this iFixit How-To) and then temporarily hooking it up to your Mac using something like this SATA-to-USB connector (or an old USB-harddrive-enclosure). Even though this breaks the warranty on your Time Capsule, it’s probably the best solution since the direct USB-connection is much faster than the usual network-over-ethernet-connection… (and bringing the Time Capsule in to an Apple-dealer for repair, will definitely mean losing all your data, since that is part of the regular repair-policy… and bringing it to a specialized data-recovery company will cost more than buying a new Time Capsule)
– then, open the Terminal app (which can be found in the Utilities folder that is in the Applications folder)
– in the window that opens, you will see the name of your Mac followed by a colon (:) and a tilde (~), so if the name of your Mac is MacBook Pro, you will see :
that is the “prompt”, when you see that, you can start typing the commands
note : some basic knowledge about working in the Terminal :
- each line of commands (a.k.a. “command line”) you type should be activated by pressing the ENTER-key
- as long as you do not see the prompt, the Terminal app is still busy executing your last command line
- the Terminal can not handle names with spaces in them, as spaces play an important roll in a command line ; they separate the subsequent commands given in one command line, e.g. if your backup-file’s name is MacBook Pro.sparsebundle, the Terminal app requires you to type is as MacBook\ Pro.sparsebundle or you can type the entire path to the file in quotation marks, like : “…/…/MacBook Pro.sparsebundle” (another option is to temporarily change the filename to one that has only letters and numbers in it)
- you don’t need to type the entire path to a file’s location in a command line manually, you can just drag-and-drop the file itself onto the command line and the entire path to the file will be automatically generated (a handy trick to prevent mis-typing)
- when typing your password in the Terminal, the cursor will not progress, so there will be no visual feedback whatsoever about what you’ve typed… so, type your passwords only with total focus on what you’re typing !
- ! BEWARE : be sure to double-check your typing when using the command line, as one mis-typed letter can generate an entirely different, unwanted outcome, screwing up your entire OSX installation !
- when working in Terminal app on a MacBook (Pro/Air), the advice is not to use an external keyboard, but the on-board keyboard
Now, when you see the prompt appearing, type this (followed by pressing the ENTER-key) :
admin$ sudo su –
Then, when you see the prompt appearing again, type this (followed by pressing ENTER) :
root# chflags -R nouchg [drag .sparsebundle-file here]
Then, at the next prompt, type this (and press ENTER) :
root# hdiutil attach -nomount -noverify -noautofsck [drag .sparsebundle-file here]
And at the next prompt, type this (and ENTER) :
root# tail -f /var/log/fsck_hfs.log
Look closely in this next file when you need to type what, and what the feedback should look like (kind of) :
- bold green text = this is the command line prompt
- bold black text = you should manually type exactly this text
- bold purple text = drag-and-drop your .sparsebundle-file here, and your sparse bundle’s path will be displayed
- black text = this text is generated by the Terminal, indicating what is busy and/or finished, and will be the same when your replicate this proces
- blue text = what is displayed here depends on your specific situation
- if problems are found, they will be listed in-between these lines, and it will also be indicated how it was fixed
note : as you can see from the time-stamps in the picture, the entire process will take quite a long time to complete (it took nearly 6 hours to repair this harddisk – a 500GB harddrive that was temporarily taken out of a Time Capsule and connected via USB2.0)
so, from there on it’s wait, wait, wait, do something entirely different, wait (again), get a good night’s sleep… and wake up in the morning with a repaired hard drive…
that should be it 😉