Home directory for Users and Groups, not Virtual Hosts, where is it defined?

Operating system: Ubuntu
OS version: 20.04

In Webmin, when I create a user under Users and Groups, there’s a selection for Home Directory labeled “Automatic.” This, by default, places the user’s home directory in /home/<user>.

I am also aware that there is a /home/virtualhost.com/homes/<users>/ path for those times when you add a user to a virtual host.

Question: I want to move the default Users and Groups home folder creation to a different drive so it’s not on the same physical drive as the rest of the OS. Short of creating a symlink to redirect /home to a new location, where is the “Automatic” creation of the home folder defined?

Or, do I need to just change the user’s home folder to the new location and let Webmin copy the files?

cat /etc/passwd

saslauth:x:986:76:Saslauthd user:/run/saslauthd:/sbin/nologin
bacula:x:133:133:Bacula Backup System:/var/spool/bacula:/sbin/nologin
test:x:1001:1002:root:/home/test:/bin/bash
test2:x:1002:1003:root:/home/test2:/bin/bash
test3:x:1003:1004:root:/home/chroot/161165693315038/./home/test3:/sbin/jk_chrootsh
[root@www virtual-server]#

Dimitar

Hi,

where is the “Automatic” creation of the home folder defined?

It’s configurable on Users and Groups module configuration page (a cog icon on the top left of the module’s index page).

If you have your home files somewhere else, don’t change any configuration, simply use the following command to mount bind directories:

mount --bind /home /mnt/hdd1/home

… and enjoy your ride.

1 Like

You want it to be /home. You’ll have to do some extra work if you change the path instead of just mounting your new partition on /home.

So, install the new disk, mount it on a temporary name (e.g. /home2), copy everything from /home to /home2, then unmount /home2 and remount it as /home. For safety/discoverability later, you may want to rename the original /home dir to something like /old/home or something.

You should not be running any services while doing this, as any files written by web apps or mail server or whatever could end up in an inconsistent state. If it’s a lot of data and you don’t want to be offline for the hours it takes to copy, you can make an initial copy with everything running, shut everything down, do a final rsync from /home to /home2, then do the remount dance. An rsync of an already almost perfect copy will generally be quite fast (a few minutes probably).

Edit: Bind mounting is optional and unnecessary if you do what I’ve recommended.

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.