/home on ZFS, PopOS 18.04 LTS, Users added via useradd do not get a diretory in /home, Why?

Hi,

I decided to try ZFS on a brand new PopOS 18.04 install. I selected PopOS because it comes with nVidia drivers out of the box and ZFS installs without an issue and seems to work (i.e., I can create pools and datesets).

So, I got the install and created a pool and was able to mount the pool to /home. However, new users created via useradd do not get a directory in /home. If I use finger u1 output tells me that there should be a user directory in /home but there isn’t one and logging in via su - u1 produces the following: “No directory, logging in with HOME=/”. I looked in /etc/defaults/useradd but I do not see anything there and setting the HOME option does not seem to do anything. I am not sure what I am missing here as I have been at this for some time and this is the first time that I tried ZFS. I did find the following thread ZFS: Move /home to another pool but it seems that I did all this.

Right now I am just trying to separate all user data from system data.

The output from zfs list, zpool status and mount is listed below. Any help greatly appreciated:)

Any help

[email protected]:/zp0# zfs list
    NAME       USED  AVAIL  REFER  MOUNTPOINT
    zp0        120M   899G    24K  /zp0
    zp0/home   117M   899G   117M  /home

[email protected]:/zp0# zpool status
      pool: zp0
     state: ONLINE
      scan: none requested
    config:

    	NAME        STATE     READ WRITE CKSUM
    	zp0         ONLINE       0     0     0
    	  mirror-0  ONLINE       0     0     0
    	    sda     ONLINE       0     0     0
    	    sdb     ONLINE       0     0     0
    	  mirror-1  ONLINE       0     0     0
    	    sdc     ONLINE       0     0     0
    	    sdh     ONLINE       0     0     0

    errors: No known data errors
       
[email protected]:/zp0# mount | grep zp0
    zp0/home on /home type zfs (rw,xattr,noacl)
    zp0 on /zp0 type zfs (rw,xattr,noacl)

ZFS (under Linux, included in distros) is still very, very new, and the correct method for creating a user home directly with zfs is to create a new data-set. ZFS is really focused on data-sets for different purposes, more so than regular folders. Think ZFS data-set when you think of a security boundary, rather than a folder.

The built in scripts for user modification on linux don’t do this, they simply try to create a folder. Which is fine for ext4 and other filesystems but not really the ideal way to work with zfs.

I’m at work without access to a zfs box at the moment, but if you read the zfs docs for creating a data-set, that’s what you want to do for each user home directory, and set the permissions on it using zfs.

i.e., create a new ZFS filesystem under zp0/home/yourusername, and give the dataset permissions for “yourusername”.

edit:
ZFS isn’t the issue here it seems.

I don’t think this is a zfs issue.
If user add created a home directory, a zfs problem would just leave a normal folder in the /home dataset.
There are flags that some distro’s change when they implement the useradd.
As it created neither a folder under /home nor a new child dataset, or separate dataset for the user, you can create one yourself, set the mountpoint, and update the user details in the OS

I didn’t even realise setting a home directory, and shell, and stuff is optional things for useradd; I presumed they were standard

Yeah you’re right.

Actually… @kbdeamon did you run adduser or useradd?

IIRC one of those merely adds a user to the password file, the other actually runs through the full process?

2 Likes

Hmm, maybe I chose the wrong option, and that would explain why it totally subverted my expectations.

Many different tools for the same job is anything but boring

Just read the man page on fedora.

Same man page for both commands.

But i’ve run into this issue a LONG time ago, like… back in the late 90s. And i remember getting different results for the above commands.

Maybe one is aliased with parameters on it, and the other isn’t. Something to check out.

1 Like

Hi @thro

going though your previous answer. Thank you. I used “useradd”. In as far as I know useradd and adduser should do the same things at least on some systems but it does not seem to be the case here:

[email protected]:~$ which useradd
/usr/sbin/useradd
[email protected]:~$ which adduser
/usr/sbin/adduser

So, I just tried “adduser” which also gives a bunch of questions and it looks like it creates a home dir and I can log in as that user as well.

[email protected]:/home# ll
total 8
drwxr-xr-x  4 root root    4 Feb 24 19:29 ./
drwxr-xr-x 24 root root 4096 Feb 24 17:19 ../
drwxr-xr-x 17 u0   u0     27 Feb 24 17:57 u0/
drwxr-xr-x  2 u1   u1      5 Feb 24 19:29 u1/
[email protected]:/home# su - u1
[email protected]:~$ ll
total 8
drwxr-xr-x 2 u1   u1      5 Feb 24 19:29 ./
drwxr-xr-x 4 root root    4 Feb 24 19:29 ../
-rw-r--r-- 1 u1   u1    220 Feb 24 19:29 .bash_logout
-rw-r--r-- 1 u1   u1   3771 Feb 24 19:29 .bashrc
-rw-r--r-- 1 u1   u1    807 Feb 24 19:29 .profile

May be now the question is why doesn’t useradd use any defaults like on other systems?

1 Like

A bit confused with this. So in essence would I be specifying a different home directory to useradd.

I think it might be a Debian(based) OS thing.

When i had the issue it was on Debin (i think) 2.0.

Nah, forget that post…

That’s what I though but i guess not on PopOS 18.08 LTS.

Hi @Trooper_ish,

I don’t follow this. What do you mean by “normal” folder? Is there some way to see that the home directories that are being create are ZFS directories as opposed to like ext4?

Kinda noobish question I suppose.

All right,

so at this point I have (1) 1 pool and (2) 1 dateset in that pool and (3) all home directories create are being created in that one dataset and (4) meaning that each directory is NOT a separate ZFS dataset.

Correct?

2 Likes

Yup, correct.

1 Like

you would have to create children datasets explicitly, which is easy to do.

Summary

Each child dataset inherits it’s parents details, and sets its own
mountpoint accordingly.
You can then change the mountpoint later to something else if you require, or even set mountpoint=none if you don’t want to mount it anywhere.
so if you have a pool that mount’s is root dataset to /data1 then it’s child would default to /data1/child1
but you can set the child’s mountpoint to /otherplace and any children from there would be /otherplace/grandhild1

1 Like