Hi!
I want before login with "rc.local" the command /bin/chattr +i or /bin/chattr +a /path/to/file
"rc.local"
#!/bin/sh
mount -t ramfs -o rw,size=1024M ramfs /path/to/folder
/bin/sleep 4
/bin/tar xvzf /path/to/file.tar.gz -C /path/to/folder
/bin/sleep 4
/bin/chattr +a /path/to/file
/bin/sleep 2
exit 0
chattr +a don't set the +a attribute. chattr can't set the attribute of the file, because
error message says the file is not there, but the file is there.
When I set it manually, then it works.
What's wrong?
I think the target file is in the /path/to/folder dir (which you created when you extracted the tarball)
I don't know what is wrong about the chattr command on rc.local at boot.
I made a test.
Added to rc.local
/bin/chattr +ai /opt/test
Rebooted
Nothing changed on the test file.
Chattr don't write its +ai attribute to the test file.
Is rc.local.service enabled and running?
usually the script goes into /etc/rc.local and is +x
rc-local.service is disabled.
/etc/rc.local is +x
with rc-local.service enabled, it don't works too. Chattr says there is no valid path, but the path is correct to the file.
I created a file, /opt/mate2go
lsattr /opt/mate2go shows --------------e----
Then I created /etc/rc.local with
#!/bin/bash
/bin/chattr +ai /opt/mate2go
chmod 755 /etc/rc.local
systemctl start rc.local.service
reboot
lsattr /opt/mate2go shows `----ia--------e----`
Does this help?
That doesn't work on me.
Chattr does not set any attributes after the boot with rc.local.
My other commands in rc.local are working, only chattr does not.
It works manually.
here's my /etc/rc.local
#!/bin/sh
touch /opt/mate2go
lsattr /opt/mate2go | logger
chattr +ai /opt/mate2go
lsattr /opt/mate2go | logger
chattr -ai /opt/mate2go
lsattr /opt/mate2go | logger
reboot
cat /var/log/syslog | grep mate2go
if you dont see 3 lines how the attributes changed, something else is wrong with your script.
Can you post your /etc/rc.local ?
#!/bin/sh
/bin/chattr +ai /opt/test-file
exit
When I test it, on boot rc.local don't run chattr, manually in terminal chattr works.
My other commands in my rc.local are working on boot.
can you post the output of ..
systemctl status rc.local.service
and ls -l /etc/rc.local
systemctl status rc.local.service and ls -l /etc/rc.local
Output:
Unit and.service could not be found.
Unit ls.service could not be found.
Unit etc-rc.local.mount could not be found.
● rc-local.service - /etc/rc.local Compatibility
Loaded: loaded (/etc/systemd/system/rc-local.service; enabled; vendor preset: enabled)
Drop-In: /lib/systemd/system/rc-local.service.d
└─debian.conf
Active: active (exited) since Wed 2019-06-19 09:08:37 CEST; 9h ago
???
Unit and.service could not be found.
Unit ls.service could not be found.
Unit etc-rc.local.mount could not be found.
they were two separate commands, it seems you typed the whole line.
systemctl status rc.local.service
ls -l /etc/rc.local
From your output, I do not see a Process running ... maybe stop the service and restart it.
systemctl status rc.local.service
rc-local.service - /etc/rc.local Compatibility
Loaded: loaded (/etc/systemd/system/rc-local.service; enabled; vendor preset: enabled)
Drop-In: /lib/systemd/system/rc-local.service.d
└─debian.conf
Active: active (exited) since Thu 2019-06-20 09:46:34 CEST; 2min 24s ago
ls -l /etc/rc.local
-rwxr-xr-x 1 root root 2957 Jun 19 18:19 /etc/rc.local
My other commands on boot in rc.local are working. Sorry, I don't want show my other commands in rc.local here.
Only chattr command on boot in rc.local don't work.
your output of the status of rc.local is different from what I have (UM 19.04).
My screenshot. Which Ubuntu Mate are you running?
Ubuntu Mate 18.04 v2 LTS (4.15.0-51-generic)
I made a minimal UM18.04 VM, created /etc/rc.local, added chattr +ai /opt/mate2go, made it +x, enabled the service, and it worked. The only issue I see is the Loaded: line shows /lib/systemd/system/rc-local.service but yours shows /etc/systemd/system/rc-local.service
Is there an rc-local.service in /etc/systemd/system/ ? I do not have such a file in /etc
My output shows 3 lines, Active: Docs: Process: but yours shows 1 line, Active:
Should I move "rc-local. service" to "/lib/systemd/system"?
Chattr command not working on my ramdisk "ramfs".
