Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.

Node-RED readonly #18

Open
owarek opened this issue Mar 17, 2019 · 9 comments
Open

Node-RED readonly #18

owarek opened this issue Mar 17, 2019 · 9 comments

Comments

@owarek
Copy link

owarek commented Mar 17, 2019

When I want to change backlight of RPi display, it trhrows:
Error: EROFS: read-only file system, open '/sys/class/backlight/rpi_backlight/bl_power

Is there a way to do this on readonly FS or how do I change the FS to writable?

Thank you in advance.

@imrehg
Copy link
Contributor

imrehg commented Mar 21, 2019

Hey @owarek, are you deploying this project as it is, or are you combining it with other containers in a multicontainer setup?

@owarek
Copy link
Author

owarek commented Mar 21, 2019

I have it as multicontainer setup. This is my compose file:

version: '2'
volumes:
node-red-data:
services:
wpe:
restart: always
build: ./wpe
privileged: true
scheduler:
restart: always
build: ./scheduler
privileged: true
mqtt:
image: panuwitp/mosquitto-arm
ports:
- "1883:1883"
node-red:
build: ./node-red
privileged: true
volumes:
- 'node-red-data:/data'
ports:
- "1880:1880"
depends_on:
- mqtt
restart: always

@imrehg
Copy link
Contributor

imrehg commented Mar 21, 2019

Hi, probably you need to paste that in not a ">" style of "quoting" but the code block as triple-backticks (`), see more in the help https://help.github.com/en/articles/creating-and-highlighting-code-blocks

And since you are using a completely different way of deploying the project, it's harder to answer what might be the issue. If you just deploy this particular project as it is in the repo, do you have the same error?

My guess would have been the privileged: true setting being required (that "read-only" warning being more a permission issue, than actual read only file system issue for /sys, as much as I know). Since it seems in your code you already use that, we will need to check further what other source of that error might be.

@imrehg
Copy link
Contributor

imrehg commented Mar 21, 2019

Also, how are you changing the backlight of a display, and what display are you using?
Do you have things shown on the display normally besides this issue? I'm guessing that the WPE service manages the display normally?

@imrehg
Copy link
Contributor

imrehg commented Mar 21, 2019

I think you have the 7" Raspberry Pi display, right?
Just tried that with this particular project, and use echo to write to that setting. The command returns an error, but the value is being set correctly. Here's the log from the node-red service's container (deployed as this project)

bash-4.4# echo 1 > /sys/class/backlight/rpi_backlight/bl_power
bash: echo: write error: Invalid argument
bash-4.4# cat /sys/class/backlight/rpi_backlight/bl_power
1
bash-4.4# echo 0 > /sys/class/backlight/rpi_backlight/bl_power
bash: echo: write error: Invalid argument
bash-4.4# cat /sys/class/backlight/rpi_backlight/bl_power
0

and looking at the screen, indeed it turns it off when 1 is sent, and turn it on when 0 is sent.

Thus it should work from the container, just have to find what setting is required. This does not seem to be the issue of this node-red project, however, regardless of the outcome.

@owarek
Copy link
Author

owarek commented Mar 21, 2019

Thank you for investigating this. Here is the compose file again:

volumes:
    node-red-data:
services:
  wpe:
    restart: always
    build: ./wpe
    privileged: true
  scheduler:
    restart: always
    build: ./scheduler
    privileged: true
  mqtt:
    image: panuwitp/mosquitto-arm
    ports:
      - "1883:1883"
  node-red:
    build: ./node-red
    privileged: true  
    volumes:
       - 'node-red-data:/data'
    ports:
       - "1880:1880"
    depends_on:
        - mqtt
    restart: always

and here is the dockerfile for node-red:


COPY ./settings.js /data/settings.js

USER root
RUN apt-get update && apt-get install nano
USER node-red

RUN npm install node-red-contrib-resinio
RUN npm install node-red-dashboard
RUN npm install node-red-contrib-credentials
RUN npm install node-red-admin
RUN npm install --save rpi-backlight

And yes I have the 7" RPi touch display. This is the output from terminal of node-red container:

node-red@cc2011243739:~$ echo 1 > /sys/class/backlight/rpi_backlight/bl_power
bash: /sys/class/backlight/rpi_backlight/bl_power: Permission denied
node-red@cc2011243739:~$ cat /sys/class/backlight/rpi_backlight/bl_power
0

In wpe and scheduler it works. In mqtt and node-red it does not.

@imrehg
Copy link
Contributor

imrehg commented Mar 21, 2019

@owarek I think the issue is that you are setting the user in node-red:

USER node-red

thus that user doesn't have the privileges to modify the file. So I think you will have to set up that user to have the right permissions, or keep using the root user?

@owarek
Copy link
Author

owarek commented Mar 21, 2019

Yes, that may be the reason but I do not know how to add permisions to write to that file to nodered user. I have tried to add sudo chmod 777 after ther USER root in dockerfile and also tried to chown node-red in host OS both with no success. Only thing that worked is chmod 777 in host OS. Do you have any idea how to set this differently or more safe?

@imrehg
Copy link
Contributor

imrehg commented Mar 22, 2019

You are already running a privileged container, not sure what's the reason you are trying to switch the user. As you see in this project as well, that the user is not switched. I think the main way to solve this to use a root user as you already do in the other two containers anyways.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants