Delete and replace User home folder

mtiffany
New Contributor III

Hi all! I used to have a process for moving a user onto a new MacBook or for clean installing a newer OS on their Mac which doesn't work anymore since High Sierra. Here's what I used to do.

  1. Login as local admin and tar the user's home folder (to preserve permissions data etc). I did this through CL as root: tar -cvzf user_name.tar.gz user_name
  2. Pull that tar'd file off the computer and do a clean install of the OS
  3. Create the user on the newly installed OS using the same pw and then login to that account to complete the account creation. Logout.
  4. Login as the local admin again and through CL run: rm -Rf User_name
  5. Now untar the tar'd up file in /Users

Doing this always allowed the transition for the users to be very easy because everything was there like before the update was done. BUT
Now in Mojave and Catalina even when root I get a permission denied when attempting to delete the user's home folder so I can put the tar'd home folder in its place. I've tried a chmod to 777 and still permission denied. I've also tried renaming the home folder and still permission denied.

Kinda stumped and don't want to just copy over users data if I can avoid it. Any thoughts?

5 REPLIES 5

bmarks
Contributor II

I think you may still be able to accomplish what you want, but via a different workflow:

  1. Log in as the local admin on the old Mac
  2. Open System Preferences, delete the user but make sure to select the option to retain it as a DMG
  3. Log in as the local admin on the new Mac, manually create a folder in /Users with the same short name. Don't create the user yet
  4. Mount the DMG you just created and copy the contents into the user folder you just created
  5. Once the copy is complete, open System Preferences and create a user with the same short name

OS X/macOS has supported this method for as long as I can remember. You don't have to worry about permissions, etc. because it handles all of that for you. When you create the user on the new Mac, it detects the home folder already there and uses it instead of creating a new empty home folder.

ilgin
New Contributor

hi, after Mac OS High Sierra, Apple change the process.

The easy way for me is:

  1. Log in as the local admin an new Mac and create the user
  2. activate the root user about Directory Utility
  3. login as root
  4. copy the user profile to the new Mac (drag an dop), with Thunderbolt or Firewire Cable/adapter whatever

NOW, very important: After copy the userprofile, change the user permissions with this command
first get the user-id: id -u username
now repair the permissions: sudo diskutil resetUserPermissions / user-id

teodle
Contributor

@ilgin I have a way that requires a lot fewer steps that you might want to try. I avoid enabling root through Directory Utility whenever possible. I'm always encountering Macs where some tech did this and forgot to disable it :). I also avoid Finder for copying a users home directory during migration. I just don't trust Finder. If I'm going computer to computer, I Thunderbolt Target mode the old computer and plug it into the new one. I rename the old hard drive "archive" to make it less confusing. Then I run the following commands (assuming the default shell is bash--after Catalina you'd need to sudo zsh instead)

sudo bash 
ditto  -V /Volumes/archive/Users/<username>/ /Users/<username>

Then, IF the config for old Mac>newMac is using local accounts, I create a new local acct on the new Mac with the exact same shortname. System Prefs will say "hey there's a home dir with the same name. would you like to use that home directory for this newly created account?" I say yes, please.

If the config is to use directory accounts, I don't do anything but give the Mac back to the user. When they first login, they'll get their home directory without permissions errors because ditto has copied ownership and permission setbits note-for-note. There are cases where we want to change the config from directory accounts to local accounts or vice-versa--in that case, I have to chown the home directory differently but that's another topic.

NOTE: The V option isn't necessary but it looks cool watching all the files scroll down the screen at an insane rate and if someone walks past your office it makes it look like you're doing something important. :). Sometimes I use lowercase v option. It just shows directories as they are copied.

ilgin
New Contributor

hi, after Mac OS High Sierra, Apple change the process.

The easy way for me is:

  1. Log in as the local admin an new Mac and create the user
  2. activate the root user about Directory Utility
  3. login as root
  4. copy the user profile to the new Mac (drag an dop), with Thunderbolt or Firewire Cable/adapter whatever

NOW, very important: After copy the userprofile, change the user permissions with this command
first get the user-id: id -u username
now repair the permissions: sudo diskutil resetUserPermissions / user-id

bmarks
Contributor II

I made a minor correction to my steps (the DMG contains the contents of the user folder, not the user folder,) but the method I described definitely still works even on Catalina. And, it means no root user, no Terminal commands, etc. because System Preferences does all the work for you. Here is Catalina's popup:

c4f0bf6ee26e43369e3cebf6126d8f82