[CentOS] How to relocate $HOME directory
Paul Heinlein
heinlein at madboa.com
Mon Jan 31 18:19:13 UTC 2011
On Mon, 31 Jan 2011, Soo-Hyun Choi wrote:
> Hi there,
>
> As you know, $HOME is generally located at "/home/$username" by default.
>
> I would like to re-locate all users' $HOME directories to something
> like "/export/home/$username" without having a hassle/trouble.
>
> Initially, I've thought of just copying them to the new directory
> (under /export/home/xxx), but guessed it might trouble for the
> normal use (I'm pretty new to CentOS, although many experiences with
> Debian/Ubuntu).
>
> Is there any good tricks (or caveats) when moving users' home
> directory cleanly with CentOS? (I'm with CentOS 5.5 x86_64)
For the sake of argument, I'm going to assume that your current /home
and the new /export/home are on separate disks or partitions. That is,
you need to make a full copy of the existing directories rather than
just renaming them.
The following instructions should all be done as root.
1. rsync -av --delete /home/ /export/home/
2. Edit /etc/default/useradd so that HOME=/export/home
3. Run /usr/sbin/genhomedircon
4. Verify the change in
/etc/selinux/<<SELINUXTYPE>>/contexts/files/file_contexts.homedirs
5. Make sure that /export/home has the right contect:
semanage fcontext -a -t home_root_t /export/home
6. Run fixfiles to see if anything is amiss:
/sbin/fixfiles check /export/home
If something fixfile reports errors, use it to fix things:
/sbin/fixfiles restore /export/home
7. Disable user logins (including your own).
8. Update /etc/password with new $HOME definitions
9. Re-run rsync, if necessary, to catch last-minute changes:
rsync -av --delete /home/ /export/home/
10. Make the older /home/* directories unreadable.
11. Enable user logins
12. Tell your users emphatically that they should use $HOME anywhere
they're tempted to hardwire their home directory path into a
script. :-)
--
Paul Heinlein <> heinlein at madboa.com <> http://www.madboa.com/
More information about the CentOS
mailing list