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.

cancel
Showing results for 
Search instead for 
Did you mean: 
SOLVED

Problems using external hard drives as storage location for App data

Problems using external hard drives as storage location for App data

cdutz
Long-established Member

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:

cdutz_0-1711012667017.jpeg

Would really love to fix this, so help is greatly appreciated.

Chris

 

7 REPLIES 7

CodeShepherd
Community Moderator
Community Moderator

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?

cdutz
Long-established Member

I think it should:

cdutz_0-1711017950748.png

 

cdutz
Long-established Member

Added the entire snapcraft.yaml ...

cdutz
Long-established Member

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"

cdutz
Long-established Member

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

cdutz
Long-established Member

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?

cdutz
Long-established Member

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.

Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist