Using External Hard Disk for data storage with Orthanc installed on Raspberry Pi

I am running Raspbian stretch on Raspberry Pi 2/3 and installed Orthanc 1.2 using the repositories of stretch distribution - i.e. sudo apt-get install orthanc. I have attached an external hard disk using a powered USB hub to my RPi. IT is formatted as NTFS and labelled "OrthancPiStorage". There is a folder "OrthancStorage" on the HDD. It gets mounted at "/media/pi/OrthancPiStorage". And I can write to the disk and read from the disk.

I want to use the folder "OrthancStorage" as the folder for storing the data (DICOM files) of Orthanc server. I modified the "/etc/orthanc/orthanc.json" to include

     "StorageDirectory" : "/media/pi/OrthancPiStorage/OrthancStorage",

and commented out the default location in the configuration file.

after I restart service orthanc (sudo service orthanc restart) the Orthanc.log is as follows -

W0924 00:47:05.617477 main.cpp:1238] Orthanc version: 1.2.0
W0924 00:47:05.617636 main.cpp:1095] Performance warning: Non-release build, runtime debug assertions are turned on
W0924 00:47:05.625580 OrthancInitialization.cpp:173] Scanning folder "/etc/orthanc/" for configuration files
W0924 00:47:05.625815 OrthancInitialization.cpp:125] Reading the configuration from: "/etc/orthanc/serve-folders.json"
W0924 00:47:05.626281 OrthancInitialization.cpp:125] Reading the configuration from: "/etc/orthanc/worklists.json"
W0924 00:47:05.626469 OrthancInitialization.cpp:125] Reading the configuration from: "/etc/orthanc/orthanc.json"
W0924 00:47:05.711692 FromDcmtkBridge.cpp:141] Loading the external DICOM dictionary "/usr/share/libdcmtk8/dicom.dic"
W0924 00:47:05.790013 FromDcmtkBridge.cpp:141] Loading the external DICOM dictionary "/usr/share/libdcmtk8/private.dic"
W0924 00:47:05.847055 OrthancInitialization.cpp:488] Registering JPEG Lossless codecs
W0924 00:47:05.847222 OrthancInitialization.cpp:493] Registering JPEG codecs
W0924 00:47:05.914637 main.cpp:632] Loading plugin(s) from: /usr/share/orthanc/plugins/
W0924 00:47:05.916165 PluginsManager.cpp:268] Registering plugin 'serve-folders' (version 1.2.0)
W0924 00:47:05.917590 PluginsManager.cpp:167] ServeFolders: Empty configuration file: No additional folder will be served!
W0924 00:47:05.918387 PluginsManager.cpp:268] Registering plugin 'worklists' (version 1.2.0)
W0924 00:47:05.918450 PluginsManager.cpp:167] Sample worklist plugin is initializing
W0924 00:47:05.919117 PluginsManager.cpp:167] Worklists server is disabled by the configuration file
W0924 00:47:05.919219 OrthancInitialization.cpp:986] SQLite index directory: "/var/lib/orthanc/db-v6"
W0924 00:47:05.919959 OrthancInitialization.cpp:1056] Storage directory: "/media/pi/OrthancPiStorage/OrthancStorage"
W0924 00:47:05.920322 PluginsManager.cpp:218] Unregistering plugin 'serve-folders' (version 1.2.0)
W0924 00:47:05.920474 PluginsManager.cpp:218] Unregistering plugin 'worklists' (version 1.2.0)
W0924 00:47:05.920514 PluginsManager.cpp:167] Sample worklist plugin is finalising
E0924 00:47:05.920697 main.cpp:1281] Uncaught exception, stopping now: [boost::filesystem::status: Permission denied: "/media/pi/OrthancPiStorage/OrthancStorage"]
W0924 00:47:05.921864 main.cpp:1297] Orthanc has stopped

What am I doing wrong. I know that it should work as it worked once in the same setting but the sd-card got corrupted and I had to write another and have not been able to get it to work again.

Hi

Is /media/pi/OrthancPiStorage/OrthancStorage belong to orthanc:orthanc ?

Bertrand

No it belongs to pi:pi .

Is the user orthanc authorised to read/write this folder if it is not the owner ?

B.

I changed the ownership to orthanc:orthanc but still am getting the same error.

Thats what I did – but nothing is working

umount /dev/sda1

Now there was no folder under /media/pi

sudo mkdir /media/pi/OrthancPiStorage

sudo chown orthanc:orthanc /media/pi/OrthancPiStorage

Now when I reboot, /dev/sda1 is mounted under OrthancPiStorage, but ownership of the folder OrthancPistorage changes to root:root (I think I remember this right that it used to be pi:pi - but now it is always root:root and after the drive is mounted I am not able to change the ownership of the folder)

and I get the same error in orthanc log

I removed the /dev/sda1 /media/pi/OrthancPiStorage ntfs3g defaults 0 0 from fstab and now /media/pi/OrthancPiStorage is again owned by pi:pi

pi@raspberrypi:~ $ id orthanc

uid=112(orthanc) gid=117(orthanc) groups=117(orthanc)

so I added the following to fstab

/dev/sda1 /media/pi/OrthancPiStorage ntfs-3g defaults,user,uid=112,gid=117,noatime

now the folders OrthancPiStorage and all folders under it have ownership as orthanc:orthanc

But the Orthanc log gives the same error

I have not been able to use either an external usb pen drive or an external usb HDD to use to store data with Orthanc. ??

Another observation -

I formatted my external drive to ext4 format and labelled it “OrthancPiStorage”.

I let the linux distribution (Raspbian) mount it as it deems right. It is mounted under “/media/pi/OrthancPiStorage” with “pi:pi” as owner and “drwxrwxr-x” as permissions.

I created a folder “OrthancStorage” in it. Its owner is again “pi:pi” with “drwxrwxr-x” as the permissions.

The "StorageFolder in “orthanc.json” is set to “/media/pi/OrthancPiStorage/OrthancStorage” - I get the error “Uncaught exception, stopping now: [boost::filesystem::status: Permission denied: “/media/pi/OrthancPiStorage/OrthancStorage”]” in the “/var/log/orthanc/Orthanc.log” (same log as in the first post).

Now I create a folder “OrthancStorage” in /home/pi folder. The folder “/home/pi/OrthancStorage” has ownership of “pi:pi” and permissions as “drwxrwxr-x”.
The “StorageFolder” in “orthanc.json” is set to “/home/pi/OrthancStorage” - no error, the server runs perfectly.

Can someone sort my problem out.

Please avoid discussing the same problem in different threads.

I have posted an answer at the following location:
https://groups.google.com/d/msg/orthanc-users/950ULo5hs_w/DIyqzSQMBwAJ

Sébastien-

At last it worked.
I had to modify my pi so that it loaded the operating system from external USB HDD and did not change the storage location in the configuration file. Now the root drive is the hard disk and storage is also happening on it and it worked.