Configuring home directory on client nodes

My cluster has dedicated nodes that take a role of a client. Users can connect to these clients with their own private keys and they have their own home directory.
Until now, the home directory was the default /home/username. Lately, Ambari has been warning me that client nodes are running out of disk.
I have added one volume to the client node and configured a new home for the users. How I am attaching volume to an instance is described here.

The new volume is mounted to folder /user. I am trying to imitate Hadoop’s filesystem. Since some users already exist and have their home directories under /home, I have to take care of them first.


Create /user folder

Create the folder where users’ home will reside

sudo mkdir /user

Move existing user

Moving existing user to a new home directory:

sudo usermod -m -d /user/test1 test1

If the new directory does not exist yet, usermod is going to create it.

After the command is finished, the directory /home/test1 is not available anymore and folder /user/test1 has become the new home directory for user1.

Explaining options*:

-m     move contents of the home directory to the new location (use only with -d)
-d       new home directory for the user account

*-taken from usermod man.

Now we can check some details of the user with the following command:

finger test1

The following output is given:

Login: test1 Name:
Directory: /user/test1 Shell: /bin/bash
Never logged in.
No mail.
No Plan.

If you run the usermod command on a user that is logged in, usermod is going to report an error:

usermod: user user2 is currently used by process 13995

Running ps aux on this process

ps aux | grep 13995

Reveals that the user user2 is logged in:

user2    13995  0.0  0.0 103568  2468 ?        S    11:59   0:00 sshd: user2@pts/2


Changing configuration for new users

Opening adduser.conf file

sudo vi /etc/adduser.conf

and changing (first uncommenting if needed!) the value for parameter DHOME does the trick:


Upon creation of a new user

sudo adduser newuser

this new user now has a new home directory on the attached volume. When logging in as newuser and running command pwd, the output is


The existing users’ directories have now been moved to /user which is a dedicated volume for user files. The configuration file /etc/adduser.conf has been altered so that the new users are automatically defined as having home directory under /user.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s