Smbclient and ubuntu server with snap

I’ve looked online for solutions, but I can’t seem to find one that fixes my problem. At least not one I understand. I’ve read the option in github from 2016. But I’m still at a loss.
I’m installing nextcloud using the option available during the ubuntu 22.04 server install. It seems to work great. However, I can not access my usb drive. The smb/cif option is not available in the external drive section of nextcloud and I how smbclient is not installed. Is there a way to access the usb drive to store and backup data?
Thank you.


If your nextcloud in installed via snap then by default snap doesn’t allow it to access anything beyond its own confined file system.

Run following command,

sudo snap connect nextcloud:removable-media → It will allow snap to access outside of it’s file system.

However still it can only access something which is under /media and /mnt so mount your USB drive or network share within those directories.

Now your nextcloud can access network share or external drives.


@NaXal Thank you for that information. It worked perfectly. I’m going to post another about moving the data folder. Since I see some functionality is limited on folders associated with external drive and to reduce confusion for the users (e.g. my family), I’d like to just move the folder.
I’m running nextcloud snap install on the non-server Ubuntu 22.04 with a windows formatted usb drive attached. I moved the data folder before setting up any nextcloud users and was able to successfully log in. However, it then complained that my data directory is readable by anyone. I’ve tried changing permissions based on several blogs, but with no luck.
Any suggestions?
Thank you again.
p.s. I’m going to post this as a separate instance as well.


Ubuntu / Linux in general works better with EXT, Windows by default doesn’t support this file system so Windows Formatted drive will be with FAT or NTFS.

It is better to reformat it within Ubuntu with ext4 file system.

How to Change Snap NextCloud user Data Directory?

Step 1 →

Connect the Disk and ensure it is detected and readable by Ubuntu by running command, sudo lsblk. This command should show an output with sdb or sdc (depending on number of drive installed) with your drive total capacity.

Step 2 →

Formatting the drive and mounting it under /media or /mnt

sudo mkdir /media/datadisk

sudo mkfs.ext4 -j -L DataDisk /dev/sdb


sudo blkid /dev/sdb → It will generate the disk UUID. Copy it and keep it for the next step.

sudo nano /etc/fstab → It will open up a configuration file under text edititor, don’t change anything just add below line at the end of the file → /dev/disk/by-uuid/4006fe68-879a-41ed-b4da-cc0e6bc6b4bb /media/datadisk auto nosuid,nodev,nofail,x-gvfs-show,x-gvfs-name=NewHDD 0 0 (replace the UUID of this command with your own) Now save and exit the file (CTRL+X → SHIFT+Y → ENTER)

sudo mount -a

Step 3 →

Changeing the nextcloud to the new location

sudo snap stop nextcloud

sudo mv /var/snap/nextcloud/common/nextcloud/data /media/datadisk/ncdata

sudo nano /var/snap/nextcloud/current/nextcloud/config/config.php → Find the line with entry for DataDirectory and change the location to /media/datadisk/ncdata. Save and exit

sudo chown -R root:root /media/datadisk/ncdata & then sudo chmod 0770 /media/datadisk/ncdata

sudo snap start nextcloud

Last Step →

You may now need to reboot the server.

Your installation will now save all user data out to that external or second disk.


Thank you again for the detailed information. Everything was working very well until this morning when I lost everything in the /media/datadisk/ncdata folder. I created a new post detailing what I did.