MacOS-iCloud interop not working as expected

I have a one year old Mac Mini runnning MacOS Ventura 13.2.1. I also have an iCloud subscription, and an iPhone 13 running iOS 16.5.1(c). My Mini has 256 gb of SSD, and I've subscribed for 2 tb of storage in iCloud. The totality of my data is far in excess of 256 gb, but far less than 2 tb.


It's my understanding that MacOS and iCloud should be working together as follows: A copy of each and every one of my data files should be stored on iCloud at all times. A subset of my files should be stored locally on the Mini. MacOS should free up local storage space as needed by deleting local copies of files (but leaving them on iCloud, of course). Also, MacOS should try to ensure that the files stored locally are my more commonly accessed files, so they can be accessed more quickly.


This, however, does not seem to be happening. My local storage is all but maxed out, and I get occasional messages saying that I need to do something to free up space. (Again, it's my understanding that this should be happening automagically.). One particulary annoying manifestation of this is that my Photos app on my Mini is no longer being updated with new photos as I take them with my phone. The app says "Not enough local storage." (I do see these photos on iCloud, so the interop between the phone and iCloud seems to be working fine.)


I've looked everywhere that I can think of on both my MacOS and on iCloud, and I can't find a setting that I might need to adjust to get this working.


Any help? Is my understanding flawed? If not, can anyone point me to a specific setting where I can get this working?


Thanks.

Mac mini

Posted on Jul 28, 2023 9:36 AM

Reply
Question marked as Top-ranking reply

Posted on Jul 28, 2023 10:20 AM

pcrowley203 wrote:

MacOS should free up local storage space as needed by deleting local copies of files (but leaving them on iCloud, of course). Also, MacOS should try to ensure that the files stored locally are my more commonly accessed files, so they can be accessed more quickly.

No, that's not correct! iCloud Drive is a syncing service so that all of your devices that have the same Apple ID and iCloud Drive enabled will have the same files. Those files are mirrored on each device, i.e. Mac, iPhone, iPad, etc. iCloud Drive is not an off computer storage facility. Any change to files on the iCloud Drive, i.e. edits, additions and deletions are mirrored on the devices. Deletions I believe stay around for 30 days before they are removed from the cloud.


You can select "Optimize Mac Storage" in the System Settings so that an optimize v4rsion of files is stored on the Mini when space is needed (I believe it start when free space is around 20% but don't quote me on that).


So if you need additional space then get an external drive, either rotational or SSD to store files on and operate from.


Similar questions

14 replies
Question marked as Top-ranking reply

Jul 28, 2023 10:20 AM in response to pcrowley203

pcrowley203 wrote:

MacOS should free up local storage space as needed by deleting local copies of files (but leaving them on iCloud, of course). Also, MacOS should try to ensure that the files stored locally are my more commonly accessed files, so they can be accessed more quickly.

No, that's not correct! iCloud Drive is a syncing service so that all of your devices that have the same Apple ID and iCloud Drive enabled will have the same files. Those files are mirrored on each device, i.e. Mac, iPhone, iPad, etc. iCloud Drive is not an off computer storage facility. Any change to files on the iCloud Drive, i.e. edits, additions and deletions are mirrored on the devices. Deletions I believe stay around for 30 days before they are removed from the cloud.


You can select "Optimize Mac Storage" in the System Settings so that an optimize v4rsion of files is stored on the Mini when space is needed (I believe it start when free space is around 20% but don't quote me on that).


So if you need additional space then get an external drive, either rotational or SSD to store files on and operate from.


Jul 31, 2023 7:30 AM in response to pcrowley203

I've poked around a bit more by Google searching and using ChatGPT. I'm now of the following opinion. It seems that neither MacOS nor iCloud provide an automated way to do what I described in the root of this thread. However, it is possible to write a script that will do much as I described through judicious use of "brctl evict" and "brctl download".


I fed the following prompt to ChatGPT: "Please write an MacOS command-line script that will do the following: Go through the entirety of that portion of my local flesystem that syncs with iCloud. For each file, determine when it was last touched. Sort the files from most recently touched to least recently touched. On that sorted list, calculate a cumulative total of storage used. For all files for which that cumulative total is greater than a threshhold, use "brctl evict" to remove their local downloaded copies. For all files for which that cumulative total is less than a threshhold, use "brctl download" to download a local copy."


It gave me back this:


#!/bin/bash


# Set the threshold for cumulative storage usage (in bytes)

threshold=1000000000 # 1GB - Change this value as needed


# Create an array to hold file information

declare -a files_info=()


# Find all files in the iCloud-synced directory and get their last access time and size

while IFS= read -r -d '' file; do

last_touched=$(stat -f "%m" "$file")

size=$(stat -f "%z" "$file")

files_info+=("$last_touched $size $file")

done < <(find ~/Library/Mobile\ Documents/com~apple~CloudDocs/ -type f -print0)


# Sort the files based on the last access time (most recent first)

sorted_files=($(printf '%s\n' "${files_info[@]}" | sort -nr))


# Initialize cumulative storage usage

cumulative_size=0


# Loop through the sorted files and calculate cumulative storage usage

for file_info in "${sorted_files[@]}"; do

file_size=${file_info#* } # Extract file size

cumulative_size=$((cumulative_size + file_size))

file_path=${file_info##* } # Extract file path


# If cumulative storage usage exceeds the threshold, evict the local copy

if [[ $cumulative_size -gt $threshold ]]; then

brctl evict "$file_path"

else

# Download a local copy if the cumulative storage usage is below the threshold

brctl download "$file_path"

fi

done


We all know that ChatGPT sometimes halucinates so, before I unleashed that script, I'd want to check it over very carefully and test it on a test subset of the directory structure.


Also, that's a one-time script. Of course, one could run it on a schedule by adding it to the launchd plist file.

Jul 28, 2023 10:00 AM in response to pcrowley203

More: I know that it's possible, on my local machine, to select one or more files and/or folders and choose "Remove Download". That, I believe, removes the local copy of the object but leaves the copy on iCloud in place. Is it possible that the answer to my question is that I need to do that manually? That is, is it possible that my belief that this is supposed to happen automatically is wrong?

Jul 28, 2023 10:09 AM in response to dialabrain

So my last post elicited what seems to be an AI-generated message telling me that I need at least 20 gb to update MacOS, and sending me to Free up storage space on your Mac - Apple Support. From there, I chose Optimize storage space on your Mac - Apple Support. That tells me:


But when I follow that path through my settings, what I see does not look like that. There is no "Store in iCloud" option. I see instead:



Jul 28, 2023 10:30 AM in response to Old Toad

If I right click on a file, I sometimes see "Remove Download" or "Download Now", but never both for the same file at the same time. What then the difference between "Remove Download" and "Move to Trash", and why is there an option to "Download Now" for some files? Also, what is the meaning of the icon next to each file that sometimes looks like a cloud and sometimes looks like a cloud with an arrow emanating from it pointing downward?


Jul 28, 2023 10:47 AM in response to Old Toad

If I right click on a file, I sometimes see "Remove Download" or "Download Now", but never both for the same file at the same time. What then the difference between "Remove Download" and "Move to Trash", and why is there an option to "Download Now" for some files? Also, what is the meaning of the icon next to each file that sometimes looks like a cloud and sometimes looks like a cloud with an arrow emanating from it pointing downward?

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

MacOS-iCloud interop not working as expected

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.