ZFS subdirectories missing under /home

I am a freebsd newbie with limited knowledge about unix and linux, and thank you in advance for help. I set up a zpool including two HD for a samba server. I set the shared folders under /home for users and others such as pictures, etc. A few days ago the computer abruptly shut down, after I restarted it, my samba folders are all missing. /home folder seems to be empty now. From disk usage, I know the contents are there, just the links to the folders are missing.

Is the corruption due to hardware failure or just the file system? What's the best way to recover those folders and files? Thanks.
 
Do you have /home on a separate ZFS filesystem? Can you share the output of zfs list?

Also check /usr/home (if it exists) just to be sure.
 
On a standard FreeBSD install /home is a symlink to /usr/home.
 
Probably home folders are not mounted, if these are in a separate dataset?
zfs mount shows current mounts and zfs list shows datasets.
 
Yes. I created a zpool dataset and have /home.

Here's the output of zfs list
Code:
root@data:~ # zfs list
NAME                 USED  AVAIL  REFER  MOUNTPOINT
data                1.09T  4.18T    88K  /data
data/home           1.09T  4.18T  1.09T  /data/home
zsyst               1.45G   208G    88K  /zsyst
zsyst/ROOT           797M   208G    88K  none
zsyst/ROOT/default   797M   208G   797M  /
zsyst/tmp             88K   208G    88K  /tmp
zsyst/usr            685M   208G    88K  /usr
zsyst/usr/home        88K   208G    88K  /usr/home
zsyst/usr/ports      685M   208G   685M  /usr/ports
zsyst/usr/src         88K   208G    88K  /usr/src
zsyst/var           1.06M   208G    88K  /var
zsyst/var/audit       88K   208G    88K  /var/audit
zsyst/var/crash       88K   208G    88K  /var/crash
zsyst/var/log        576K   208G   576K  /var/log
zsyst/var/mail       156K   208G   156K  /var/mail
zsyst/var/tmp         88K   208G    88K  /var/tmp
my folders should be under data/home, but now there are no links to them.

Thank you very much!

Do you have /home on a separate ZFS filesystem? Can you share the output of zfs list?

Also check /usr/home (if it exists) just to be sure.
 
Last edited by a moderator:
Hi. The following worked for me:
First do
# rm -rf /usr/home
Then create a sym link
# ln -s /data/home /usr/home

You should test this by creating a new user and logging in.
Furthermore, you could mount your home dataset at /home with
# zfs set mountpoint=/home data/home
Check the ZFS chapter in the handbook. I think there is a similar good example.
 
my folders should be under data/home, but now there're no links to them.
Now you got me confused. In the OP you mentioned that /home was empty but now you're saying that /data/home is empty, so which one is it?

Anyway, I get the impression that you might be confusing a few things here. Whenever you create a new ZFS filesystem ('dataset') then it gets mounted under the root directory of that particular pool by default. Also important: a ZFS pool will automatically create a ZFS filesystem with the same name and make that available right away.

A good example is data which immediately got mounted as /data. So when you created the data/home dataset that new filesystem got mounted under the the main filesystem which in itself was already mounted on /data. Ergo: /data/home.

If /data/home doesn't exist for some reason then you should check if the filesystem can be automatically mounted: zfs get mounted,canmount data data/home. The canmount property (normally not set) determines if a ZFS filesystem gets mounted automatically.

My suggestion would be to remove zsyst/usr/home and then change the mountpoint of data/home to /home. So:
  • # zfs destroy zsyst/usr/home (warning!)
  • # zfs set mountpoint=/home data/home
After that things should be normally accessible and also stay that way.
 
I installed system in separate zfs "zsyst" on a SSD, and created a zpool "data" composed of two HDs, set the /home to /data/home, and put all user directories there, including shared ones like pictures.

Now you got me confused. In the OP you mentioned that /home was empty but now you're saying that /data/home is empty, so which one is it?

Anyway, I get the impression that you might be confusing a few things here. Whenever you create a new ZFS filesystem ('dataset') then it gets mounted under the root directory of that particular pool by default. Also important: a ZFS pool will automatically create a ZFS filesystem with the same name and make that available right away.

A good example is data which immediately got mounted as /data. So when you created the data/home dataset that new filesystem got mounted under the the main filesystem which in itself was already mounted on /data. Ergo: /data/home.

If /data/home doesn't exist for some reason then you should check if the filesystem can be automatically mounted: zfs get mounted,canmount data data/home. The canmount property (normally not set) determines if a ZFS filesystem gets mounted automatically.

