Monday, May 5, 2025

Backup iPhone to External Drive

Running out of disk space for iPhone backups is a pain. It's very important to back up your iPhone. Sure, there are some options to do this, such as using iCloud. But for me, I have lots of space on my USB drives, and I'd like to use them for the job.

Finding a solution

On the current macOS (mine is Sequoia 15.3.2), there's no obvious way to change the iPhone backup location in Finder.


After searching online, I found a great solution: using a symbolic link to redirect the backup location to a different path on my external USB drive. It's a really smart trick.

Using Symbolic Links

The ln command is an old but handy command in Unix. I used it often back in university. Basically, it creates a symbolic link that points to another file or directory. It looks like a regular file but is actually a link.

Before doing anything, I needed to locate the original backup path on my Mac and ensure it didn’t contain other important files.

I quickly found the backup folder: ~/Library/Application Support/MobileSync/Backup. I opened Terminal and ran the following commands to check:

  1. MyMac-MBP13:MobileSync auser$ cd ~/Library/Application\ Support/MobileSync/
  2. MyMac-MBP13:MobileSync auser$ ls -a
  3. . .. .DS_Store Backup
  4. MyMac-MBP13:MobileSync auser$

To be safe, I decided to run a test first. As shown above, the only contents are the Backup folder and a hidden .DS_Store file (which can be ignored). So, I created a test directory backupTest in ~/Downloads/:

  1. MyMac-MBP13:MobileSync auser$ mkdir ~/Downloads/backupTest
  2. MyMac-MBP13:MobileSync auser$ ls -a -l ~/Downloads/
  3. total 316496
  4. ...
  5. drwxr-xr-x 2 auser staff 64 22 Apr 20:23 backupTest
  6. ...

Now I created a symbolic link named backupTest pointing to ~/Downloads/backupTest:

  1. MyMac-MBP13:MobileSync auser$ ln -s ~/Downloads/backupTest/ backupTest
  2. MyMac-MBP13:MobileSync auser$ ls -l
  3. total 0
  4. drwxr-xr-x 1 auser staff 26 21 Apr 20:27 Backup
  5. lrwxr-xr-x 1 auser staff 33 22 Apr 20:34 backupTest -> /Users/auser/Downloads/backupTest/

Great! The symbolic link backupTest now points to the test folder. I copied a known file (1.html) to this link and verified the result:

  1. MyMac-MBP13:MobileSync auser$ pwd
  2. /Users/auser/Library/Application Support/MobileSync
  3. MyMac-MBP13:MobileSync auser$ cp ~/Downloads/1.html backupTest
  4. MyMac-MBP13:MobileSync auser$ ls -l ~/Downloads/backupTest/
  5. total 8
  6. -rw-r--r--@ 1 auser staff 4024 22 Apr 20:43 1.html

The pwd command shows the current directory. The cp command copies the file, and the last ls confirms that it reached the redirected location.

Ready to Create the Real Link for iPhone Backup

