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) Cheers, Soo-Hyun
This is not a CentOs issue or problem. This plain Jane UNIX. $HOME can be anything you want or need it to be. Copy the user's home directory to where you want and make the appropriate changes in the passwd file or automount maps. -- Thanks, Gene Brandt SCSA 8625 Carriage Road River Ridge, LA 70123 home 504-737-4295 cell 504-452-3250 Family Web Page | My Web Page | LinkedIn | Facebook | Resumebucket On Mon, 2011-01-31 at 06:07 +0900, 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) > > Cheers, > Soo-Hyun > > _______________________________________________ > CentOS mailing list > CentOS at centos.org > http://lists.centos.org/mailman/listinfo/centos-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.centos.org/pipermail/centos/attachments/20110130/ce0de822/attachment-0002.html>
Hi,> This is not a CentOs issue or problem. This plain Jane UNIX. $HOME can > be anything you want or need it to be. Copy the user's home directory to > where you want and make the appropriate changes in the passwd file or > automount maps. >Well, yes and no. In case of Debian/Ubuntu, we need to modify apparmor settings (e.g., by changing "etc/apparmor.d/tunables/home" information) to get it right apart from just copying them and changing passwd file. I wondered if CentOS has such an issue when relocating $HOME directories. Cheers, Soo-Hyun
On Sun, Jan 30, 2011 at 11:07 PM, Soo-Hyun Choi <s.choi at terabit.org.uk> 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) > > Cheers, > Soo-Hyun > > _______________________________________________The easiest way would be to move (or copy) everything in /home to /export/home, and then remount /home on /export/home in your fstab. Before you remount it, you may want to rename it to say /oldhome or /home2 or something like that, and then if everything works fine then you simply delete it :) -- Kind Regards Rudi Ahlers SoftDux Website: http://www.SoftDux.com Technical Blog: http://Blog.SoftDux.com Office: 087 805 9573 Cell: 082 554 7532
On Mon, Jan 31, 2011 at 06:07:27AM +0900, 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)It depends on if /export is in the same file system as /home currently is. If the file systems are different, then make the new '/export' space. Then use a tar-to-tar to copy the old home to the new place. First, create the new directory situation. If the file systems are different mount /export (or whatever you have to do to create the new one) cd /export tar -cpf - /home | tar xpf - If it is the same file system, just do: mkdir /export (or whatever it takes to create the new one) mv /home /export/. (NOTE: Some versions of mv(1) (FreeBSD for example) will actually do a cp(1) for you if they are not in the same file system so you can cheat a little) Next you would have to modify each user's entry in the /etc/passwd file to be /export/home/userid rather than /home/userid you can use vipw(8) to insert the export/ string in between the first '/' and 'home' eg search for home and then insert 'export/' By the way, I'd suggest not using the name /export. It gets used in too many places to mean specific things and it could get confusing some time later. Pick some other name. ////jerry> > Cheers, > Soo-Hyun > > _______________________________________________ > CentOS mailing list > CentOS at centos.org > http://lists.centos.org/mailman/listinfo/centos
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/