My suggestion would be to remove zsyst/usr/home and then change the mountpoint of data/home to /home. So:
  • # zfs destroy zsyst/usr/home (warning!)
  • # zfs set mountpoint=/home data/home
After that things should be normally accessible and also stay that way.
 
Hi. The following worked for me:
First do
# rm -rf /usr/home
Then create a sym link
# ln -s /data/home /usr/home

You should test this by creating a new user and logging in.
Furthermore, you could mount your home dataset at /home with
# zfs set mountpoint=/home data/home
Check the ZFS chapter in the handbook. I think there is a similar good example.

I can enter /data/home, but couldn't see anything.
 
Mmh, that's odd. According to your zfs list the data/home set shows 1.09TB used.

I installed system in separate zfs "zsyst" on a SSD, and created a zpool "data" composed of two HDs, set the /home to /data/home, and put all user directories there, including shared ones like pictures.

Please explore how exactly did you set /home to /data/home and how did you transfer the data and directories?
 
Did you additionally create an empty directory /data/home on the parent filesystem /data?
So maybe your data is still there but you're cding in the empty directory. Check this with ls -a /data.
 
Last edited:
I installed system in separate zfs "zsyst" on a SSD, and created a zpool "data" composed of two HDs, set the /home to /data/home, and put all user directories there, including shared ones like pictures.
Then please share the output of the zfs get mounted,canmount data data/home command which I asked for earlier.

Seems your issue doesn't necessarily evolve around /home but around the ZFS data dataset which somehow cannot be accessed. That's a different scenario than you initially told us about. Because now I don't understand where Samba comes into play (if you're only using it to share data then let's ignore that for now though).

To get answers on a tech forum it's vital that you're as clear and detailed as possible. Because without that information we can't help you. It might be obvious for you that "I cannot access /home" also implies that there could be an issue with your other dataset, but how are we supposed to know about data if you're not telling us about it? And with all due respect but changing the story as the community tries to gather all the information needed to find the cause of your problems can be demotivating to some.

Anyway, right now I think that your problem might be caused by data which doesn't mount cleanly during boot, and I suspect that the cause lies with the canmount property for zsyst/ROOT/default which is set to false in order to cater to sysutils/beadm. A setup I'm definitely not a fan off because it causes a lot of collateral damage.

It is just a wild theory but I think that because / isn't automatically mounted during the main boot phase it causes a problem for data as well. As a result you only see the mountpoints but not the actual data.

The reason I say this is because I know that a scenario with two or more pools can work without any problems:
Code:
breve:/home/peter $ zpool list
NAME    SIZE  ALLOC   FREE  EXPANDSZ   FRAG    CAP  DEDUP  HEALTH  ALTROOT
zdata   464G   131G   333G         -    27%    28%  1.00x  ONLINE  -
zroot  33.8G  19.6G  14.1G         -    60%    58%  1.00x  ONLINE  -
breve:/home/peter $ zfs list zroot zdata
NAME    USED  AVAIL  REFER  MOUNTPOINT
zdata   131G   318G   104K  /opt
zroot  24.7G  7.96G  6.61G  /
Of course this ZFS installation wasn't set up by the (IMO braindead) default installer.
 
Many thanks for your patient reply. I totally agree with you that asking the questions clearly will help the community to figure out the issues sooner. Please forgive my ignorance due to my limited knowledge and not using freeBSD on a daily base.

Here's the output of zfs get mounted,canmount data data/home

root@data:~ # zfs get mounted,canmount data data/home
NAME PROPERTY VALUE SOURCE
data mounted yes -
data canmount on default
data/home mounted yes -
data/home canmount on default

As well as zpool list data

root@data:~ # zpool list data
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
data 5.44T 1.09T 4.35T - - 0% 20% 1.00x ONLINE -

It seems to me the the pointers to subdirectories and files are missing.

Thank you again for your help.

Then please share the output of the zfs get mounted,canmount data data/home command which I asked for earlier.

Seems your issue doesn't necessarily evolve around /home but around the ZFS data dataset which somehow cannot be accessed. That's a different scenario than you initially told us about. Because now I don't understand where Samba comes into play (if you're only using it to share data then let's ignore that for now though).

To get answers on a tech forum it's vital that you're as clear and detailed as possible. Because without that information we can't help you. It might be obvious for you that "I cannot access /home" also implies that there could be an issue with your other dataset, but how are we supposed to know about data if you're not telling us about it? And with all due respect but changing the story as the community tries to gather all the information needed to find the cause of your problems can be demotivating to some.