Now I was ready to create the actual symbolic link for redirecting iPhone backups to my external USB drive. But first, I did two things:

  1. Backed up the existing Backup folder just in case.
  2. Deleted the old Backup directory (after making sure it's empty).

To remove the folder, I used this command:

  1. MyMac-MBP13:MobileSync auser$ rmdir Backup

Next, I identified the name of my external drive (MyUSBDrive) and the folder I wanted to use (iPhoneBackups).

I created the symbolic link and verified the link like this:

  1. MyMac-MBP13:MobileSync auser$ ln -s /Volumes/MyUSBDrive/iPhoneBackups/ Backup
  2. MyMac-MBP13:MobileSync auser$ ls -l
  3. total 0
  4. lrwxr-xr-x 1 auser staff 26 21 Apr 20:27 Backup -> /Volumes/Lachie160/iPhone/

Backup My iPhone

With everything set up, I connected my iPhone and USB drive to my Mac, opened Finder, and clicked the "Back Up Now" button. The backup process started smoothly.

In just 7 minutes, the backup was completed—without any "not enough disk space" error!

References

Other Blogs

Tuesday, April 22, 2025

Fix the "ls: Operation Not Permitted" Error on Mac

Recently, I encountered an issue when trying to execute the ls command in Terminal. This is a commonly used command to display the contents—files and directories—within a specific path. I need to know what's there before I do anything.

ls Error

  1. MyMac-MBP13:~ auser$ ls
  2. Applications Untitled.html
  3. Desktop downloadtemp
  4. Documents iCloud Drive (Archive)
  5. Downloads iCloud Drive (Archive) - 1
  6. Library iCloud Drive (Archive) - 2
  7. Movies test
  8. Music test.aiff
  9. Pictures test.html
  10. Programming tmp
  11. Public vc.swift
  12. Sites
  13. MyMac-MBP13:~ auser$ cd ~/Library/Application\ Support/MobileSync/
  14. MyMac-MBP13:MobileSync auser$ ls
  15. ls: .: Operation not permitted
  16. MyMac-MBP13:MobileSync auser$

After searching online, I discovered that this issue is due to a security enhancement introduced by Apple in the latest macOS: System Integrity Protection (SIP). By default, the Terminal app does not have the privilege of Full Disk Access. My current macOS version is Sequoia 15.3.2.

Change System Settings

According to a solution on the CleanMyMac blog titled “How to fix the ‘ls: .: operation not permitted’ error in Terminal,” I needed to adjust a setting in System Settings.

Initially, when I navigated to Privacy & Security, I couldn’t find the Full Disk Access option.

I wasn’t sure where the setting was—until I tried searching for “Full Disk.”

I turned it on.

The hidden setting was revealed. As expected, Terminal did not have Full Disk Access by default. I enabled it by entering my admin password. Now, the ls command works anywhere in the console, after re-opended.

  1. MyMac-MBP13:Application Support auser$ ls Mob*
  2. Backup
  3. MyMac-MBP13:Application Support auser$

Revert the Setting (Optional)

I believe Apple’s SIP is a great safety feature. After finishing my work in Terminal, I turned off Full Disk Access for the Terminal app to restore the default setting. I’m writing this blog post for future reference, in case I need to do similar work in Terminal again.

References

Other Blogs

Tuesday, March 11, 2025

Process Behind Spotlight

This topic is related to my previous blog on Time Machine Backup Issues

While working on my Mac’s Time Machine backup, I believe I disabled the Spotlight process. Spotlight was indexing my external Time Machine backup drive, which prevented me from resetting and cleaning up the drive.

After resolving my Time Machine backup issue, I realized that Spotlight was no longer working. I could no longer launch applications quickly using Command + Space. It was quite frustrating.

Checking Spotlight Settings

I went to System Settings -> Spotlight, but all the Spotlight settings appeared to be correct. Unfortunately, I couldn’t find an option there to restart Spotlight.

Restarting the Spotlight Process

Eventually, I figured out how to restart the process—the same process I had modified while troubleshooting my Time Machine backup issue. Here’s how you can do it:

Steps to Restart Spotlight

  1. Open Terminal from
    Applications->Utilities->Terminal
    . (Since Spotlight wasn’t working, I had to open it manually.)
  2. Run the following command:
    sudo mdutil -a -i on
    

The mdutil tool is used to manage Spotlight’s indexing process. I realized that I had previously disabled this service, and while I had restored my Time Machine backup, I had not re-enabled Spotlight indexing. That’s why Spotlight was not working.

After running this command, Spotlight started working within minutes. I could once again use Command + Space to launch my frequently used applications, such as Preview, Terminal, MacVim, and Safari.

Spotlight’s Background Process: mds_store

One interesting note about Spotlight’s indexing process is that it is managed by a background process called mds_store. However, when I checked Activity Monitor, I couldn’t find a process with that exact name. It’s possible that the process name has changed, but in any case, the steps above successfully restored Spotlight’s functionality.

If you have disabled this process, you will need to manually enable it using the steps above.

References

Thursday, March 6, 2025

Time Machine Backup Issue

Recently, I discovered that my Time Machine backup to an external hard drive was no longer working. I kept receiving failure messages, but they did not clearly explain the reason for the failure. Eventually, I realized that the available space on the drive was insufficient.

The quickest way to resolve this issue was to erase all backup data on the drive and start a fresh backup from scratch.

Erasing Time Machine Data

The best way to erase Time Machine data from the drive is by using the Disk Utility tool, which wipes out all data and reformats the drive as needed. However, when I attempted to erase the drive, I encountered another failure message. The system reported that the process "mds_store" was preventing the operation (holding the drive).

Following advice from a Google search, I tried terminating the process via Terminal. However, even after killing the process, I encountered the same failure message when attempting to erase the drive again.

Finally, I found a solution! I restarted my Mac in Safe Mode by holding the Shift key during startup. Since Safe Mode runs with minimal processes, I was able to successfully erase the data on the drive by using Disk Utility.

Adding the Drive Back to Time Machine

Once I had the drive ready, another issue appeared—the drive did not show up in the list of available backup drives, preventing me from adding it back to Time Machine.

I recalled receiving a warning message about "Forgetting this drive as a Time Machine backup" when I initially removed the external drive from the Time Machine settings. It seemed that macOS had stored a hidden setting to prevent this drive from being used as a Time Machine backup again. Unfortunately, I wasn’t sure where to change this setting.

Fortunately, I noticed that another partitioned drive appeared as an available Time Machine option. This drive contained important data, such as my picture libraries and historical records. When I selected this drive as a Time Machine backup, the backup process started immediately. However, I did not want to use this drive for backups, so I stopped the process.

One thing I observed was that a Backups.backupdb directory was created on this data drive. I decided to copy this directory to my intended backup drive. To my surprise, after doing this, the drive finally appeared in the Time Machine settings as an available backup option!

Time Machine Permissions

Another interesting discovery was related to permissions on my Time Machine drive.

When I erased and reformatted the drive, the permission settings were as shown in the following picture:

These permissions were the same as those of my data drive. However, when the drive was set up as a Time Machine backup, the permissions changed to the following:

I noticed that I could no longer modify these permissions or add an admin user. If I wanted to copy or erase any data on the drive, I had to enter my admin passwordeach time.

Conclusion

After a long struggle, I finally managed to get my Time Machine backup working again!