Solved Question about mount and zroot

Hi everyone,

I am newby in FreeBSD.
I am sorry if I can't describe clear.
I set a SFTP server and mount /home to second disk (da1) for SFTP store files.
I add newuser and auto create /home/newuser.
It looks all good to here.

I create a files directory to /home/newuser/files and "chown newuser:sftp /home/newuser/files"
When I upload file from filezilla to my SFTP server /home/newuser/files/.
The data is store in zroot/usr/home. But the /home/newuser/ is store in /dev/da1p2 (second disk).

How to store the file to /home/newuser/files/ in mount disk (da1)?

Thank you.

1. I mount second disk /dev/da1p2 to /home
mount_001.jpg


2. Add newuser and the /home/newuser is store in /dev/da1p2 /usr/home. But when I upload file to SFTP /home/newuser/files/. It stores in zroot/usr/home.
mount_002.jpg
 
You've made a bit of mess of things. Normally on FreeBSD /home is a symlink to /usr/home. Home directories for users are stored in /usr/home/. Copy the files from the mounted /dev/da1p2 partition to /usr/home and unmount it. Then make sure /home is a symlink to /usr/home.

With SFTP you're writing to $HOME for 'newuser' which is likely /usr/home/newuser. You can see the user's home directory by looking at the output from getent passwd newuser.
 
You've made a bit of mess of things. Normally on FreeBSD /home is a symlink to /usr/home. Home directories for users are stored in /usr/home/. Copy the files from the mounted /dev/da1p2 partition to /usr/home and unmount it. Then make sure /home is a symlink to /usr/home.

With SFTP you're writing to $HOME for 'newuser' which is likely /usr/home/newuser. You can see the user's home directory by looking at the output from getent passwd newuser.
Thank you very much.
I edit "/dev/da1p2 /usr/home" in /etc/fstab and "mount -a" again.
It works.
 
I edit "/dev/da1p2 /usr/home" in /etc/fstab and "mount -a" again.
Don't do that. You already have a filesystem mounted on /usr/home. Now you have overlapping mounts, that's not a good idea.

Here's what you should do to untangle this mess.
umount /dev/da1p2
mount /dev/da1p2 /mnt
Now check the data in /mnt and /usr/home. Copy any missing data from /mnt to /usr/home.
Remove that da1p2 entry from /etc/fstab.
If you want to use that filesystem as extra storage space, mount it on /storage (directory doesn't exist so create it) for example.
 
Don't do that. You already have a filesystem mounted on /usr/home. Now you have overlapping mounts, that's not a good idea.

Here's what you should do to untangle this mess.
umount /dev/da1p2
mount /dev/da1p2 /mnt
Now check the data in /mnt and /usr/home. Copy any missing data from /mnt to /usr/home.
Remove that da1p2 entry from /etc/fstab.
If you want to use that filesystem as extra storage space, mount it on /storage (directory doesn't exist so create it) for example.
Thank you a lot.
After reboot the zroot/usr/home /usr/home auto mount again.
I change some setting. It looks working. But I am not sure it is correct.

set sshd_config chrootDirectory /sftp/%u instead /home/%u or /usr/home/%u
mount_005.jpg


mount /dev/da1p2 /sftp and mkdir /sftp
mount_004.jpg


add newuser home: /sftp/newuser
mount_003.jpg


getent passwd newuser
mount_006.jpg


upload file via sftp and the /sftp increase
mount_007.jpg
 
Back
Top