Cannot mount USB drive

Having issues with your DietPi installation or found a bug? Post it here.
sfh1975
Posts: 32
Joined: Sun Nov 03, 2019 12:22 pm

Re: Cannot mount USB drive

Post by sfh1975 »

Thank you, looks like the issue is with permissions.

Code: Select all

Oct 18 22:20:39 DietPi systemd[1]: Started Sonarr Daemon (DietPi).
Oct 18 22:22:11 DietPi Sonarr[1484]: [Info] Bootstrap: Starting Sonarr - /usr/li
b/sonarr/bin/Sonarr.exe - Version 3.0.6.1265
Oct 18 22:32:08 DietPi Sonarr[1484]: [Info] AppFolderInfo: Data directory is bei
ng overridden to [/mnt/dietpi_userdata/sonarr]
Oct 18 22:32:08 DietPi Sonarr[1484]: [Trace] DiskProviderBase: Directory '/mnt/d
ietpi_userdata/sonarr' isn't writable. Access to the path "/mnt/dietpi_userdata/
sonarr/sonarr_write_test.txt" is denied.
Also,

Code: Select all

Oct 18 18:41:53 DietPi systemd[1]: Started Radarr Daemon (DietPi).
Oct 18 22:20:42 DietPi Radarr[594]: [Info] Bootstrap: Starting Radarr - /opt/radarr/Radarr - Version 3.2.2.5080
Oct 18 22:25:11 DietPi Radarr[594]: [Info] AppFolderInfo: Data directory is being overridden to [/mnt/dietpi_userdata/radarr]
Oct 18 22:32:06 DietPi Radarr[594]: [Trace] DiskProviderBase: Directory '/mnt/dietpi_userdata/radarr' isn't writable. Access to the path '/mnt/dietpi_userdata/
radarr/radarr_write_test.txt' is denied.
AND:

Code: Select all

Oct 18 22:20:39 DietPi systemd[1]: Started Jellyfin Media Server.
Oct 18 22:32:06 DietPi jellyfin[1477]: Error whilst attempting to create folder
Oct 18 22:32:06 DietPi jellyfin[1477]: System.IO.IOException: The file '/mnt/dietpi_userdata' already exists.
Oct 18 22:32:06 DietPi jellyfin[1477]:    at System.IO.FileSystem.CreateDirectory(String fullPath)
Oct 18 22:32:06 DietPi jellyfin[1477]:    at System.IO.Directory.CreateDirectory(String path)
Oct 18 22:32:06 DietPi jellyfin[1477]:    at Jellyfin.Server.Program.CreateApplicationPaths(StartupOptions options)
Oct 18 22:32:06 DietPi systemd[1]: jellyfin.service: Main process exited, code=exited, status=1/FAILURE
Oct 18 22:32:06 DietPi systemd[1]: jellyfin.service: Failed with result 'exit-code'.
Oct 18 22:32:06 DietPi systemd[1]: jellyfin.service: Service RestartSec=100ms expired, scheduling restart.
Oct 18 22:32:06 DietPi systemd[1]: jellyfin.service: Scheduled restart job, restart counter is at 1.
Oct 18 22:32:06 DietPi systemd[1]: Stopped Jellyfin Media Server.
Oct 18 22:32:06 DietPi systemd[1]: Started Jellyfin Media Server.
Oct 18 22:32:08 DietPi jellyfin[2223]: Unhandled Exception
Oct 18 22:32:08 DietPi jellyfin[2223]: System.UnauthorizedAccessException: Access to the path '/mnt/dietpi_userdata/jellyfin/cache' is denied.
Oct 18 22:32:08 DietPi jellyfin[2223]:  ---> System.IO.IOException: Permission denied
Oct 18 22:32:08 DietPi jellyfin[2223]:    --- End of inner exception stack trace ---
Can you please help me with these, e.g. who should own what in the dietpi_userdata folder. This currently looks like this:

Code: Select all

