Moving a user’s home or CloudStorage wants a lot of space

03 Aug 2023

Why would we do this

We have several customers that use various cloud sync/storage options as another location for archived data.  Once the projects are complete and we mark them read-only on the Xsan, they can be written to tape and sent to “the cloud” for further redundancy.  This means we are almost constantly sending data up to these providers.  

In macOS Monterey (and later back ported to Catalina), Apple introduced a new Apple supported way for these providers to offer this sync capability.  It requires that the synced data go to each user’s ~/Library/CloudStorage folder.  This means it is stored within each user’s home folder and can’t be anywhere else. For home users, this works great with small amounts of data to and from our internal SSDs/flash storage.

However, we want to sync a lot more data than a standard 1TB or even 4TB internal drive can handle.  Also we have plenty of spinning disk space available in the form of external drives.  At first we thought we could put a user home on the Xsan, but that is not supported by macOS.  Now we want to move a user’s home to an external drive (or RAID) to take advantage of the larger volume sizes.

How do we do this

Assuming the user’s account already exists on the Mac, there are 2 big parts to this change.  First, move the data to the external drive.  Secondly, tell the user account to use the new location.

For the first step, log in as an administrator on the Mac, that is not the account to be moved.  Make sure the account to be moved is not logged in.  Then we need to give Terminal Full Disk Access to work with another user’s data.  Open System Settings -> Privacy & Security -> Full Disk Access.  If Terminal is in the list, make sure the slider shows blue (On).  If it is not in the list, click the plus sign, authenticate as an admin, navigate to /Applications/Utilties (Shift-Command-U), select Terminal, and click Open.  If you are prompted to “Quit & Reopen”, do so.

If it isn’t open, launch Terminal.  Also make sure the external drive is connected and mounted on the Mac.  Now we can make a directory to hold the user’s home folder.  At the command prompt enter sudo mkdir /Volumes/<external drive name>/Homes.  Replace <external drive name> with the volume name of the external drive.  This command will prompt for your admin password to run.  Enter it at the prompt.  You won’t see any characters,  just type and hit enter.  I call the new folder Homes to keep it obviously distinct from the standard /Users/ directory.  

Now we can copy the user’s existing home folder to the new location with sudo rsync -a /Users/<username> /Volumes/<external drive name>/Homes/. Again replace the username and external drive name areas.  This will copy all the directories and files from the existing home folder to the new location.  Once we have confirmed everything is working we will delete the old home folder.

Now that the data is in the new location, we can move to part 2, telling the account to look at the new location.  Open System Settings, if needed, and go to Users & Groups.  Right click (or control-click) on the account we are moving and choose Advanced Options.  Authenticate as the admin again.  Find the section labeled “Home directory”.  Click the Choose… button.  In the folder picker that opens, navigate to the eternal drive, into Homes, and highlight the user’s directory.  Click Open.  Confirm that the path listed next to Home directory is now something like /Volumes/externaldrive/Homes/username.  Click Ok to close the advanced options.  

Now you can log out of the admin account and log in as the user we just moved.  Once signed in as them navigate to something in their home folder (like Documents or Music).   Hold down the command key and click the title of the Finder window.  A pop-up should show you the path to the folder.  Make sure it shows the Computer, Volumes, Homes, username, and then the folder you are in.  This means the account is using the new folder.

Now at some point it would be good to remove the old home to prevent confusion.  As the user or an admin, you can run rm -r /Users/<username> to delete the old home.  If you are an admin, add sudo to the start of that command.

Caveats

A couple of additional things to keep in mind.  

If the external drive is ever not mounted when the user logs in the system will create a new, empty home folder at /Volumes/<external drive name>/Homes/<username>.  This will cause the user to think everything is missing.  Even worse, if you then mount the external drive, it will get mounted at /Volumes/<external drive name> 1.  This means that the user still won’t see their data.  To fix this, first eject the drive (to be safe), then as the admin run sudo rm -r /Volumes/<external drive name>.  Now re-connect the drive and make sure it mounts to the proper path.  Then the user can log in and things should be ok.

Another option, if the user doesn’t exist yet, you can specify where the home folder will be during account creation.  Various account creation tools can specify the path.  For example, sysadminctl has the option -home <full path to home>.  If you are using dscl you can specify the NFSHomeDirectory attribute.

Another thing to look out for is that macOS can ignore ownership and permissions on external volumes.  To check this, Get Info (command-I) on the volume, expand the Sharing and Permissions area, and make sure “Ignore ownership on this volume” is NOT checked.

 

Share

Eric Hemmeter