4

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).

  • 3
    What exactly are you trying to delete with rm -rf? – nohillside Apr 1 '18 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 Apr 1 '18 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 Apr 1 '18 at 14:14
  • Have you tried Disk Utility and repairing errors on the volume? – jornane Apr 2 '18 at 9:33
  • @jornane Yes. No errors detected. Same with the full RAM test. – Mala Apr 2 '18 at 10:02
5

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.

  • 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 Apr 1 '18 at 13:28
  • Surely the OP would be better off firing up Disk Utility from the installer and giving the disk a nice clean format? – Boris the Spider Apr 1 '18 at 13:52
  • 2
    @BoristheSpider But then the files that are not unnecessary will be lost. – Mala Apr 1 '18 at 14:06
  • 1
    @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 Apr 1 '18 at 14:12
  • 1
    Mount the NAS and do a backup - I don’t really see the problem. – Boris the Spider Apr 1 '18 at 23:55
4

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 /
  • 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 Apr 2 '18 at 7:00
3

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.

0

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 .