root@DietPi:/mnt/dietpi_userdata# ls -l
total 60
drwxr-xr-x 2 root mediamgmt 4096 Oct 16 21:22 comics
drwxr-x--- 4 root mediamgmt 4096 Oct 16 21:22 deluge
drwxr-xr-x 8 root mediamgmt 4096 Oct 16 21:22 downloads
drwxr-xr-x 2 root mediamgmt 4096 Oct 16 21:22 ebooks
drwxr-xr-x 7 root mediamgmt 4096 Oct 16 21:28 homeassistant
drwxr-x--- 9 root mediamgmt 4096 Oct 17 02:13 jellyfin
drwxr-x--- 2 root mediamgmt 4096 Oct 16 22:41 lost+found
drwxr-xr-x 2 root mediamgmt 4096 Oct 16 21:22 Music
drwxr-x--- 3 root mediamgmt 4096 Oct 16 21:22 mysql
drwxr-x--- 4 root mediamgmt 4096 Oct 16 21:22 nzbget
drwxr-xr-x 2 root mediamgmt 4096 Oct 16 21:28 Pictures
drwxr-x--- 6 root mediamgmt 4096 Oct 16 23:53 radarr
drwxr-x--- 6 root mediamgmt 4096 Oct 16 23:32 sonarr
drwxr-xr-x 5 root mediamgmt 4096 Oct 16 23:30 ubooquity
drwxr-xr-x 2 root mediamgmt 4096 Oct 16 21:28 Video
I remember, in the early days, making a group(??) called mediamgmt and then adding users to it, if that helps.
Many thanks.
User avatar
trendy
Posts: 390
Joined: Tue Feb 25, 2020 2:54 pm

Re: Cannot mount USB drive

Post by trendy »

sfh1975 wrote: Fri Oct 22, 2021 11:37 am Can you please help me with these, e.g. who should own what in the dietpi_userdata folder.
It should be owned by dietpi user and dietpi group should have also full access.

Code: Select all

dietpi@RockPi:[~]$ ls -al /mnt/dietpi_userdata/
total 44
drwxrwxr-x 11 dietpi  dietpi  4096 Απρ  23 12:03 .
drwxr-xr-x  7 root    root    4096 Μαΐ   6 09:18 ..
drwxr-xr-x  8 bazarr  dietpi  4096 Οκτ  13 03:13 bazarr
drwxr-xr-x  5 radarr  root    4096 Οκτ  19 12:39 radarr
drwxr-xr-x  7 sonarr  root    4096 Οκτ  19 12:39 sonarr
Then each application would have its own user owning the folder.
sfh1975 wrote: Fri Oct 22, 2021 11:37 am I remember, in the early days, making a group(??) called mediamgmt and then adding users to it, if that helps.
Many thanks.
This could work, but you don't have write permission for the mediamgmt group for each folder.
User avatar
MichaIng
Site Admin
Posts: 3515
Joined: Sat Nov 18, 2017 6:21 pm

Re: Cannot mount USB drive

Post by MichaIng »

UNIX permissions are not the issue here. An additional group can only have an effect it the related directories are owned by this group ;). Here its root, intentionally to not allow any other user than the service itself to access these.

Is this a dedicated drive?

Code: Select all

findmnt -T /mnt/dietpi_userdata
Can you try to manually create a file inside?

Code: Select all

echo | sudo tee /mnt/dietpi_userdata/testfile
sudo rm /mnt/dietpi_userdata/testfile
sfh1975
Posts: 32
Joined: Sun Nov 03, 2019 12:22 pm

Re: Cannot mount USB drive

Post by sfh1975 »

Thanks, I think the settings messed up when I manually copied these dirs/files from the corrupt USB drive to the new one, while being logged in as root. I will try giving the main folder to dietpi and then folders to the respective applications.
trendy wrote: Fri Oct 22, 2021 12:03 pm
sfh1975 wrote: Fri Oct 22, 2021 11:37 am Can you please help me with these, e.g. who should own what in the dietpi_userdata folder.
It should be owned by dietpi user and dietpi group should have also full access.

Code: Select all

