6

I have a seemingly broken MacBook Air that doesn't boot, but I can get into the recovery console. If I try to reinstall Mac OSX on the main disk (Macintosh HD aka /dev/disk1s2), the installer complains that there isn't enough disk space available.

So I opened up a terminal and tried to manually delete unnecessary files.

Using rm -rf, it looks like everything works, except that the disk space isn't freed. On reboot, the files are there again as if nothing happened.

  • Folders I 'delete' with rm -rf seem to vanish from the directory listinng (ls)
  • df -h never updates the amount of free space after rm
  • Rebooting into recovery console shows the deleted files are there again

And when I look at the disk in Disk Utility in the recovery console, it tells me that there are 4 GB of free space, but 0 KB deletable.

How can I delete the missing files without reformatting the whole HD and losing all data?

And why doesn't rm -rf work?

Using rm without -f (e.g. # rm -r /Volumes/Macintosh\ HD/Developer) first asks me to confirm each file deletion, then errors with

no such file or directory.

Which I would assume is a permissions issue. But I'm root (#) in the terminal and the files are owned by root/wheel. As suggested, I tried to remount with write permissions (mount -uw). This did not give me an error message, but the behavior is still the same (files reappear on reboot).

6
  • 3
    What exactly are you trying to delete with rm -rf?
    – nohillside
    Commented Apr 1, 2018 at 13:56
  • Unnecessary stuff. There's an outdated version of the developer tools installed in (/Volumes/Macintosh HD/Developer), old iphone backups etc.
    – Mala
    Commented Apr 1, 2018 at 14:05
  • 2
    Please add the specific commands (including path names) you are using. And the output you get when you run it without the -f.
    – nohillside
    Commented Apr 1, 2018 at 14:14
  • Have you tried Disk Utility and repairing errors on the volume?
    – jornane
    Commented Apr 2, 2018 at 9:33
  • 1
    Please add the output of diskutil list, df and ls -la /Volumes/Macintosh\ HD/ entered in Terminal.app to your question! And add your system version!
    – klanomath
    Commented Apr 2, 2018 at 11:31

5 Answers 5

6

Using -f hides errors. Try running the command without the f option: rm -r ….

Without the actual error message, I can guess what the problem is: you're trying to delete files by providing a path you expect to the files but do not match the actual path.

When you're booted into Recovery, the Recovery environment is mounted at /, so paths like /Users are actually pointing to the Recovery HD. For example, instead of

rm -rf /Users/…

you should prepend to your paths the correct path to the volume

rm -rf /Volumes/Macintosh\ HD/Users/…

where Macintosh HD is your startup disk volume. Try ls /Volumes to see what's available.

15
  • 2
    I'll add a more overall - let's re-examine why the OP is thinking rm is the solution. Read mail isn't usually the hammer to fix an install and read mail, really fast certainly isn't - especially when in recovery boot.
    – bmike
    Commented Apr 1, 2018 at 13:28
  • 3
    @BoristheSpider But then the files that are not unnecessary will be lost.
    – Mala
    Commented Apr 1, 2018 at 14:06
  • 2
    @Mala Are you actually able to confirm that the files are being deleted in the first place? I suspect it's nothing to do with rebooting. rm won't complain if it doesn't delete anything because you've used -f.
    – grg
    Commented Apr 1, 2018 at 14:12
  • 1
    @grgarside Yes, the files are gone until reboot. E.g. I cannot cd into (.../Developer) anymore after the rm. I found some rare references in apple support forums of similar behavior. Very weird.
    – Mala
    Commented Apr 1, 2018 at 14:14
  • 1
    Mount the NAS and do a backup - I don’t really see the problem. Commented Apr 1, 2018 at 23:55
6

When you boot in single user mode, the disk is mounted read-only. As others have pointed out, running rm with -f can hide errors.

Prior to running rm, try setting the mount point to read write using

mount -uw /
1
  • 1
    Unfortunately, this didn't work either. More exactly, it accepted the command (both mount -uw / and mount -uw /Volumes/Macintosh\ HD) without error, but it did not delete anything afterwards. All files return after reboot, and the 'empty' diskspace (df -h) never changes, even if the 'deleted' files disappear from ls.
    – Mala
    Commented Apr 2, 2018 at 7:00
5

Normally two questions is hard to answer, but in this case - it's easy.

  1. Don't rm -rf when you want to reinstall - many of the images you mount in recovery are read-only and almost everyone is going to be confused between deleting parts of the system that runs recovery versus deleting files from the normal running system.
  2. All installs are now archive and install - so if you have a failed install - you can either try the archive install again or you need to erase the volume entirely (with disk utility and not with a file removal tool like rm) throwing away the container and then run a clean install.

So to take that general advice and try and fit your specific instance:

  1. Do you have your data backed up? If not - please boot to recovery HD and connect a drive and make a backup. That frees you from mistakes, misunderstandings and you'll need that backup drive next week once you have a working computer. You can't get your time back and you can't get your files back without a backup.
  2. The one true way to erase and install is here: https://support.apple.com/kb/PH25649?locale=en_US

If you want to fix the archive install - hit me up in the comments or chat room or a follow on question. Like George has answered - you'll need to find a specific error for us to help more. (As will I if you choose to pick apart why your archive and reinstall failed and led you to think you need to rm in the first place. No judgement, just that's usually not the best way forward so let's get you there sooner rather than later.

5

I ran into a similar issue today, where my macbook pro couldn't boot because the HDD volume couldn't be mounted. The DiskUtil couldn't fix the issue for me.

Then I found solution 5 on this page to be helpful: https://iboysoft.com/mac-data-recovery/file-system-check-exit-code-is-8.html

However the fsck –fy command failed on creating a B-tree, due to lack of available disk space. I tried removing files, but everything was read only and mounting in r/w mode was obviously not possible.

That is when I found the comment on this answer here: https://apple.stackexchange.com/a/14485/367209

Simply run this command and you'll be able to remove files. mount -o update /

I reran fsck –fy after that successfully and could boot my mac again.

1

Get your hands on a cheap USB hard drive. Plug it in and install macOS on that. Set up any old user, and from there, you can easily see and access and delete any files you want on the internal drive. Then go back into recovery and reinstall the OS on the boot drive.

THEN once that works, erase the external drive and use it as a Time Machine backup. Then think about upgrading the internal SSD in your MacBook Air because clearly the tiny amount of storage space those computers tend to come with, isn't not enough for you (or most people).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .