-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 01/31/2011 01:19 PM, Paul Heinlein wrote:
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.
rsync -av --delete /home/ /export/home/
Edit /etc/default/useradd so that HOME=/export/home
Run /usr/sbin/genhomedircon
Verify the change in
/etc/selinux/<<SELINUXTYPE>>/contexts/files/file_contexts.homedirs
Make sure that /export/home has the right contect:
semanage fcontext -a -t home_root_t /export/home
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
Disable user logins (including your own).
Update /etc/password with new $HOME definitions
Re-run rsync, if necessary, to catch last-minute changes:
rsync -av --delete /home/ /export/home/
Make the older /home/* directories unreadable.
Enable user logins
Tell your users emphatically that they should use $HOME anywhere they're tempted to hardwire their home directory path into a script. :-)
If you are using RHEL6 or its equivalent:
# semanage fcontext -a -t home_root_t /export # semanage fcontext -a -e /home /export/home # restorecon -R -v /export/home # mkdir /export/home # mv /home/* /export/home/* # restorecon -R -v /export