This is what worked for me. I am running an Ubuntu host server with HA as a KVM VM. I already had a Samba share setup for media. I also had nfs-kernel-server already installed on the host server. When trying to mount the cifs share in HA I was getting an error because the password contained a ) symbol in it. Iām now wondering if the posts recommending using ā ā around the mount commands would have resolved that issue. But I have not tested that. I switched to trying to mount it as an NFS share.
NOTE IP Addresses and folder paths have been changed where necessary for security reasons.
To get past the permission denied error for NFS mount command in HA, 1st in HA terminal run the mount command using the -vvvv option to see verbose messages. The network IP address of my HA server is 192.168.1.12. However, the verbose message showed that HA VM was communicating with host server using a client IP address of 172.30.32.2. Next on the server that Iām exporting (sharing) the media folder from, run command:
ls -l /path/to/shared/folder
(using your path) to see user and group of folder owner. Then run the command:
id username
where username was determined from previous ls command. The output of the id command will give you the user id and group id corresponding to the output of the ls command. Then edit the /etc/exports file (as root or sudo) on the server containing the shared media folder adding a line like the one below, adjusted for your environment:
/local/folder/media 192.168.1.12(rw,no_subtree_check,all_squash,anonuid=1001,anonguid=141) 172.30.32.2(rw,no_subtree_check,all_squash,anonuid=1001,anonguid=141)
where:
/local/folder/media is the folder you are sharing
I added both HA network IP Address and the client IP Address used to communicate with host to be safe.
anonuid = the user ID for the folder owner, and anonguid = the group id for folder.
make sure there is not a space between the IP Address and the (.
Save the file then restart nfs service with command:
sudo systemctl restart nfs-kernel-server
Occasionally the service failed to restart for me. I double check the exports file but didnāt see anything wrong. The NFS service restarted on the 2nd try.
In configuration.yaml I have:
homeassistant:
media_dirs:
media: "/media"
shell_command:
make_music_folder: mkdir -p /media/music
mount_music_nfs_folder: mount -t nfs4 -o rw 192.168.1.10:/local/folder/media /media/music
I used the media folder since it already existed in HA and I wouldnāt have to worry about recreating it after upgrading HA.
After rebooting HA host I was able to go to Developer Tools ā Services and run both shell commands. I can now go to the Media tab and browse through all of the folders and files in the mounted share. My next step is to create an automation based on previous posts to run the shell commands upon HA startup.