LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-05-2016, 01:17 PM   #1
fanoflq
Member
 
Registered: Nov 2015
Posts: 397

Rep: Reputation: Disabled
How to integrate /home from a separate partition into existing filesystem?


How to integrate /home from separate partitions or devices into existing filesystem?

Scenario:

1) Have one or more separate partitions for /home.
And each partition contains one or more user directory.
E.g.
In sda10, /home with /user10-1, /user10-2, ....
In sda11, /home with /user11-1, /user11-2, ....

2) We have a root filesytem, on a new installed or an existing OS.
Obviously this OS already has a /home folder.

Questions:
a) If I mount sda10 and sda11 to root filesystem's /home directory, I would have conflicts.
So I would just mount each subdrectories (/user10-1, /user10-2, .... ) from sda10 and sda11 to root filesystem's /home directory.
Meaning create mount points of same names and mount those subdirectories from separate partitions under /home/<user_name>.

Is there a better way to do this?

b) Have done part a) above, the OS still does not know those newly mounted user directories in /home/<user_name> belongs to specific users.

So next I would create account for these user sub directories with same user account names.

When I create user accounts, I would expect OS to possibly delete those existing same name user subdirectories when the OS tried to create same directories for the new user account?

Is this likely and how do I deal with this deletion scenario?

How to configure OS to recognize such user subdirectories as
belonging to corresponding user such that when user signs in,
that subfolder would be automatically assigned to the appropriate user?


Thank you.
 
Old 10-05-2016, 01:45 PM   #2
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 5,393

Rep: Reputation: 409Reputation: 409Reputation: 409Reputation: 409Reputation: 409
First set your partition mountpoint in /etc/fstab eg:
Code:
/dev/sda10        /home1       ext4        defaults     1
/dev/sda11        /home2       ext4        defaults     1
Code:
mkdir /home1 /home2
mount /home1
mount /home2
It's just an example, you can use any name you want, and have to set correct filesystems accordingly
then when adding new users, you use the -b option for useradd
Code:
useradd -b /home1 -g <group> -u <uid> user10-1
useradd -b /home2 -g <group> -u <uid> user11-1
Edit:
It's possible to use bind mount also
Code:
mkdir -p /srv/hd1
mkdir -p /srv/hd2
mkdir /home/user10-1 /home/user11-1
Then in /etc/fstab
Code:
/dev/sda10        /srv/hd1      ext4        defaults     1
/dev/sda11        /srv/hd2      ext4        defaults     1
/srv/hd1/home/user10-1   /home/user10-1    none      bind
/srv/hd2/home/user11-1   /home/user11-1    none      bind
...
In this case all users have home dirs under /home

Last edited by keefaz; 10-05-2016 at 01:58 PM.
 
2 members found this post helpful.
Old 10-05-2016, 02:20 PM   #3
fanoflq
Member
 
Registered: Nov 2015
Posts: 397

Original Poster
Rep: Reputation: Disabled
Thumbs up

@keefaz:

Thank you!
 
Old 10-05-2016, 03:45 PM   #4
IsaacKuo
Senior Member
 
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian 9 Stretch
Posts: 2,274
Blog Entries: 8

Rep: Reputation: 361Reputation: 361Reputation: 361Reputation: 361
I was going to suggest the bind mount option, but I'm happy to learn about the other method!

I will note one thing that does NOT work. If you try to use symbolic links (instead of bind mounts) in /home, then the symlink to a user's home directory at another location will NOT work. I don't know exactly why, I just know that when I tried it before it failed miserably...at least when trying to log in to a GUI.
 
Old 10-07-2016, 08:00 AM   #5
fanoflq
Member
 
Registered: Nov 2015
Posts: 397

Original Poster
Rep: Reputation: Disabled
@IsaacKuo:

What is Yahoo mechdan?
 
Old 10-07-2016, 07:57 PM   #6
IsaacKuo
Senior Member
 
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian 9 Stretch
Posts: 2,274
Blog Entries: 8

Rep: Reputation: 361Reputation: 361Reputation: 361Reputation: 361
Quote:
Originally Posted by fanoflq View Post
@IsaacKuo:

What is Yahoo mechdan?
That's my Yahoo account name, if you want to IM me. However, my IM info is years out of date. I haven't logged into my ICQ account in years, and Google+ IM is the only one which will likely get my attention.
 
Old 10-08-2016, 10:03 PM   #7
MadeInGermany
Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 502

Rep: Reputation: 235Reputation: 235Reputation: 235
In big environments you want every user as /home/user in the passwd.
If your physical storage path is different you need a mapping.
Having bind mounts in fstab is one solution.
The Sun Microsystems solution was automounter, using an auto.home (later auto_home) map.
Code:
# cat /etc/auto.master
/home auto.home
# cat /etc/auto.home
user1 server1:/export/home/home1/user1
user2 server1:/export/home/home2/user2
This is NFS syntax. It makes most sense if you have shared home directories on many computers.
The auto.home map (and even the auto.master) can be in NIS (or NIS+ or LDAP), as a means to centralize the administration of auto.home. Otherwise another configuration management must provide the identical /etc/auto.home files.
If only used locally, the NFS is some overhead: the server1 is the local host. In Solaris the automounter detects that and automatically uses an efficient bind mount (in Solaris implemented as another mount type: lofs).
I tell you this because it is THE traditional enterprise standard. Linux has re-engineered (and other commercial Unix have licenced) NFS, autofs/automounter, NIS. And all have implemented openldap.

Last edited by MadeInGermany; 10-08-2016 at 10:10 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there any benefit of making a separate partition for home, root and boot partition Vexe Linux - Hardware 18 02-23-2013 12:00 PM
Using a separate /home partition. Sgt Canuck Linux - General 6 03-10-2009 02:22 PM
Home directory on separate partition Steve W Linux - Newbie 23 03-19-2008 02:51 PM
Home directory on separate partition Steve W Linux - Newbie 2 03-12-2008 01:36 PM
Does anyone here have a separate /root and /home partition? Kramer Linux - General 12 03-17-2004 06:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:59 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration