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@centos.org http://lists.centos.org/mailman/listinfo/centos
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 Mon, Jan 31, 2011 at 06:58:36AM +0900, Soo-Hyun Choi wrote:
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.
Not that I'm aware. But you could always relocate the home directories and then create appropriate symlink(s).
For example, if you're relocating everyone, you can move the users' directories, then remove /home and create /home as a symlink to the new top-level home directory (/export/blah). Or, if your users will be in various different places, you can keep /home and create a symlink for each user (/home/user1 -> /export1/user1 ; /home/user2 -> /export3/user2).
There are probably many other ways to deal with this; AFAIK CentOS shouldn't have any difficulties with any of these situations.
--keith
On Sun, Jan 30, 2011 at 11:07 PM, Soo-Hyun Choi s.choi@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 :)
On Mon, Jan 31, 2011 at 12:18 AM, Rudi Ahlers Rudi@softdux.com wrote:
On Sun, Jan 30, 2011 at 11:07 PM, Soo-Hyun Choi s.choi@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 :)
This tends to break symlinks and hard-coded script locations. In particular, Samba and Apache make some assumptions about where home directories live that you might want to resolve if you enable homedir access for or public_html access for those tools.
--On Monday, January 31, 2011 12:55 AM -0500 Nico Kadel-Garcia nkadel@gmail.com wrote:
This tends to break symlinks and hard-coded script locations. In particular, Samba and Apache make some assumptions about where home directories live that you might want to resolve if you enable homedir access for or public_html access for those tools.
I'd be surprised if such well-written packages didn't simply use the value from /etc/passwd (acquired by the appropriate API, such as getpwent(3)). Remember also that Samba and Apache are written to be used on other than Linux, and other OS's might not keep their home directories in the same place.
As Tom H points out, the big issue is to set the selinux attributes of home directories not in the more common location.
On 01/31/11 12:34 AM, Kenneth Porter wrote:
--On Monday, January 31, 2011 12:55 AM -0500 Nico Kadel-Garcia nkadel@gmail.com wrote:
This tends to break symlinks and hard-coded script locations. In particular, Samba and Apache make some assumptions about where home directories live that you might want to resolve if you enable homedir access for or public_html access for those tools.
I'd be surprised if such well-written packages didn't simply use the value from /etc/passwd (acquired by the appropriate API, such as getpwent(3)). Remember also that Samba and Apache are written to be used on other than Linux, and other OS's might not keep their home directories in the same place.
apache itself has no clue and doesn't look at /etc/passwd or any other such. instead, /home/*/public_html is specified in the httpd.conf files, if that feature is enabled.
As Tom H points out, the big issue is to set the selinux attributes of home directories not in the more common location.
yeah,t hat will bite you
On 1/31/11 2:34 AM, Kenneth Porter wrote:
--On Monday, January 31, 2011 12:55 AM -0500 Nico Kadel-Garcia nkadel@gmail.com wrote:
This tends to break symlinks and hard-coded script locations. In particular, Samba and Apache make some assumptions about where home directories live that you might want to resolve if you enable homedir access for or public_html access for those tools.
I'd be surprised if such well-written packages didn't simply use the value from /etc/passwd (acquired by the appropriate API, such as getpwent(3)). Remember also that Samba and Apache are written to be used on other than Linux, and other OS's might not keep their home directories in the same place.
As Tom H points out, the big issue is to set the selinux attributes of home directories not in the more common location.
There's also a template somewhere for 'adduser' and equivalents to use as the default location when new users are added.
On Mon, Jan 31, 2011 at 12:18 AM, Rudi Ahlers Rudi@softdux.com wrote:
On Sun, Jan 30, 2011 at 11:07 PM, Soo-Hyun Choi s.choi@terabit.org.uk wrote:
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)
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 :)
If you're changing the root of /home to another mount point or directory, say "/export/home", you'll also have to use semanage to set its selinux context to "home_root_t", etc.
On Mon, Jan 31, 2011 at 8:22 AM, Tom H tomh0665@gmail.com wrote:
On Mon, Jan 31, 2011 at 12:18 AM, Rudi Ahlers Rudi@softdux.com wrote:
On Sun, Jan 30, 2011 at 11:07 PM, Soo-Hyun Choi s.choi@terabit.org.uk wrote:
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)
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 :)
If you're changing the root of /home to another mount point or directory, say "/export/home", you'll also have to use semanage to set its selinux context to "home_root_t", etc. _______________________________________________
I generally do this on systems without website stored in the home folders, since website files are normally stored in /var/www/html folder by default.
So, in this case you just need to update the httpd.conf file and tell it where the new home folder resides, IF you actually store website files in the /home folder.
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@centos.org http://lists.centos.org/mailman/listinfo/centos
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.
My personal preference is to use a subdirectory under /srv, say /srv/nfs/home. Keeps it out of the rest of the tree and pretty obvious what the files are for.
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. :-)
On 1/02/2011, at 7:19 AM, Paul Heinlein heinlein@madboa.com wrote:
Lots of good advice snipped
- Tell your users emphatically that they should use $HOME anywhere they're tempted to hardwire their home directory path into a script. :-)
Although this is still painful for any users who might have compiled their own software. (libraries, etc)
In some environments this can be common.
On 01/31/2011 01:32 PM, Cameron Kerr wrote:
On 1/02/2011, at 7:19 AM, Paul Heinleinheinlein@madboa.com wrote:
Lots of good advice snipped
- Tell your users emphatically that they should use $HOME anywhere they're tempted to hardwire their home directory path into a script. :-)
Although this is still painful for any users who might have compiled their own software. (libraries, etc)
In some environments this can be common.
That's why I have my home directory tree bind-mounted on /home . In /etc/fstab:
/var/home /home none bind 0 0
-----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