dietpi@RockPi:[~]$ ls -al /mnt/dietpi_userdata/
total 44
drwxrwxr-x 11 dietpi  dietpi  4096 Απρ  23 12:03 .
drwxr-xr-x  7 root    root    4096 Μαΐ   6 09:18 ..
drwxr-xr-x  8 bazarr  dietpi  4096 Οκτ  13 03:13 bazarr
drwxr-xr-x  5 radarr  root    4096 Οκτ  19 12:39 radarr
drwxr-xr-x  7 sonarr  root    4096 Οκτ  19 12:39 sonarr
Then each application would have its own user owning the folder.
sfh1975 wrote: Fri Oct 22, 2021 11:37 am I remember, in the early days, making a group(??) called mediamgmt and then adding users to it, if that helps.
Many thanks.
This could work, but you don't have write permission for the mediamgmt group for each folder.
sfh1975
Posts: 32
Joined: Sun Nov 03, 2019 12:22 pm

Re: Cannot mount USB drive

Post by sfh1975 »

Yes, this is a dedicated drive (the replacement for the previously corrupted USB drive). Root has r/w permissions. I am going to try to change these permissions as per trendy's recommendation. That is, to set dietpi as the owner of dietpi_userdata and then set sonarr/ radarr, etc. as the owners of their dirs in there.
MichaIng wrote: Fri Oct 22, 2021 2:57 pm UNIX permissions are not the issue here. An additional group can only have an effect it the related directories are owned by this group ;). Here its root, intentionally to not allow any other user than the service itself to access these.

Is this a dedicated drive?

Code: Select all

findmnt -T /mnt/dietpi_userdata
Can you try to manually create a file inside?

Code: Select all

echo | sudo tee /mnt/dietpi_userdata/testfile
sudo rm /mnt/dietpi_userdata/testfile
User avatar
Joulinar
Posts: 6442
Joined: Sat Nov 16, 2019 12:49 am

Re: Cannot mount USB drive

Post by Joulinar »

how did you copied the files from old to new disk. What was the command used?
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
sfh1975
Posts: 32
Joined: Sun Nov 03, 2019 12:22 pm

Re: Cannot mount USB drive

Post by sfh1975 »

Yep, silly me. Not sure what I was thinking :cry: I simply copied the files to the new USB, thinking that somehow the existing installations of sonarr, radarr, etc will pick up the existing databases without issue. It looks like not :( I am not worried about anything else except sonarr and radarr, as I had a huge list of wanted, ignored, etc items which will be a pain to setup again. Is there anyway to salvage the existing databases from the files that I have? I am thinking of going nuclear and reinstalling dietpi to the latest version, as I can set up almost everything else without much trouble.
So, any idea how to recover all or part of the (sql?) database of sonarr and radarr and use them with a fresh install? Many thanks.
Joulinar wrote: Sun Oct 24, 2021 3:01 pm how did you copied the files from old to new disk. What was the command used?
User avatar
Joulinar
Posts: 6442
Joined: Sat Nov 16, 2019 12:49 am

Re: Cannot mount USB drive

Post by Joulinar »

You have still the old HDD available? If yes you could copy data again. But this time not just using simple copy command as this will not preserve file system permission. Better to use rsync.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
sfh1975
Posts: 32
Joined: Sun Nov 03, 2019 12:22 pm

Re: Cannot mount USB drive

Post by sfh1975 »

Joulinar wrote: Sun Oct 24, 2021 4:06 pm You have still the old HDD available? If yes you could copy data again. But this time not just using simple copy command as this will not preserve file system permission. Better to use rsync.
I have that USB drive and a couple of images that I made of it as well. I didn't use rsync because I didn't have another USB of the same size (64GB, replaced by 32GB). Also, when I mounted the image, it was also mounted as read-only- same problem that the USB drive had, so thought that doing an rsync might produce the same problem. On the other hand, while copying files, I saw a few errors but other than that, all files were copied on the new drive (with messed up permissions of course).
User avatar
Joulinar
Posts: 6442
Joined: Sat Nov 16, 2019 12:49 am

Re: Cannot mount USB drive

Post by Joulinar »

Usingrsync did not require to have source and target with same size
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Post Reply