LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-03-2012, 03:52 AM   #1
vjramana
Member
 
Registered: Sep 2009
Posts: 89

Rep: Reputation: 0
creating users in /mnt/data


I would like to setup a server (Centos) and this server has got two hard drives. In the first hard drive I wish to install Centos 5.7 and the second hard drive I plan to dedicate to home directories of the users.

Normally if I create home directory for users, it is like /home/john, /home/mark, /home/leena. But now I want to create home directories to be in /mnt/data/home/john, /mnt/data/home/mark and /mnt/data/home/leena where the second hard drive mounted at /mnt/data. Whenever these users login, they should be directed to /mnt/data/home/(users).

I have searched on the internet on how to setup this, but seems does not help me much.

It would be pleasure if I can get some help or guide to achieve this.

Thanks

Last edited by vjramana; 03-03-2012 at 03:53 AM.
 
Old 03-03-2012, 04:24 AM   #2
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

Hi vjramana,

Do you want to set that up for all users you will create going forward? Do you already have /mnt/data/home created? If answer to both the questions is "yes" then you can simply edit /etc/default/useradd script as follows:

Default useradd script
Code:
# useradd defaults file
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes
Modified useradd script
Code:
# useradd defaults file
GROUP=100
HOME=/mnt/data/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes

Last edited by T3RM1NVT0R; 03-03-2012 at 04:25 AM. Reason: forgot to put [code] tag
 
1 members found this post helpful.
Old 03-03-2012, 04:36 AM   #3
Doc CPU
Senior Member
 
Registered: Jun 2011
Location: Stuttgart, Germany
Distribution: Mint, Debian, Gentoo, Win 2k/XP
Posts: 1,099

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
Hi there,

Quote:
Originally Posted by vjramana View Post
I would like to setup a server (Centos) and this server has got two hard drives. In the first hard drive I wish to install Centos 5.7 and the second hard drive I plan to dedicate to home directories of the users.
separation of system/code and user data, always a good idea.

Quote:
Originally Posted by vjramana View Post
Normally if I create home directory for users, it is like /home/john, /home/mark, /home/leena. But now I want to create home directories to be in /mnt/data/home/john, /mnt/data/home/mark and /mnt/data/home/leena where the second hard drive mounted at /mnt/data. Whenever these users login, they should be directed to /mnt/data/home/(users).
I'd rather recommend you to keep the standard /home/* directories, and mount your second hard disk to /home instead of /mnt/data.
If you want to do that, copy all existing home directories first, for example /home/john to /mnt/data/john (while the second hard disk is mounted to /mnt/data). When you copied all existing profiles from /home, unmount the drive from /mnt/data an re-mount it to /home. I'd recommend to do that by a static mount in /etc/fstab.

Result: The home directories remain "standard" (/home/user), but they're located on the second hard disk.

Once you established that everything works, you log in as root, temporarily unmount the /home volume, and delete everything in the original /home directory to regain the space. Re-mount /home, and you're done.

[X] Doc CPU
 
1 members found this post helpful.
Old 03-03-2012, 05:50 AM   #4
vjramana
Member
 
Registered: Sep 2009
Posts: 89

Original Poster
Rep: Reputation: 0
Hi T3RM1NVT0R,

I tried your method, but there seems some error I get.
I could create a user account using command.

useradd kaka
passwd kaka

but when I login I get this message as below:

Could not chdir to home directory /mnt/data/home/kaka: Permission denied
-bash: /mnt/data/home/kaka/.bash_profile: Permission denied
-bash-3.2$

note: I work from root.
Thank you

Last edited by vjramana; 03-03-2012 at 05:52 AM.
 
Old 03-03-2012, 06:46 AM   #5
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

I have checked on my system and it works perfectly fine. Did you compare the permissions of /home and /mnt/data/home.

It appears to me that user does not have read / excute permissions on /mnt/data and thus it is not able to get into his home directory. Default /home permissions are drwxr-xr-x. You have to setup /mnt/data/home the same way. Paste the output of the following commands:

1.
Code:
cat /etc/default/useradd
2.
Code:
ls -l / | grep home
3.
Code:
ls -l /mnt/data
 
1 members found this post helpful.
Old 03-06-2012, 05:53 AM   #6
vjramana
Member
 
Registered: Sep 2009
Posts: 89

Original Poster
Rep: Reputation: 0
Hi, T3RM1NVT0R

I got it. The trick was the permission of the /mnt/data/home. I changed the mode to, chmod ugo+rwx. Then it is working ready.

Thanks.

Regards.

Vijay
 
  


Reply

Tags
home directory, linux users, mnt



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Make Linux Translate String c:\data\ As /mnt/ntfs/data/ kraml Linux - General 4 01-15-2012 10:48 AM
Synchonizing data files and creating a NAS third data set Odyssey1942 Linux - Newbie 5 07-23-2009 06:44 AM
copying data to file:/mnt/hd on mandrake 10 star2a Linux - General 0 06-15-2004 08:34 AM
allowing /mnt/ to all users bcf2 Mandriva 1 02-18-2004 05:10 PM
mount -t //192.168.0.1/mnt /mnt/windows -o password='' generates error broadsoft Linux - Networking 3 08-07-2003 04:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:01 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration