5

If I have an existing user user with an existing home directory /home/user, what is the proper way to move his home directory a new home partition?

Simply copying the directory with cp does not preserve owner and timestamps (unless I use the appropriate cp options). Would cp be enough? And what options should be used to make sure everything is copied correctly?

3
1

I use cp -vfa, but the rsync -vaH (mentioned by @Kusalananda in a comment) would also work. In the case of latter, don't forget that all directories should end with / (i.e. /home/gradient will be not okay, /home/gradient/ yes).

Once in a life we all should really read the ls, cp, rm, bash and rsync manual pages, they can really a lot.


If the target directory is on the same partition, a simple mv -vf would be also ok.

Don't forget to update the home directory entry belonging to the user in /etc/passwd.

1
  • Don't forget pax -r -w -l.
    – JdeBP
    Aug 20 '17 at 18:28
0

These days the mv command will copy across partitions and delete the original. I'm not sure how it will cope if interrupted and restarted, which may be an issue for large home directories.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.