Fixing invalid node structure in a Mac OSX (w/o having to buy software!)

So it happened. The darned invalid node structure error when I verified my Macintosh disk in an attempt to repair it. This happens to many Mac users whose computers are playing up, and is a fairly serious error seeing as Disk Utility itself cannot repair the error. Neither can the fsck command. And for many users, one cannot boot up their computer again under this error, so if you have attempted to repair it in vain from booting up with the CD/fsck, you're pretty much screwed.


However - you don't need to erase your disk or buy Disk Warrior to fix it. I was in a perilous situation, where I had not backed up anything on my disk and, well, was not really in the mood to fork out money on Disk Warrior or a technician.

With the help of Simon at Devlab, the problem was solved!

Now, as I mentioned the fsck command won't work on its own. However, this command does;
fsck_hfs -rf /dev/diskxsy - where x and y are unique to your computer, but range between 0 and 4 usually

How do you go about doing this for the layman?
1. Restart your computer and immediately press and hold Command-S

2. You will soon go into the console command view.


3. Type in the fsck_hfs -rf /dev/diskxsy command

4. Remember to experiment with x and y, mine ended up being disk0s3. To find out for certain the x number, you have to boot up with your CD (insert your Mac OSX installation CD, reboot and press and hold C). Then, choose the first language option and go to Utilities and Disk Utility at the top menu options. Click on the disk you are having trouble with and click info. Disk identifier will give you your x number.

5. If you get something along these lines:
#: type name size identifier
0=apple_partition_scheme *26.6gb disk0s0
1=apple_partition_map 31.5kb disk0s1
2-apple_driver43 28.0kb disk0s2
3=apple_driver43 28.0kb disk0s3
4=apple_driver_ATA 28.0kb disk0s4
5=apple_driver_ATA 28.8kb disk0s5
6=apple_FWDriver 256.0kb disk0s6
7=apple_driver_IOkit 256.0kb disk0s7
8=apple_patches 256.0kb disk0s8
9=apple_hfs Tiger 26.4gb disk0s10
After running your command line I get this message;
Usage: fsck_hfs [-dfl m[mode]npgruy] special device
d= output debugging info
l= live fsck (lock down and test only)
m arg= octal mode used when creating lost+found directory
n= assume a no response
p= just fix normal inconsistencies
q= quick check returns clean dirty or failure
r= rebuild catalog btree
u= usage
y= assume a yes response
THEN, you need to keep experimenting with you x and y values

5. Once the computer accepts your command, it will start attempting to repair the disk. The command will look something like this:
magneto:~ root# fsck_hfs -rf /dev/disk1s3
** /dev/rdisk1s3
** Checking Journaled HFS Plus volume.
** Checking Extents Overflow file.
** Checking Catalog file.
** Rebuilding Catalog B-tree.
Invalid node structure
(4, 75586)
** Rechecking volume.
** Checking Journaled HFS Plus volume.
** Checking Extents Overflow file.
** Checking Catalog file.
... and so on.

6. Once it is finished, the command will either say:
The volume X was repaired successfully.
or Cannot repair drive after 3 attempts
If it is the prior, hell yes. Time to type in the command exit and reboot (or hard restart if this does not work).
If it is the latter, you can still be happy. Why? Well, some people who attempt this method usually rerun the command until that "Cannot repair drive after 3 attempts" disappears. However, myself and some other people exited the console and rebooted with the startup CD in in order to run Disk Utility. Once we did so, we were able to repair to drive whereas we could not before! Unbelievable! Once this was all over, we were able to start up our drive as per normal.


Please note that these steps will differ amongst computers, so follow them as best you can and improvise where necessary. But at least you will have an operational computer at the end of all this!

36 comments:

TechNazgul said...

Thanks! Lion borked my disk when going from 10.7.3 to 10.7.4 and it was totally unbootable. Booted into single user mode, and then ran the commands above and was able to repair. I did have to run them manually 2x before it repaired successfully, but it did work. Thanks!

rob said...

