Struggling with Nextcloud's SMB/CIFS backend? Consider These Alternatives
Posted
Lately, I’ve been tinkering with Nextcloud and Samba shares using its SMB/CIFS backend. While the process seemed straightforward at first, I quickly ran into issues with the icewind1991/SMB library that Nextcloud relies on.
Under certain scenarios doesn’t parse the response messages properly and some file streams would lock/freeze and never return - which made it very frustrating to work with. I wasn’t fully satisfied with the patch I created, even though it worked, it didn’t feel like an ideal solution. Given these issues, I figured that it may be best to avoid using Nextcloud’s SMB/CIFS backend altogether and I started looking for alternative solutions.
Since I’m running Nextcloud in a container, I took a look in Docker’s documentation and found out that it’s possible to mount the share directly in a volume. To do that, you would have to do something like:
docker volume create \
--driver local \
--opt type=cifs \
--opt device=//hostname/share/ \
--opt o=username=user,password=xxx,file_mode=0777,dir_mode=0777 \
--name nas
Once you’ve created the volume, you can map it to your container by adding -v nas:/mnt/nas
to your Docker run command like:
docker run -d -p 8080:80 \
--net nginx \
--name nextcloud \
--hostname nextcloud \
--restart=unless-stopped \
--hostname nextcloud \
-v /opt/containers/nextcloud:/var/www/html \
-v nas:/mnt/nas \
nextcloud
Another option is to manually mount the Samba share in your operating system. This will give you more control over the mounting process and may be more reliable than using Nextcloud’s SMB/CIFS backend. Here’s an example of how to mount a Samba share in Linux:
sudo mount -t cifs //hostname/share /mnt/nas \
-o username=user,password=xxx,file_mode=0777,dir_mode=0777
Lastly you will need to configure the mount in your Nextcloud instance by navigating, as an admin, to settings/admin/externalstorages
and configure it like:
Folder Name | External Storage | Authentication | Configuration | Available for |
---|---|---|---|---|
nas | Local | None | /mnt/nas |
Once the mount is configured, you can access it like any other directory in Nextcloud.
In conclusion, if you’re struggling with Nextcloud’s SMB/CIFS backend, there are alternatives that you can try. Consider mounting it in a Docker volume or in your OS. By doing so, you can avoid the issues associated with the icewind1991/SMB library and ensure that your files are accessible and safe, while also enjoying improved performance and responsiveness.