How to cleanly reboot core OS when "Failed to talk to init daemon" is seen? - coreos

How do I cleanly reboot my coreOS after the following issue shows up?
core#node2 ~ $ sudo reboot
Failed to talk to init daemon
core#node2 ~ $ sudo shutdown -r now
Failed to talk to init daemon.
core#node2 ~ $ sudo systemctl reboot
Failed to get D-Bus connection: Operation not permitted
core#contiv-node2 ~ $ shutdown
Must be root.
core#node2 ~ $ sudo shutdown
Unable to perform operation without bus connection.
core#node2 ~ $ cat /etc/lsb-release
DISTRIB_ID=CoreOS
DISTRIB_RELEASE=991.2.0
DISTRIB_CODENAME="Coeur Rouge"
DISTRIB_DESCRIPTION="CoreOS 991.2.0 (Coeur Rouge)"

sudo reboot -f
-f, --force
Force immediate halt, power-off, reboot. Do not contact the init system.

kill -15 1
That should wake up the init daemon and then you should be able to reboot as normal. (i.e. sudo kill -15 1; sudo reboot)
If possible, this is a better solution than reboot -f as you will be able to perform a clean reboot.

Related

Can't add user to docker group

I'm trying to set docker up on a new system, and when running docker info I get:
docker -v
=> Docker version 18.09.5, build e8ff056
docker info
=> Got permission denied while trying to connect to the Docker daemon
socket at unix:///var/run/docker.sock: Get
http://%2Fvar%2Frun%2Fdocker.sock/v1.39/info: dial unix
/var/run/docker.sock: connect: permission denied
Following the docs, I've tried:
sudo usermod -a -G docker $USER
Which returns no output. When I then run groups:
groups
=> mark adm cdrom sudo dip plugdev lpadmin sambashare
I can see a docker group exists:
less /etc/group | grep docker
=> docker:x:131:mark
And can see that it owns a socket running where the error message states:
ls -la /var/run/ | grep docker
=>
drwx------ 5 root root 120 May 25 14:54 docker
-rw-r--r-- 1 root root 5 May 25 14:54 docker.pid
srw-rw---- 1 root docker 0 May 25 14:54 docker.sock
So why can't I add myself to that group with sudo usermod -a -G docker $USER ?
You need to reload your shell in order to make the changes take effect.
Often you need to reboot your shell process and possibly even restart your computer.
e.g
sudo usermod -aG docker $USER
sudo reboot
See #4Z4T4R answer and give a thumbs
https://stackoverflow.com/a/66297855/7961500
Load changes without quitting your shell
To avoid starting a new shell you can run. (Doesn't seem to work for all environments)
exec su -l $USER
This will create a new subshell with the loaded changes and replace your current shell with it.
If nothing else is working for you.
Another way if you just need to get it working now, is to change your primary group. This is only a temp solution as with any new shell you will need to apply it again.
export my_group=$(id -gn)
newgrp docker
newgrp $my_group
Documentation
You can also look at the offical documentation here
https://docs.docker.com/engine/install/linux-postinstall/
In my case, on Ubuntu 20.04, run sudo reboot after this command:
$ sudo usermod -aG docker $USER
I literally needed to reboot my operating system (and machine) for the change to take effect. Restarting/reloading the bash session did not apply the new setting.
Sure, newgrp docker does the trick "on the fly" without restart/reboot/re-anything... but once the session terminates, POOF you're not in the docker group any longer.
Added this as a formal answer bc it genuinely solved the OP's---and my (identical)---problem.
Credit should go to #Omari Celestine for the suggestion, but because I suck at interpretation, I (and maybe you) need the literal disambiguation that this answer provides.
Its a two step process technically. Run
sudo usermod -aG docker $USER
then,
sg docker -c "bash"
Change the permissions on the /var/run/docker.sock file and restart docker process.
sudo chown jenkins:jenkins /var/run/docker.sock
sudo 644 /var/run/docker.sock
Then,
sudo service docker restart
Before running $docker info, Please make sure that the docker service up.
If not pls start the service by running below command.
$service docker start
Now you check the $docker info

How to run commands on CentOS reboot

I want to run the following commands one after the other upon reboot of the server after I do shutdown -r now but not sure how to do it:
getenforce
setenforce 0
systemctl start httpd.service
I'm running CentOS 7.x
Technically you can crontab it
sudo crontab -e
and add the line
#reboot /somewhere/myscript.sh
and put the 3 commands in the myscript.sh with the proper rights.
But it is a bad idea since you can you just make these changes permanent:
systemctl enable httpd
and
vim /etc/selinux/config
to set the SELINUX variable to permissive
This will make the configuration permanent across reboot.

limits.conf not taking effect

I have been trying to open oracle db. It gives below error.
ORA-27515: inadequate memlock limit
So I put below lines in limits.conf.
* soft memlock 60397977
* hard memlock 60397977
However even after reboot, it doesn't take effect.
Both these files contains below line ./etc/pam.d/su and /etc/pam.d/sshd:
session required pam_limits.so
Figured out that UsePam was set 'no' in /etc/ssh/sshd_config file.
I made it 'yes', rebooted the node and it worked.
Add:
UsePAM yes to your /etc/ssh/sshd_config
and
You don't need to reboot. Just restart sshd service.
You restart by one of the following commands:
Debian/Ubuntu
sudo systemctl restart ssh.service
OR
sudo systemctl restart ssh
Red Hat/CentOS
sudo systemctl restart sshd.service
OR
sudo systemctl restart sshd
macOS
sudo launchctl unload /System/Library/LaunchDaemons/ssh.plist then sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist
FreeBSD/OpenBSD
/etc/rc.d/sshd restart
Credit GH P's answer of adding UsePAM=yes to sshd_config.

Sudo command from remote/CI platform does not work

I am able to run sudo command for my user on a linux server.
But when I run the same command from another (Jenkins CI console) to the same Linux server.
it says "sudo: sorry, you must have a tty to run sudo"
My command is like this,
echo ${somePassword} | sudo -S chown someUser /someFile.war

Is there any way to remove and insert network module remotely without losing connection?

I need to ssh to the server, remove the original network driver and insert a new one, but after I remove the original one, the connection will lose.
Is there any way to do it without losing connection.
The thing I want to do is:
$ ssh user#server
$ sudo rmmod igb
$ sudo insmod ./igb.ko
P.S., igb is the driver for one of Intel ethernet network card.
Thanks in advance.
Check this:
$ ssh user#server
$ sudo rmmod igb; sudo insmod ./igb.ko
Here the SSH server in the server will receive both the both commands even before executing the first command.

Resources