I am so glad that I came across this post. There is so much rubbish out there on how to fix this problem - but this information is first class. Thanks heaps!

Borfi Costa said...

Secret secrets? So Many Want to Know..We have Powerful Knowledge to Share With You!
We Unlocked The Secret Secrets About Life and The Internet Money System.
A POWERFUL BOOK ($77 Value) FREE Today at www.secretsecrets.biz

Rey Lagaras said...

I followed the steps above to solve the node structure error, however the repair attempt failed, when I reboot, I could no longer go to the single user mode in the terminal. pls help.

Jugal Thakkar said...

Thank you so much!!! Worked, had to do run it back to back twice like TechNazgul said

aishani said...

I have just put my mac in for repair. They told me repair will take up to 14 days, so I called on the 10th day to ask how the imac repairs was going. They said 7 more days. I really need my computer back, as I have a project to finish. Do they give a replacement, i have apple care.

chinaman4u said...

Thank you very much! Computer booted to startup screen with empty loading bar at bottom of screen, then shuts off; I did not have any other software to boot from.
(OSX 10.6.8)
Followed other pram reset and all the other things to no avail, thinking HDD failed.

Started it in single user mode ran fsck to get Invalid node...etc. It did specify a bad disk0s1(not sure of correct number).

Followed above instructions to get a long list of somethings(replace this with that.. etc), to finally get "Unable to repair after 3 attempts". Typed fsck again and i got the "repaired successfully" and rebooted mac successfully.

Thanks a bunches!!!

Matus said...

Thank you thank you thank you, this finally saved me - I was getting scared off crazy by some discussions online talking about faulty HDDs, since it happened to me 2 months after buying a new MB Pro. Tried pretty much everything, nothing worked, fsck couldn't finish the repair. The only temp solution I found was to go through single user mode everytime I booted up, and mounting the drive manually, which was a pain in the donkey. But your approach finally worked and I can again boot up normally.
Thanks a ton man, appreciated greatly!

redgilda said...

I have a question regarding this. Are the steps the same for 'invalid node structure' error on an external drive? I just need to find the correct Xy values, right?

Are there arguments againts using it on a 3TB external drive?

what happens if I make a mistake and this affects the main hard drive? It cannot 'break' it, right? It might just start to check/repair it?

Is there any way that messing up the command will 'break' the disk further? I guess you can never promise anything of course :) but some reassurance wouldnt hurt hehe

I used the 3TB for random back up and am pretty sure that some files on it are the only copy. so before I send it to WesternDigital for replacement - I'd like to be able to save what I can (right now the disk does not mount at all).

Thanks

Marta

Diego Schmunis said...

Man, you saved my life at 3 am! Thank you, thank you... THANK YOU!

zeddarn said...

You are the best. Imagine no backup, not anything. I had an application that I had spent time on it and was really worried about having no backup at all. I almost had an heart attack. But phew it is up again after running the command twice.
Just for the sake of others, to know x and y:
I run this command at /dev/
cd /dev/
ls
and it gave a list of files from disk0, to disk0s3, mine had a problem with disk0s2

THiNK1MEDiA said...

YOU ARE THE BEST! EVER! Did not have data backed up( 1st thing i am Doing now that i am back), The BROKE MONSTER got my pocket under siege, $100 was not in the budget for the "WARRIOR" to fend off this MAC ATTACK. 3 hours later of reading the same ol same ol ( like these people get a check from alsoft ) i find you , and this saved my @$$! and at least 250-400 dollars in software and extra drive, tech labor and time down. Drinks on me :)
CHEERS!

lwduk said...

Thank you sooooo much! I tip my hat to you as you have saved my skin. I too didn't have a back up of my machine and this has given me the opportunity to rectify this before I fix the hard disk.

Nick Gass said...

I keep getting this message after running fsck:

**Repairing volume.
**The volume Macintosh HD could not be repaired.
-sh-3.2#

Help, please.

Satish Reddy said...

