FORUM CTRLX AUTOMATION
ctrlX World Partner Apps for ctrlX AUTOMATION
Dear Community User! We have started the migration process.
This community is now in READ ONLY mode.
Read more: Important
information on the platform change.
03-21-2024 10:18 AM
hi all,
finally I got some time to continue working on the Timecho IoTDB App for CtlrX and I think I'm approaching the finishing line, as I've managed to address all issues I had on my ToDo list.
Unfortunately the one left is a very important one: Storing data on an external hard-drive.
I use the media api in order to query all storage locations available and instead of trying to manage an mount them from my app, I'm now simply using what's configured in CtrlX. So now I've selected an external hard-drive that's mounted on `/media/sda1`.
Unfortunately as soon as I try to create a directory there from within my app, I get errors that I'm not allowed to do so.
Here's how the device is listed in CtrlX:
Would really love to fix this, so help is greatly appreciated.
Chris
Solved! Go to Solution.
03-21-2024 11:41 AM - edited 03-21-2024 11:41 AM
Moved to corresponding sub forum SDK.
Does your own application have the necessary rights (via plug "removable-media" see SDK documentation) to access the external storage?
03-21-2024 11:46 AM
I think it should:
03-21-2024 11:48 AM
03-21-2024 01:24 PM
So ... If I do an " ls -l" on /media I get this:
root@ctrlX-CORE:/media/sda1# ls -l /media/
total 4
drwx------ 3 boschrexroth rexroot 4096 Nov 2 15:52 sda1
and if I do an "ls -l" on /media/sda1, I get this:
root@ctrlX-CORE:/media/sda1# ls -l
total 16
drwx------ 2 root root 16384 Nov 2 15:52 lost+found
So it looks as if "root" should have full access on the device. And If I look at "ps -ux" I get this:
root 7399 1.8 12.7 3234396 260988 ? Sl 09:07 3:30 ./bin/java --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.util.concurrent=ALL-UNNAMED -cp time
So ... not quite sure, why my program is not allowed to create the directory: "/media/sda1/data/confignode/system"
03-21-2024 01:49 PM
And some more info from the syslog:
Mar 21 12:47:33 ctrlX-CORE audit[15602]: AVC apparmor="DENIED" operation="capable" profile="snap.timechodb.server" pid=15602 comm="java" capability=2 capname="dac_read_search"
Mar 21 12:47:33 ctrlX-CORE kernel: audit: type=1400 audit(1711025253.930:475): apparmor="DENIED" operation="capable" profile="snap.timechodb.server" pid=15602 comm="java" capability=2 capname="dac_read_search"
Mar 21 12:47:33 ctrlX-CORE timechodb.server[15602]: 165635 [main] ERROR c.t.iotdbapp.service.StorageService - Got error while doing startup checks
Mar 21 12:47:33 ctrlX-CORE timechodb.server[15602]: java.io.IOException: Start ConfigNode failed, because couldn't make system dirs: /media/sda1/data/confignode/system.
Mar 21 12:47:33 ctrlX-CORE timechodb.server[15602]: at org.apache.iotdb.confignode.conf.ConfigNodeStartupCheck.createDirIfEmpty(ConfigNodeStartupCheck.java:204)
Mar 21 12:47:33 ctrlX-CORE timechodb.server[15602]: at org.apache.iotdb.confignode.conf.ConfigNodeStartupCheck.createDirsIfNecessary(ConfigNodeStartupCheck.java:191)
Mar 21 12:47:33 ctrlX-CORE timechodb.server[15602]: at org.apache.iotdb.confignode.conf.ConfigNodeStartupCheck.startUpCheck(ConfigNodeStartupCheck.java:75)
Mar 21 12:47:33 ctrlX-CORE timechodb.server[15602]: at com.timecho.iotdbapp.service.StorageService.startConfigNodeService(StorageService.java:221)
M
03-22-2024 09:45 AM
Ok ... so I've been digging a bit more ... so it seems that the problem is related to the snap running as "root", but the /media/sda1 directory being owned by "rexroot" and having set permissions to only allow "rexroot" access to the directory. I could probably manually change the permissions or the owner, but that would only work on my device and only by manually hacking the file system.
What would be the CtrlX-way to solve this problem?
03-22-2024 10:08 AM
Ok ... so I've solved this problem myself ... unfortunately I can't really explain why this was a problem.
So I observed thay my sda1 was owned by the user "rexroot" and only that user had access to the directory. So I unmounted the drive in the CtrlX UI and then I could see the /media/sda1 directory now belonged to "root" ... if I mounted it again, it changed to "rexroot". So I unmounted it, and reformatted it from the UI. After that was done and I mounted it again, it belonged to "root" and now I'm able to write data to the hard-drive.
Could it be, that there was a bug in previous CtlrX OS versions, that set the username of the external media wrong? I know this was an issue I was having since the beginning.