[Note: Don’t start following these directions until you’ve read this whole post. The NFS stuff was a dead end.]
I set up a user for myself on the NAS. Next, I need to connect the NAS to my home folder, so I can put the Documents, Music and Videos directories on it. The first step is to enable NFS on the client. In Ubuntu, install nfs-common with Synaptic. To automount directories, install autofs, which will install autofs5.
Synology -> Control Panel-> User, Create, then User Home and Enable User Home Service.
Synology -> Control Panel -> Shared Folder, select homes, NFS Privileges, Create. Add network segment, e.g., 192.168.1.0/24 and read/write. Note mount path at bottom.
$ sudo mount -t nfs4 nas:/volume1/homes /mnt
mount.nfs4: mounting nas:/volume1/homes failed, reason given by server:
No such file or directory
$ sudo mount -t nfs nas:/volume1/homes /mnt
$ sudo mount nas:/volume1/homes /mnt
work fine, but now I’m concerned with security because NFS doesn’t validate connections by user, but by host and I don’t have common user IDs across my machines.
Synology has a forum post on linking network drives that uses CIFS. I tried this:
$ mkdir ~/nas
As root, edit
//nas/home /home/me/nas cifs user,uid=me,gid=me,rw,suid,credentials=/home/me/.naspwd 0 0
# chmod 0600 ~/.naspwd
$ mount ~/nas
mount: wrong fs type, bad option, bad superblock on //nas/home,
missing codepage or helper program, or other error
(for several filesystems (e.g. nfs, cifs) you might
need a /sbin/mount. helper program)
In some cases useful info is found in syslog - try
dmesg | tail or so
CIFS VFS: No username specified
CIFS VFS: cifs_mount failed w/return code = -22
Other instructions on the Net use Samba, so I tried that. Installed packages samba, samba-tools, smbfs, samba-doc, xsmbrowser. (You really only need smbfs.)
Now this works:
# sudo mount -t smbfs //nas/home ~/nas -o username=nas username,password=nas pwd
So does this:
# sudo mount -t smbfs //nas/home ~/nas -o credentials=/home/me/.naspwd
As root, edit
/etc/fstab and change file system type from cifs to smbfs.
(When later updating another machine, I found out it was smbfs that was needed by cifs, so you can use cifs in
/etc/fstab if you want instead of smbfs.)
Now, as root
# sudo mount /home/me/nas
works, but if I run it as me, I get
mount error(1): Operation not permitted
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
But this is good enough to have my home directory on the Synology DiskStation automatically mapped to ~/nas on the client. From there, I moved my common directories (e.g., Documents, Videos, and Music) to the NAS directory and made them soft links to the NAS:
$ cp -r ~/Documents ~/nas
$ mv ~/Documents ~/Documents-old
$ ln -s ~/nas/Documents ~/.