Nextcloud-snap: Permission denied when accessing external HDD

Created on 5 Sep 2017  路  6Comments  路  Source: nextcloud/nextcloud-snap

Hi,
I installed nextcloud via snap on a Raspberry Pi3 running Ubuntu Core.
I mounted an external HDD formatted to EXT4 to /media/Data and, from the Nextcloud web interface, I added the Local external storage (named "Data", with permission set to "all users"):

nc

But when I try to create a file in Data folder, it says it's impossible to create files here:

nc

If I type sudo nextcloud.occ files:scan <username> I get this error:
`Exception while scanning: opendir(/media/Data/): failed to open dir: Permission denied

0 [internal function]: OCA\Files\Command\Scan->exceptionErrorHandler(2, 'opendir(/media/...', '/snap/nextcloud...', 117, Array)

1 /snap/nextcloud/2713/htdocs/lib/private/Files/Storage/Local.php(117): opendir('/media/Data/')

2 /snap/nextcloud/2713/htdocs/lib/private/Files/Cache/Scanner.php(357): OC\Files\Storage\Local->opendir('')

3 /snap/nextcloud/2713/htdocs/lib/private/Files/Cache/Scanner.php(408): OC\Files\Cache\Scanner->getNewChildren('')

4 /snap/nextcloud/2713/htdocs/lib/private/Files/Cache/Scanner.php(388): OC\Files\Cache\Scanner->handleChildren('', true, 3, '35', true, 0)

5 /snap/nextcloud/2713/htdocs/lib/private/Files/Cache/Scanner.php(322): OC\Files\Cache\Scanner->scanChildren('', true, 3, '35', true)

6 /snap/nextcloud/2713/htdocs/lib/private/Files/Utils/Scanner.php(196): OC\Files\Cache\Scanner->scan('', true, 3)

7 /snap/nextcloud/2713/htdocs/apps/files/lib/Command/Scan.php(159): OC\Files\Utils\Scanner->scan('/matt')

8 /snap/nextcloud/2713/htdocs/apps/files/lib/Command/Scan.php(227): OCA\Files\Command\Scan->scanFiles('matt', '/matt', false, Object(Symfony\Component\Console\Output\ConsoleOutput), false)

9 /snap/nextcloud/2713/htdocs/3rdparty/symfony/console/Command/Command.php(256): OCA\Files\Command\Scan->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

10 /snap/nextcloud/2713/htdocs/core/Command/Base.php(161): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

11 /snap/nextcloud/2713/htdocs/3rdparty/symfony/console/Application.php(818): OC\Core\Command\Base->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

12 /snap/nextcloud/2713/htdocs/3rdparty/symfony/console/Application.php(186): Symfony\Component\Console\Application->doRunCommand(Object(OCA\Files\Command\Scan), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

13 /snap/nextcloud/2713/htdocs/3rdparty/symfony/console/Application.php(117): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

14 /snap/nextcloud/2713/htdocs/lib/private/Console/Application.php(169): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

15 /snap/nextcloud/2713/htdocs/console.php(98): OC\Console\Application->run()

16 /snap/nextcloud/2713/htdocs/occ(11): require_once('/snap/nextcloud...')

17 {main}`

Neither chown nor chmod 777 on the mount point "/media/Data" seem to work. What do you think? Thanks in advance.

Most helpful comment

Hey there @Void97, thanks for logging an issue. From the symptoms it sounds like you haven't connected the removable-media plug, could that be true? Stealing from the README in case you don't know what I'm talking about:

Also note that the interface providing the ability to access removable media is not automatically connected upon install, so if you'd like to use external storage (or otherwise use a device in /media for data), you need to give the snap permission to access removable media by connecting that interface:

$ sudo snap connect nextcloud:removable-media

All 6 comments

Hey there @Void97, thanks for logging an issue. From the symptoms it sounds like you haven't connected the removable-media plug, could that be true? Stealing from the README in case you don't know what I'm talking about:

Also note that the interface providing the ability to access removable media is not automatically connected upon install, so if you'd like to use external storage (or otherwise use a device in /media for data), you need to give the snap permission to access removable media by connecting that interface:

$ sudo snap connect nextcloud:removable-media

Thanks for the advice!
I've tried what you suggested, now typing sudo nextcloud.occ files:scan <username> gives me a LockedException:
`Exception while scanning: "files/f3c292d7b0f1af4eddce2a8723dc76c4" is locked

0 /snap/nextcloud/2713/htdocs/lib/private/Files/Storage/Common.php(680): OC\Lock\MemcacheLockingProvider->acquireLock('files/f3c292d7b...', 2)

1 /snap/nextcloud/2713/htdocs/lib/private/Files/Cache/Scanner.php(316): OC\Files\Storage\Common->acquireLock('scanner::', 2, Object(OC\Lock\MemcacheLockingProvider))

2 /snap/nextcloud/2713/htdocs/lib/private/Files/Utils/Scanner.php(196): OC\Files\Cache\Scanner->scan('', true, 3)

3 /snap/nextcloud/2713/htdocs/apps/files/lib/Command/Scan.php(159): OC\Files\Utils\Scanner->scan('/matt')

4 /snap/nextcloud/2713/htdocs/apps/files/lib/Command/Scan.php(227): OCA\Files\Command\Scan->scanFiles('matt', '/matt', false, Object(Symfony\Component\Console\Output\ConsoleOutput), false)

5 /snap/nextcloud/2713/htdocs/3rdparty/symfony/console/Command/Command.php(256): OCA\Files\Command\Scan->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

6 /snap/nextcloud/2713/htdocs/core/Command/Base.php(161): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

7 /snap/nextcloud/2713/htdocs/3rdparty/symfony/console/Application.php(818): OC\Core\Command\Base->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

8 /snap/nextcloud/2713/htdocs/3rdparty/symfony/console/Application.php(186): Symfony\Component\Console\Application->doRunCommand(Object(OCA\Files\Command\Scan), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

9 /snap/nextcloud/2713/htdocs/3rdparty/symfony/console/Application.php(117): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

10 /snap/nextcloud/2713/htdocs/lib/private/Console/Application.php(169): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

11 /snap/nextcloud/2713/htdocs/console.php(98): OC\Console\Application->run()

12 /snap/nextcloud/2713/htdocs/occ(11): require_once('/snap/nextcloud...')

13 {main}`

But it works, from the web interface I can access to my external HDD. So it was a problem of snap confinement. Should I ignore the LockedException?

Should I ignore the LockedException?

Yeah I suspect it's temporary, e.g. it's already being scanned, so it locked it. Glad it's working! I'll go ahead and close this.

Yep, thank you!

Almost 3 years later still a valid advice! Thanks guys, saved me hours.

$ sudo snap connect nextcloud:removable-media

Still valid, fixed it for me

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tinokizis picture tinokizis  路  8Comments

JWise1203 picture JWise1203  路  5Comments

johnpoint picture johnpoint  路  4Comments

MichaelsGITIGIT picture MichaelsGITIGIT  路  6Comments

DAMONSTA360 picture DAMONSTA360  路  3Comments