Anyway, right now I think that your problem might be caused by data which doesn't mount cleanly during boot, and I suspect that the cause lies with the canmount property for zsyst/ROOT/default which is set to false in order to cater to sysutils/beadm. A setup I'm definitely not a fan off because it causes a lot of collateral damage.

It is just a wild theory but I think that because / isn't automatically mounted during the main boot phase it causes a problem for data as well. As a result you only see the mountpoints but not the actual data.

The reason I say this is because I know that a scenario with two or more pools can work without any problems:
Code:
breve:/home/peter $ zpool list
NAME    SIZE  ALLOC   FREE  EXPANDSZ   FRAG    CAP  DEDUP  HEALTH  ALTROOT
zdata   464G   131G   333G         -    27%    28%  1.00x  ONLINE  -
zroot  33.8G  19.6G  14.1G         -    60%    58%  1.00x  ONLINE  -
breve:/home/peter $ zfs list zroot zdata
NAME    USED  AVAIL  REFER  MOUNTPOINT
zdata   131G   318G   104K  /opt
zroot  24.7G  7.96G  6.61G  /
Of course this ZFS installation wasn't set up by the (IMO braindead) default installer.
 
Thank you all for help. It seems the problem is solve for now. The following is what I did (as Lanakus suggested).

root@data:~ # zfs set mountpoint=/home data/home
cannot mount 'data/home': mountpoint or dataset is busy
property may be set but unable to remount filesystem

But the folders and files showed up.
 
This is just theory of mine, but if this problem happens again (only after a reboot) then you might want to try this: # zfs set canmount=on zsyst/ROOT/default. However, don't do this if you're using sysutils/beadm because then it could theoretically disrupt a few things (I can't say for sure because I never used beadm myself).
 
Remove zsyst/usr/home if it serves no more purpose. Leaving it might case mounting issues with two different filesystems mounting at the same mountpoint. Set the mountpoint of data/home to /usr/home. Make sure /home/ is a symlink to /usr/home/.
 
Well do. Thank you so much!

Remove zsyst/usr/home if it serves no more purpose. Leaving it might case mounting issues with two different filesystems mounting at the same mountpoint. Set the mountpoint of data/home to /usr/home. Make sure /home/ is a symlink to /usr/home/.
 
Remove zsyst/usr/home if it serves no more purpose. Leaving it might case mounting issues with two different filesystems mounting at the same mountpoint. Set the mountpoint of data/home to /usr/home. Make sure /home/ is a symlink to /usr/home/.

Are there good [bsd related] reasons why the home dataset should be mounted at /usr/home and /home should be a symlink or is it just a convention?
I mounted my storage/home set at /home and /usr/home is a symlink to. Actually I don't recognize any inconsistencies.

Another question:
Is it possible and advisable to move /var datasets the same way? On my desktop machine I had a SSD where my system pool lives and a HDD on which datasets for home, data, VMs and so on are sitting on a pool called storage. Im considering to move e.g. the /var/log set to the storage pool to have lower loads on the SSD.

Thanks for your replies!
 
Are there good [bsd related] reasons why the home dataset should be mounted at /usr/home and /home should be a symlink or is it just a convention?
Convention / backwards compatibility. /usr/home is something originally used by the system at the time only UFS was supported and FreeBSD is quite serious about backwards compatibility.

But I can say that although this is the official (and recommended) way of doing so it doesn't cause problems if you only use /home.

Im considering to move e.g. the /var/log set to the storage pool to have lower loads on the SSD.
Shouldn't be a problem. "Back in the days" I sometimes even symlinked (most) parts of /var to other slices because people didn't reserve enough space for /var during installation and there was no way to regain more.

So using another storage medium altogether should also work. But if that is advisable is another question, I'd try to avoid it. Problem is that /var is a pretty important place for your system, so if that other storage medium somehow fails on you for whatever reason then you got a major problem on your hands.
 
ShelLuser - thanks for your hints.

So using another storage medium altogether should also work. But if that is advisable is another question, I'd try to avoid it. Problem is that /var is a pretty important place for your system, so if that other storage medium somehow fails on you for whatever reason then you got a major problem on your hands.

These were my considerations and misgivings, too. My system pool is a zfs mirror - so I will leave /var and everything as it is. Never change a running system ;).
 
But I can say that although this is the official (and recommended) way of doing so it doesn't cause problems if you only use /home.
Just make sure all your user accounts are indeed using /home and not /usr/home.
 
Back
Top