How to remotely run Disk Repair (fsck) on OS X

The first thing you should do is make sure your remote control program is running properly at startup.  I’m using TeamViewer so I just added it to the main user’s startup items.  If you’re using VNC on your mac you probably don’t have to do anything special once it’s enabled.

The problem with Disk Repair (fsck) is that it needs to be run in single user mode, but you won’t have a GUI to work with on the remote side so the system needs to reboot, run fsck automatically, then reboot back to your normal GUI.

Here’s how:

Run or SSH into the remote system

sudo su –

Enter your password, then issue these commands:

nvram boot-args="-s"
vi /etc/bashrc

Add this block of text to the end of the file:

singleuser=`sysctl -n kern.singleuser`
if [[ $singleuser -eq 1 ]]; then
nvram boot-args=""
/sbin/fsck -fy
echo Not in single user mode

Save /etc/bashrc (:wq!), then


The remote system will reboot in single user mode, run fsck, then reboot back to normal mode.  Run Disk Verify again on the running system, and it should be problem-free if the fsck did it’s job!

You should now go back and edit /etc/bashrc and remove the block we added, so that if you need to boot into single user mode for some other reason in the future it will give you a prompt and not just run fsck and reboot on you.

1 reply
  1. Ace Twenty8
    Ace Twenty8 says:

    I ran into a situation that required me to run fsck remotely on a system running Mac OS 10.10, and unfortunately the neither the bashrc or profile are called as of Mac OS 10.10. In my case, system was not physically accessable, so I had not other choice but to get the code working. It seems that as of Mac OS 10.10 single user mode calls /bin/sh with options that disable the checking of bashrc/profile. I was able to get around the problem by downloading the bash source, and modifiying it such that /etc/profile is called no matter what arguments are specified when calling the shell. I then replaced /bin/sh on my system with the custom one I compiled. To modify the bash source you will need to work with the lines containing: maybe_execute_file (SYS_PROFILE, 1); in shell.c Once the custom /bin/sh is installed, then the above script works perfectly to run fsck remotely. I by no means recommend making these modifications to your own system.


Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *