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
root@pop-os:/zp0# zfs list
NAME USED AVAIL REFER MOUNTPOINT
zp0 120M 899G 24K /zp0
zp0/home 117M 899G 117M /home
root@pop-os:/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
root@pop-os:/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”.
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
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:
u0@pop-os:~$ which useradd
/usr/sbin/useradd
u0@pop-os:~$ 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.
root@pop-os:/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/
root@pop-os:/home# su - u1
u1@pop-os:~$ 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?
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?
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.
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