Great, it worked..Thank you very much. Luckily I came here without having to spend too much time on other troubleshooting techniques.
If you want to see your diskxsy..Go to Disk Utility(Press Command-R during start-up)-->Select the bootup hard disk-->Click 'info' icon on top left corner-->'Disk identifier' field shows your diskxsy (Mine is disk0s2)

Timmu said...

It doesn´t seem to work on my 10.8

mikeg said...

THANK YOU!! Your tips and instructions worked out perfectly and saved me a ton of headaches.
How can I repay you :)

Hossam Hammady said...

Wow that saved me $99 of DiskWarrior!
I'm willing to donate! Quickly before I change my mind LOL :)

roryokane.com said...

You have another option instead of trying to guess the name of your disk "diskXsY". If you boot from the OS X installation disk or recovery partition (hold Option on boot) and open Utilities > Terminal, the "diskutil" command will be available. Run "diskutil list" to see the names of all drives - the first level of numbers is before the "s", and the numbers within each level goes after the "s" in the name.

Emmie said...

I have a 10.9 version, and I too got this:
**Repairing volume.
**The volume Macintosh HD could not be repaired.
-sh-3.2#

I have no idea what to do...

PHM said...

Thank you, I love you! :-)

vega gravity said...

Thank you for saving my Mac

ams patil said...

I would like to recommend your article .. you can also refer PLC Repairs

The Geeks said...

Thanks for review, it was excellent and very informative.
thank you :)

Nakiro said...

OMG... you saved my life.

Thank you very much!!

Kristy Griggs said...

You legend, at two in the morning I thought I'd list an important design project and my New machine was a pretty paper weight. you saved me and I could kiss you ;)

AJ said...

Thank You for providing the information

Luis Quero said...

I too got this **Repairing volume.
**The volume Macintosh HD could not be repaired.
-sh-3.2#

And now, when I try to boot the system, it takes me to the initial white page, with a loading bar but it shuts off when it is halfway loaded. What can I do?

John Nagtzaam said...

This worked. Thx.

Les new warriors en vadrouille said...

hi,
i was desperate, trying to find an answer, found thousands of stupid things..and then after 5hours of researchs with 10times almost crying i found your article and I repaired my mac !!!!!! I'm so GLAD! Thank you
Katia a little happy frenchy

BourBen said...

It says my HD could not be verified completely. What do I do?

Chong gi Lim said...

Same here - help!!

Todd Little said...

can't thank you enough!

college of computer said...

I'm really enjoying the design and layout of your website.
Qassim & QU

andrewolsenblog said...

I found the space after -rf was necessary: fsck_hfs -rf /dev/diskxsy
but then it found a million things, said it couldn't repair the disk, and now won't take the command again, nor others, even with cmd-s restarts :-(

velocirapta said...

Rebooted my computer earlier today and it decided to give me the grey screen of death for the first time in six years. Since been looking at ways to fix it, and could only get Single User Mode up, but weirdly when I exited it I could still get into normal OS X too (though it was buggy, a lot of broken apps and files not showing up).

About 12 hours later I had almost given up when I tried your code above three times, like you said - each time coming up with 'Invalid node structure' errors, two this time rather than one earlier in the day - and finally tried the install CD one last time...this time it wasn't automatically ejected, a lot of code came up and it looked and sounded like it was doing something! Finally it booted up Disk Utility, so I could wipe the HD (checked it was healthy too, had backed up important files on an external HD) and reinstalled 10.6.3. Also had 10.6.4 on another disc which didn't work - I think you have to use the same disc the computer originally came with. Fingers crossed but looks like I'm back in business! Thought my MacBook Pro had packed it in after 6 years...nope, keep on fighting!

Thanks for this easy to follow guide. I thought it looked too simple as I had tried a similar code earlier in the day but to no avail...this one works a treat, just stick with it. Best thing to do is use Disk Warrior to try and repair the disc (I didn't have a copy on me, but I know someone with an old, possible out of date copy) or wipe it like I did and reinstall everything! I know the HD may completely die in time but at least I can keep it going a little longer. Good luck everyone!

Post a Comment

Twitter Updates