date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,295,035,247,000 |
I was going through a tutorial on setting up a custom initramfs where it states:
The only thing that is missing is /init, the executable in the root of
the initramfs that is executed by the kernel once it is loaded.
Because sys-apps/busybox includes a fully functional shell, this means
you can write your /init binary as a simple shell script (instead of
making it a complicated application written in Assembler or C that you
have to compile).
and gives an example of init as a shell script that starts with #!/bin/busybox sh
So far, I was under the impression that init is the main process that is launched and that all the other user space process are eventually children of init. However, in the given example, the first process is actually bin/busybox/ sh from which later init is spawned.
Is this a correct interpertation? If I were, for example, have a available interpreter available at that point, I could write init as a Python script etc.?
|
init is not "spawned" (as a child process), but rather exec'd like this:
# Boot the real thing.
exec switch_root /mnt/root /sbin/init
exec replaces the entire process in place. The final init is still the first process (pid 1), even though it was preceded with those in the Initramfs.
The Initramfs /init, which is a Busybox shell script with pid 1, execs to Busybox switch_root (so now switch_root is pid 1); this program changes your mount points so /mnt/root will be the new /.
switch_root then again execs to /sbin/init of your real root filesystem; thereby it makes your real init system the first process with pid 1, which in turn may spawn any number of child processes.
Certainly it could just as well be done with a Python script, if you somehow managed to bake Python into your Initramfs. Although if you don't plan to include busybox anyway, you would have to painstakingly reimplement some of its functionality (like switch_root, and everything else you would usually do with a simple command).
However, it does not work on kernels that do not allow script binaries (CONFIG_BINFMT_SCRIPT=y), or rather in such a case you'd have to start the interpreter directly and make it load your script somehow.
| Can the init process be a shell script in Linux? |
1,295,035,247,000 |
In this question, the accepted answers states that
For example, /sbin/init uses glibc [the vulnerable lib], and restarting that without a reboot is non-trivial.
Now, non-trivial is engineer'ish for impossible, but I'm still curious:
Is it possible to restart init without restarting the whole system?
|
telinit u
will restart init without affecting the rest of the system.
| Restarting init without restarting the system |
1,295,035,247,000 |
I want to run one sysvinit script before another and figured out how to do that.
To make sure, this actually happens in the the order I like, I would like to see a list, in which order that happens.
I found sudo insserv --showall already, but can't make head or tail of it, since it lists init scripts multiple times.
How to find out in which order /etc/init.d scripts are load on Debian?
|
There's some files in /etc/init.d/ directory:
$ ls -al /etc/init.d/ | grep -i depend
-rw-r--r-- 1 root root 2739 Feb 17 05:20 .depend.boot
-rw-r--r-- 1 root root 2221 Feb 17 05:20 .depend.start
-rw-r--r-- 1 root root 1855 Feb 17 05:20 .depend.stop
Whenever you run update-rc.d the files will change. .depend.boot file is for S level, .depend.start is for 2 3 4 5 levels and .depend.stop for 0 1 6.
In my case, I have the following order in .depend.start:
TARGETS = killprocs motd nvidia-kernel nfs-common rsyslog privoxy virtualbox
linuxlogo acpi-fakekey binfmt-support fancontrol openvpn hddtemp cgconfig
dropbox-container dbus dnscrypt-proxy pulseaudio atd cryptmount exim4
qbittorrent-nox ddclient acpi-support smartmontools ssh ntp loadcpufreq acpid
cron rsync cgrulesengd cpufrequtils bootlogs bootchart-done single rmnologin
rc.local stop-bootlogd
You can also see why the order presents in the way you see above. Each next line looks like this:
cgrulesengd: rsyslog cgconfig
which means that cgrulesengd needs rsyslog cgconfig to be started prior.
| How to find out in which order /etc/init.d scripts are load on Debian? |
1,295,035,247,000 |
I'm stuck in the boot and can't open any terminal. When I try to boot my laptop it shows the following error:
Gave up waiting for root device. Common problems:
-Boot args (cat /proc/cmdline)
-Check rootdelay= (did the system wait long enough?)
-Missing modules (cat /proc/modules; ls /dev)
ALERT! UUID=718ed077-947d-4018-80ad-59825678e81d does not exist. Dropping to a shell!
BusyBox v1.27.2 (Ubuntu 1:1.27.2-2ubuntu3.2) built-in shell (ash)
Enter 'help' for a list of built-in commands.
(initramfs)_
I tried to follow these steps mentioned in this link (https://forums.linuxmint.com/viewtopic.php?t=47594). They changed root=UUID=9c05139c-b5bb-4683-a860a7bdf456ccda ro quiet splash to
root=/dev/sda5 (i used my UUID and /dev/sda1), but then the error becomes:
-Missing modules (cat /proc/modules; ls /dev)
ALERT! root=/dev/sda1 does not exist. Dropping to a shell!
(I tried to find out my root partition where I installed ubuntu, but i can't run fdisk command in initramfs and also i tried running
(initramfs) cat /proc/cmdline
BOOT_IMAGE=/boot/vmlinuz-5.3.0-53-generic root=UUID=718ed077-947d-4018-80ad-59825678e81d ro quiet splash
and
(initramfs) cat /proc/modules
(shows nothing)
)
This is where I changed the root=UUID=718ed077-947d-4018-80ad-59825678e81d ro quiet splash to
root=/dev/sda1 (only the line started with linux)
|
Your empty output from cat /proc/modules indicates you have no kernel modules loaded, so something has gone wrong with either initrd file generation when installing your current kernel, or with hardware detection as the kernel starts up.
You might try running modprobe ahci to try and force loading the standard AHCI SATA driver, but I'd expect it to just tell you that the module ahci was not found.
If you have other kernel versions available in your GRUB boot menu, now would be a good time to try them. If the GRUB boot menu has "Advanced options for " item, select it: it should bring up a sub-menu of all kernel versions you have installed. Typically there are two boot menu items for each kernel version: one normal boot and another for booting into recovery mode. If there is a kernel version older than 5.3.0-53 available, try the normal (non-recovery mode) option for it.
If the system now boots up normally, it confirms that there was a problem with creating the initrd file during the installation of the latest kernel update. But that should be fairly easy to fix: first run sudo apt-get clean to clean up the package manager's cache: anything in that cache can just be downloaded again if necessary, and over time the cache can sometimes grow very large, so cleaning it up is a good first step.
Then run df -h and make sure that any of the filesystems on your system disks is not 100% full. Finally run sudo update-initramfs -k 5.3.0-53-generic -u to re-build the initramfs file for the kernel version 5.3.0-53. If that command completes without any error messages, you should now be able to boot normally with the latest kernel version you have.
| Missing modules (cat /proc/modules; ls /dev) and UUID doesn't exist in BusyBox |
1,295,035,247,000 |
On multiple computers running Ubuntu 14.XX, I ran the command "killall init" as user, and was immediately logged out. I could log back in again without a problem. Why is this? What's going on behind the scenes?
|
On newer Upstart systems, a session init process is started when you login using the GUI. Since Ubuntu uses Upstart, there's an init process for your session. Test it out using pstree -ps $$ in a terminal:
$ pstree -ps $$
init(1)───lightdm(1741)───lightdm(9511)───init(9526)───/usr/bin/termin(9570)─┬─gnome-pty-helpe(9734)
└──zsh(7944)
So when you run killall init, you're not killing init PID 1 (because you don't have the privilege), but your session init, which would be PID 9526 in this example.
Since this init is the governing process for your GUI session, killing it kills your session and therefore you are logged out.
| Why does running `killall init` as user log me out? |
1,295,035,247,000 |
I managed to create a small and fully functional live Linux CD which contains only kernel (compiled with default options) and BusyBox (compiled with default options + static, all applets present, including /sbin/init). I had no issues to create initrd and populate /dev, /proc and /sys and also I had no issues at all with my /init shell script.
Recently I read that BusyBox supports /etc/inittab configurations (at least to some level) and I very much would like to do either of the following:
Forget about my /init shell script and rely entirely on /etc/inittab configuration.
Use both /init shell script and /etc/inittab configuration.
Now the actual problem - it seems that /etc/inittab is completely ignored when my distro boots up. The symptoms are:
When I remove /init and leave only /etc/inittab I end up with kernel panic. My assumption is that kernel doesn't execute /sbin/init at all, or that /sbin/init doesn't find (or read) /etc/inittab.
I read that BusyBox should work fine even without /etc/inittab. So, I removed both /init and /etc/inittab and guess what - kernel panic again.
I tried to execute /sbin/init from my shell and after several guesses which included exec /sbin/init, setsid /sbin/init and exec setsid /sbin/init I ended up with kernel panic. Both with and without /etc/inittab being present on the file system.
Here is the content of my /init shell script:
#!/bin/sh
dmesg -n 1
mount -t devtmpfs none /dev
mount -t proc none /proc
mount -t sysfs none /sys
setsid cttyhack /bin/sh
At this point I don't care what the content of the /etc/inittab would be, as long as I have a way to know that the configuration there actually works. I tried several /etc/inittab configurations, all based on the information which I found here.
As a bare minimum my /etc/inittab contained just this one line:
::sysinit:/bin/sh
Again - I ended up with kernel panic and it seems that /etc/inittab was ignored.
Any suggestions how to force my little live distro to work fine with BusyBox's /etc/inittab are highly appreciated!
Update:
Just to make it clear - I do not have kernel panic troubles with my current /init shell script both with and without /etc/inittab. It all works fine, my /bin/ash console works great and I don't experience any unexpected troubles. The only issue is that /etc/inittab is completely ignored, as I described above.
I examined 3 different live Linux distributions: Slax, Finnix and SysResCD. All of them have /init and none of them have /etc/inittab. In addition this Wiki article concludes my suspicion that /sbin/init is not invoked at all.
|
OK, I did a lot of extensive research and I found out what was wrong. Let's start one by one:
When we use initramfs boot scheme the first process which the kernel invokes is the /init script. The kernel will never try to execute /sbin/init directly.
/init is assigned process identifier 1. This is very important!
The problem now is that /sbin/init can only be started as PID 1 but we are already running /init as PID 1.
The solution is to execute the command line exec /sbin/init while we are still inside /init. In this way the new process (which is /sbin/init) will inherit the PID from its parent (/init with PID 1) and that's all we have to do.
The problem I experienced with my initial configuration (see the question) was due to the fact that the last thing my /init script does is to spawn new /bin/sh process which is assigned brand new PID. From this point it's impossible to run /sbin/init directly from interactive console because even when we execute the command line exec /sbin/init, the best we achieve is to assign the same PID which has already been assigned to the shell and this PID is definitely not PID 1.
Long story short - execute the command line exec /sbin/init directly from /init and that's all.
| Minimal Linux with kernel and BusyBox: /etc/inittab is ignored, only /init is executed |
1,295,035,247,000 |
What file in Ubuntu is equivalent to the /etc/inittab file in RedHat?
In RedHat the /etc/inittab file contains the settings related to the runlevel in which you want to boot Linux.
|
Ubuntu uses Upstart, an alternative to sysvinit, which works completely differently. The Upstart CookBook discusses runlevels and how to work with them.
Generally, though, the RedHat concept of runlevels isn't used on Debian or derivatives, including Ubuntu; they have only "single user" or "everything running", without any of the "network, but not graphics" style distinctions that RedHat draws.
| File in Ubuntu equivalent to /etc/inittab file in RedHat |
1,295,035,247,000 |
I found lots of good documentation for ubuntu's start-stop-daemon and there is a man page for a binary daemon.
But from what I can tell the canonical way to start a daemon in a rhel/centos script is to source /etc/init.d/functions then use the daemon() function. But I can't find any good examples or documentation.
What is the canonical way to start a daemon in rhel/centos-6 init script?
my first attempt was:
#!/bin/bash
source /etc/init.d/functions
daemon --user USER nohup /path/to/your/binary arg1 arg2 >/dev/null 2>&1 &
|
The documentation and example you are looking for is located at /usr/share/doc/initscripts-*/sysvinitfiles on CentOS/RHEL. Here is the documentation for the daemon function specifically:
daemon [ --check ] [ --user ]
[+/-nicelevel] program [arguments] [&]
Starts a daemon, if it is not already running. Does
other useful things like keeping the daemon from dumping
core if it terminates unexpectedly.
--check <name>:
Check that <name> is running, as opposed to simply the
first argument passed to daemon().
--user <username>:
Run command as user <username>
With CentOS/RHEL 6, you also have the option of using an upstart job file instead of writing a sysv init script.
| what is the canonical way to start a daemon in rhel/centos-6 init script? |
1,295,035,247,000 |
Visiting some forum online that discuss about Debian and Xubuntu, I saw some users that add this line in the signature field:
...With no systemd...
This line is showed with pride (it seems to me).
From Wikipedia:
systemd is a suite of system management daemons, libraries, and utilities designed as a central management and configuration platform for the Linux computer operating system.
So systemd doesn't seem like a bad thing, so why do people write with pride that they don't use it?
Can systemd be dangerous, or just bad for you?
|
No, it is neither dangerous nor bad for you. You have stumbled upon a little battle of the init wars. I will not get into this in detail but, briefly, the situation is as follows.
Linux has been using sysvinit for most of its lifetime. This is old and lacks features and the one thing pretty much everyone agrees on is that it needs to be changed. However, nobody can agree on what it should be changed to. Various alternatives were proposed, including--but not limited to-- the following:
systemd
upstart
Both of these are good in their own way and bad in others. As so often happens in the geek world, the choice of which init system (either one of those two or another) to adopt became something similar to a religious war.
So, you happened to come across someone who dislikes systemd and, therefore, is proud of not using it. There are various people who have the opposite opinion and think that systemd is wonderful and everything else awful. Just like there is on any other subject on the wide and wonderful interwebs.
Happily, the init wars are simmering down and are now past their prime. Most Linux distributions have decided to switch to systemd. Even Canonical's Ubuntu, despite their being the force behind upstart. So, today, systemd is actually the init system of choice for pretty much all major disrtibutions except Gentoo (image source):
| Is systemd "malicious"? [closed] |
1,295,035,247,000 |
I am editing a init.d script. The init.d script runs a utility script which then runs an process. From either bash scripts how would I make it launch the main process as a specific user and group?
|
The simplest way is to use the su(1) command, it has an option that allows you to run a command via the user's shell, example:
su foo -c ls
This will switch to the user foo and run the ls command. If the user you want to use does not have a valid shell (ie it's not in /etc/shells, like /bin/false or /sbin/nologin) you will also have to specify a shell on the command line. Example with output:
# su nobody -s /bin/bash -c id
uid=99(nobody) gid=99(nobody) groups=99(nobody) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
| Launch process as another user/group (in init.d script) |
1,295,035,247,000 |
Say I am writing my own init program running on a Linux kernel.
What happens when my init program exits with return value 0 ?
Additionally is the behaviour different if the return value is non-zero?
|
What happens when my init program exits with return value 0?
This code, from the find_child_reaper function in kernel/exit.c, is run:
panic("Attempted to kill init! exitcode=0x%08x\n",
father->signal->group_exit_code ?: father->exit_code);
And consequently this message appears on your console:
Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000000
| Linux kernel action upon init process exiting |
1,295,035,247,000 |
I just wonder why kill -9 0 ends my tty console session?
What exactly is PID 0, it is not listed on a ps aux?
|
killing 0 isn't killing the pid 0. Instead it is an option in kill to kill all processes in the current group. With your command you are killing everything in the process group ID (GID) of the shell that issued the kill command.
from the kill man page:
pid... Specify the list of processes that kill should signal. Each pid
can be one of five things:
...
0 All processes in the current process group are signaled.
| Why does "kill -9 0" end my console session? |
1,295,035,247,000 |
command init seems to be the first process running after each booting.
If I init in my Ubuntu Gnome terminal, will that restart my OS?
|
If you're not root (and you shouldn't normally be logging in as root), you'll just get a message:
bash$ init
init: Need to be root
if you are root, you can change the current run level of the system using init (it actually runs "telinit" to make the change).
bash$ sudo init
init: missing runlevel
Try `init --help' for more information.
if you really want to reboot your system, you can do it by telling init to switch to run level six:
bash$ sudo init 6
(I'm not actually going to do this because I don't want to really reboot my machine.)
For future reference, all of this stuff is well described in the man pages. Try running man init for example. Other interesting man pages include runlevel and telinit.
| What will happen if I run the command init in my Ubuntu Gnome terminal? |
1,295,035,247,000 |
I am currently working on a project which needs to be added to inittab so that the program loads during startup.
The program that I am trying to start is a c# mono application. I have created a start script and if the start script is run manually the program launches fine. However, when I put it into inittab the program doesn't launch.
I've checked in /var/log/messages but it doesn't say anything is wrong, it just says that it is reloading.
Below is what I have added to my inittab script
bes:2345:respawn:/home/bits/MyProgram/start.myprogram
Thanks for any help you can provide
UPDATE
Below is the code in the start script which is located in /home/bits/MyProgram.
#!/bin/sh
cd /home/bits/MyProgram
/usr/bin/mono EmailServer.exe "$@"
I have also tried adding > mylog.txt onto the end of the line beginning with /usr/bin/mono e.g.
/usr/bin/mono EmailServer.exe "$@" > mylog.txt
If I run the start script manually, even if I am not in the directory where the start script is located it works fine, its just when I add it to inittab and run telinit q it never starts and the log isn't written to but the log does get written to if I start the program manually.
Thanks for any help you can provide.
|
The problem is simple, you are using OpenSuse 12.1 which uses systemd instead of your classic System V boot system.
To install a new service place create following file in /etc/systemd/system/myprogname.service
[Unit]
Description=My progname service file
[Service]
ExecStart=/home/bits/MyProgram
[Install]
WantedBy=multi-user.target
Aftwards run systemctl daemon-reload and systemctl start myprogname.service
If you want to automatically restart MyProgname you have to add
Restart=restart-always
to the service section.
| Add item to inittab on OpenSuse 12.1 |
1,295,035,247,000 |
I have configured the lines in /etc/inittab as follows:
# The default runlevel.
id:2:initdefault:
But after logging in the output of runlevel is as follows:
N 5
So why am I in runlevel 5 instaed of 2?
Note: As an additionaly info here is uname -a output for my system
Linux d3bi4n 3.16.0-4-amd64 #1 SMP Debian 3.16.7-2 (2014-11-06) x86_64 GNU/Linux
and the output of dpkg -S /sbin/init is
systemd-sysv: /sbin/init
|
$ dpkg -S /sbin/init
systemd-sysv: /sbin/init
Your init system is Systemd, not SysVinit. /etc/inittab is a configuration file of SysVinit, it is not used by Systemd. I presume you have this file because this is a jessie system which was upgraded from an earlier jessie or from wheezy with SysVinit.
Systemd doesn't exactly have a concept of runlevels, though it approximates them for compatibility with SysVinit. Systemd has “target units” instead. You can choose the boot-time target unit by setting the symbolic link /etc/systemd/system/default.target. See the Systemd FAQ for more information.
If you don't want to use Systemd, install the sysvinit-core package, which provides a traditional SysVinit (formerly in the sysvinit package, which in jessie is now a front for systemd). As of jessie, Debian defaults to Systemd but still supports SysVinit.
| Why is my Debian jessie always in runlevel 5? |
1,295,035,247,000 |
I never thought about this before, but I was wondering why they chose runlevel 2. Every other distro and OS I've used default to runlevel 3 (with the exception of AIX which also defaults to runlevel 2).
|
The Debian distribution (and hence Ubuntu, which is derived from it) does not define any differences between runlevels 2-5 as a matter of policy. It is up to the local system administrator to make use of runlevels as they see fit.
Since there is no difference between runlevels 2-5, a default runlevel 2 was chosen.
| Why does debian and ubuntu default to runlevel 2? |
1,295,035,247,000 |
I'm running Debian 8 x64 and still learning it. One of the confusing things I've come across repeatedly on Debian and Ubuntu systems is there appear to be two ways of running and managing services:
service
systemctl
I've read through the Debian page on systemd (systemctl) as well as questions such as How does systemd use /etc/init.d scripts?
From what I understand so far, many Linux distributions these days, including Debian and Ubuntu, are moving away from the old SysV (System Five) and embracing systemd.
I can see that my /sbin/init is a symbolic link to /lib/systemd/systemd.
The question is:
If systemd has replaced SysV, why is SysV (service) still there?
Why can I use both seemingly interchangeably? If I start a daemon in one, the other knows about it. How? Which one is running the show?
Is there any real reason to use service any more or should I just stick to systemctl?
|
The service command is a "compatibility" tool to help people migrate from sysvinit to systemd. It's a smart program that tries to work out your current init system and will call sysvinit, upstart or systemd calls as necessary.
Your question is a little "tell the future" in nature; today Debian allows different init systems to work and the service command will try and work it all out. But Debian 9? Who knows what that will support... We could end up with superinit to replace systemd, and the service command will be updated...
The problem is that this solution may not be cross-platform consistent; will service work with CentOS or SuSE? Will systemctl?
If I was writing my own stuff then I'd just stick with systemctl for all systemd based platforms, but have a massive test for all OS variants I support.
| If systemd has replaced SystemV, why is it still there and who is running the show? |
1,295,035,247,000 |
I'm designing an app that will be deployed/installed to a linux machine (perhaps Archlinux, but could be any distro and in fact I would actually prefer something lightweight and inside the Debian family if at all possible). This machine will not be a "general purpose" or multiple application machine: it's sole purpose is to run my app at startup and close my app at shutdown. No other end-user apps would be installed on this machine.
I'm looking for a way to:
When the user powers on the machine, instead of the normal Ubuntu/OS startup --> BIOS --> splash screen --> login process, they just see a splash screen for my app (while the system and app boots up) and then my app loads with its own look and feel
While using the machine, they cannot access any other apps, shells or other part of the operating system; all they have access to is my app
When running, the app takes up the entire screen and its window cannot be minimized or resized
The app (as software) cannot be turned off or killed while running, except...
Turning off the machine (physically powering it down) shuts down the app gracefully and shuts down the underlying OS as well
Hence, the end user never knows that the machine is running on top of linux; to them, the app is the only thing "living" on the machine.
This has to be possible seeing that Android is just a wrapper around Linux, and there are thousands of other devices that just run a single app and nothing more.
This will likely be a C binary that launches a Java desktop application as the actual app.
Any ideas as to how I can accomplish the items mentioned above?
|
I would strongly recommend Archlinux for this task. It manages to strike the delicate balance between installing very few "end-user" applications by default and still leaving a sensible system upon which you can build.
As for steps to take to accomplish your goal, after you have Arch installed, fine-tune what services you want to run at startup (off the top of my head, it sounds like you might want less ttys). After that, install and configure X (that link also has a link to starting X at login, which you will want). If you want a splash screen on-boot, you'll need to setup something like Plymouth. And, finally, systemd tends to handle physical shutdowns (pressing a power button on consumer hardware a single time, for example) pretty gracefully. However, it may be worth considering adding a shutdown function to the app you'll be running.
Your $HOME/.xinitrc might be very basic if you do not need a lot of functionality. E.g.:
exec /path/to/your/program/here
| Dedicated-purpose, single application linux boxes [duplicate] |
1,295,035,247,000 |
What I understand from runlevels is that in each level some programs have permission to be executed and some don't. runlevel 3 boots system into CLI and runlevel 5 starts the default GUI.
But I don't understand what do 0(shutdown) and 6(reboot) mean?(Start in shutdown/reboot mode?!). What happens If set initdefault to these values?
|
If you start in these, the system will shut down/reboot as soon as it enters the runlevel. A runlevel is essentially just a way of specifying actions you want to take when you enter/leave a certain state, in that respect, once those runlevels are entered they execute programs that prepare the computer to shut down or reboot, respectively.
| What happens if I set default system runlevel to 0 or 6? |
1,295,035,247,000 |
I was reading through all the things that are run during bootup and have seen that after mounting the rootfs, /sbin/fsck.ext4 is run and after that systemd is run. I was wondering where or how fsck is run, because I was searching for it in the kernel source code and couldn't find it and its not part of the init scripts. So what runs fsck? The distro I am using is mint.
EDIT: In this image it is shown that fsck is run after mounting the root file sytem
|
Edit 2: checked sources
I've found the ubuntu initramfs-tools sources. Here you can see clearly, the Begin: "Mounting root file system" message is printed first, but in the mount_root function fsck is run before the actual mounting. I have ommited some non-relevant code, just to indicate the order. (If you would inspect the linked sources you will find also the other reported scripts from the screenshot).
/init line 256
log_begin_msg "Mounting root file system"
# Always load local and nfs (since these might be needed for /etc or
# /usr, irrespective of the boot script used to mount the rootfs).
. /scripts/local
. /scripts/nfs
. /scripts/${BOOT}
parse_numeric ${ROOT}
maybe_break mountroot
mount_top
mount_premount
mountroot
log_end_msg
/scripts/local @line 244
mountroot()
{
local_mount_root
}
/scripts/local @line 131
local_mount_root()
{
# Some code ommited
# FIXME This has no error checking
[ -n "${FSTYPE}" ] && modprobe ${FSTYPE}
checkfs ${ROOT} root "${FSTYPE}"
# FIXME This has no error checking
# Mount root
mount ${roflag} ${FSTYPE:+-t ${FSTYPE} }${ROOTFLAGS} ${ROOT} ${rootmnt}
mountroot_status="$?"
if [ "$LOOP" ]; then
if [ "$mountroot_status" != 0 ]; then
if [ ${FSTYPE} = ntfs ] || [ ${FSTYPE} = vfat ]; then
panic "<Error message ommited>"
fi
fi
mkdir -p /host
mount -o move ${rootmnt} /host
# Some code ommitted
}
Original answer, retained for historical reasons
Two options:
Root is mounted read-only during boot and the init implementation is running fsck. Systemd is the init implementation on mint, and since you already checked if it exists there, this option does not apply.
/sbin/fsck.ext4 is run in the "early user space", set up by an initramfs. Which is most probably the case in your system.
Systemd
Even if you noticed that /sbin/fsck.ext4 was run before systemd, I want tot elaborate a bit. Systemd is perfectly capable of running fsck itself, on a read-only mounted filesystem. See [email protected] documentation. Most probably this service is not enabled by default in mint, since it will be redundant with the early user space one.
Initramfs
I don't know which implementation of an initramfs mint is running, but I will use dracut as an example. (used in Debian, openSuse and more) It states the following in its mount preperation documentation:
When the root file system finally becomes visible:
Any maintenance tasks which cannot run on a mounted root file system are done.
The root file system is mounted read-only.
Any processes which must continue running (such as the rd.splash screen helper and its command FIFO) are hoisted into the newly-mounted
root file system.
And maintenance tasks includes fsck. Further evidence, there is a possibility in dracut cmdline options to switch off fsck:
rd.skipfsck
skip fsck for rootfs and /usr. If you’re mounting /usr read-only and the init system performs fsck before remount, you might
want to use this option to avoid duplication
Implementations of initramfs
An dynamic (udev based) and flexible initramfs can be implemented using the systemd infrastructure. Dracut is such an implementation and probably there are distro's out there that want to write their own.
Another option would be a script based initramfs. In such a case busybox ash is used as a scripting shell and maybe even replacing udev with mdev, or maybe just completely static. I found some people being dropped to a busybox shell due to some fsck error int mint, so this implementation could apply to mint.
If you really want to know for sure, try to decompress the initramfs file in /boot and see what's in there. It might also be possible to see it mounted under /initramfs.
| Where is fsck run? |
1,402,867,478,000 |
I have a an inittab file with the following entry:
console::askfirst:-/bin/ash
According to this Man page a '+' character in the process field means
init will not do utmp and wtmp accounting for that process.
However, it does not say anything about a '-' character. What does having the '-' character in the process field do?
|
The hyphen appears to be a Busybox-specific feature (as is "askfirst", which was how I found that you are using Busybox). The example inittab file says:
# /bin/sh invocations on selected ttys
#
# Note below that we prefix the shell commands with a "-" to indicate to the
# shell that it is supposed to be a login shell. Normally this is handled by
# login, but since we are bypassing login in this case, BusyBox lets you do
# this yourself...
#
# Start an "askfirst" shell on the console (whatever that may be)
::askfirst:-/bin/sh
So, it starts the shell as a login shell (by beginning argv[0] with a hyphen). What a login shell means is beyond the scope of this question, but it generally at least means it will execute different startup files (i.e. ~/.profile).
The convention of using a hyphen in argv[0], rather than a proper command line flag, to tell the shell it is a login shell, is an ancient convention - it dates back to at least Second Edition UNIX. (argv[0] was simply "-" for login shells until Sixth Edition, then it was changed to "-/bin/sh")
| inittab '-' character in process field |
1,402,867,478,000 |
After a clean install of Fedora 17 and distcc-server, I did a service distccd start, which completed successfully.
man service indicates that it would merely be running the distccd script at /etc/init.d/distccd, but that file doesn't exist. chkconfig also doesn't appear to know about distccd, which is confirmed by there being no related files in /etc/rc[0-6].d. There does exist a file /etc/sysconfig/distccd that contains run options for the distcc daemon, but I can't seem to find anything linking service to /etc/sysconfig anyway.
How does service know what to do when I type service distccd start?
Also, I have learned that Fedora 17 may redirect service to systemd/systemctl. Even if that is the case, I still don't find any distccd related files in /etc/systemd/{system,user}.
|
/etc/systemd is for user defined services. The default location for system defined services is /lib/systemd/system/. You can overwrite system defined services in /etc/systemd.
For more information about systemd either have a look at the fedora wiki page for systemd or have a look at the systemd documentation
| Why is a service being started if it isn't mentioned in /etc/init.d? |
1,402,867,478,000 |
I'm trying to run a CherryPy app on my NetBSD 5.1 box. To have it start automatically, I've added this line to my /etc/rc.local:
/bin/httpd &
When I boot the machine, some of the output of the Webserver starting is visible, right after the Starting sshd. message. None the less, I can't connect to my web-server.
I can log into the machine, and when I start the web-server by typing httpd, it all works well. What am I doing wrong? What is the correct way to have my program start on boot-time?
|
The program will exit as soon as the rc.local script is finished. So, here's the complete procedure that doesn't require the program to understand any of the rc.d stuff:
Make the script executable (e.g. chmod a+x /usr/local/bin/httpd)
Add the following line to your /etc/rc.local:
nohup /usr/local/bin/httpd &
| How do I start my service at boot-time? |
1,402,867,478,000 |
The documentation I have read on systemd unit files states that unit files can be found in three locations on the filesystem:
/etc/systemd/system/: system unit files
/run/systemd/system/: runtime unit files
/lib/systemd/system/ (also sometimes /usr/lib/systemd/system/): default unit files for packages
I understand that system unit files are for (possibly user-configured) system daemons. I also understand that default package unit files are unit files that come along with package installs that provide sane defaults.
However, I cannot find documentation that explains the purpose of runtime unit files. What are runtime unit files for? Might I, as a sysadmin, ever create one? What are some examples of problems that might be solved with runtime unit files? Why do runtime unit files take precedence over package unit files, but not over system unit files?
|
Historically, runtime unit files are intended for machine-generated units. They are supposed to override corresponding vendor units (if any), but are designed to allow user overrides, hence the defined precedence.
Nowadays I think they’ve largely been supplanted by transient units generated using the bus API; these don’t appear as files anywhere.
| What are systemd runtime unit files for? |
1,402,867,478,000 |
From When the operating system shuts down, how does a service manager know that it should sends SIGTERM and SIGKILL to its services?
systemd IS BOTH the init and service manager
What is the difference between "init" and "service manager"?
I guess they are the same thing?
What is some example which is "the init" but not "service manager"? Vice versa?
Thanks.
|
init is (usually) the first process started by the system. It has a couple of special responsibilities, including (but not limited to:
Starting whatever other userspace processes are necessary to finish the boot up process.
Handling the final shutdown of the system (init is what ultimately tells the kernel to power off or reboot once everything in userspace is shut down).
Adopting orphaned processes (processes which no longer have a running parent process) and cleaning up after them.
A service manager, on the other hand, is solely responsible for ensuring a given set of services are running, and optionally that they keep running. The exact approach to this can vary from rudimentary scripts that just track dependencies among services, to complex systems that automatically manage dependencies.
The original SVR4 init implementation (which is the basis for both the classic systemv-init packages on most Linux distributions, the Busybox init applet, and the BSD and Solaris init programs) actually included rudimentary service management. It let you define programs which it would automatically start at boot, and restart if they exited. As a result of this, it's actually pretty hard to find an init implementation on a UNIX-like system that isn't also a rudimentary service manager, and this baseline level of service management is largely implied to be part of the init process's job.
On the other hand, you can easily have a service manager that isn't an init implementation. The classic BSD rc.d scripts are an example of a really simple service manager (they handle starting and stopping services, and provide rudimentary dependency management), and they formed the basis of the concept of /etc/init.d on Linux. A more complex example is monit, which adds state tracking, automatic restart capabilities, alerting, and some system monitoring support to the basic functionality.
| What is the difference between "init" and "service manager"? |
1,402,867,478,000 |
If I tell my system to go to run level 3 does that mean that it first runs through run level 0, 1, 2, and then finally runs through run level 3?
I thought the answer to this question was yes. But when I look on my RHEL 6 system I see that many of rcX.d directories contain same symbolic links.
In My /etc/rc.d/rc0.d/
[root@centos6 rc.d]# ls -lah /etc/rc.d/rc0.d/
total 8.0K
drwxr-xr-x. 2 root root 4.0K Jun 27 11:59 .
drwxr-xr-x. 10 root root 4.0K Jul 9 15:06 ..
lrwxrwxrwx. 1 root root 13 Jun 12 13:02 K05atd -> ../init.d/atd
lrwxrwxrwx. 1 root root 14 Jun 12 13:01 K10cups -> ../init.d/cups
lrwxrwxrwx. 1 root root 19 Jun 12 10:57 K10saslauthd -> ../init.d/saslauthd
lrwxrwxrwx. 1 root root 18 Jun 12 12:51 K15svnserve -> ../init.d/svnserve
lrwxrwxrwx. 1 root root 14 Jun 12 10:58 K25sshd -> ../init.d/sshd
lrwxrwxrwx. 1 root root 17 Jun 12 10:57 K30postfix -> ../init.d/postfix
lrwxrwxrwx. 1 root root 17 Jun 12 12:26 K50dnsmasq -> ../init.d/dnsmasq
lrwxrwxrwx. 1 root root 20 Jun 12 10:57 K50netconsole -> ../init.d/netconsole
lrwxrwxrwx. 1 root root 15 Jun 12 10:57 K60crond -> ../init.d/crond
lrwxrwxrwx. 1 root root 25 Jun 27 11:59 K65vboxadd-service -> ../init.d/vboxadd-service
lrwxrwxrwx. 1 root root 17 Jun 27 11:58 K70vboxadd -> ../init.d/vboxadd
lrwxrwxrwx. 1 root root 21 Jun 27 11:59 K70vboxadd-x11 -> ../init.d/vboxadd-x11
lrwxrwxrwx. 1 root root 17 Jun 12 12:26 K73winbind -> ../init.d/winbind
lrwxrwxrwx. 1 root root 19 Jun 12 12:26 K74haldaemon -> ../init.d/haldaemon
lrwxrwxrwx. 1 root root 26 Jun 12 10:58 K75blk-availability -> ../init.d/blk-availability
lrwxrwxrwx. 1 root root 15 Jun 12 11:15 K75netfs -> ../init.d/netfs
lrwxrwxrwx. 1 root root 19 Jun 12 10:57 K75udev-post -> ../init.d/udev-post
lrwxrwxrwx. 1 root root 24 Jun 12 12:26 K84NetworkManager -> ../init.d/NetworkManager
lrwxrwxrwx. 1 root root 24 Jun 27 11:59 K84wpa_supplicant -> ../init.d/wpa_supplicant
lrwxrwxrwx. 1 root root 19 Jun 12 10:58 K85mdmonitor -> ../init.d/mdmonitor
lrwxrwxrwx. 1 root root 20 Jun 12 12:25 K85messagebus -> ../init.d/messagebus
lrwxrwxrwx. 1 root root 20 Jun 12 10:58 K87multipathd -> ../init.d/multipathd
lrwxrwxrwx. 1 root root 21 Jun 12 10:57 K87restorecond -> ../init.d/restorecond
lrwxrwxrwx. 1 root root 16 Jun 12 10:58 K88auditd -> ../init.d/auditd
lrwxrwxrwx. 1 root root 15 Jun 27 11:59 K88iscsi -> ../init.d/iscsi
lrwxrwxrwx. 1 root root 17 Jun 12 10:57 K88rsyslog -> ../init.d/rsyslog
lrwxrwxrwx. 1 root root 16 Jun 12 10:58 K89iscsid -> ../init.d/iscsid
lrwxrwxrwx. 1 root root 21 Jun 12 13:01 K89portreserve -> ../init.d/portreserve
lrwxrwxrwx. 1 root root 15 Jun 12 11:15 K89rdisc -> ../init.d/rdisc
lrwxrwxrwx. 1 root root 17 Jun 12 11:15 K90network -> ../init.d/network
lrwxrwxrwx. 1 root root 19 Jun 12 10:57 K92ip6tables -> ../init.d/ip6tables
lrwxrwxrwx. 1 root root 18 Jun 12 10:57 K92iptables -> ../init.d/iptables
lrwxrwxrwx. 1 root root 22 Jun 12 10:58 K99lvm2-monitor -> ../init.d/lvm2-monitor
lrwxrwxrwx. 1 root root 17 Jun 12 11:15 S00killall -> ../init.d/killall
lrwxrwxrwx. 1 root root 14 Jun 12 11:15 S01halt -> ../init.d/halt
lrwxrwxrwx. 1 root root 15 Jun 26 12:32 S95jexec -> ../init.d/jexec
And in /etc/rc.d/rc1.d/ I see the same set of symbolic links as in rc0.d plus extra links. This seems to indicate that the directories rc0.d, rc1.d are independent and that to get to run level 1 it does not execute the stuff in run level 0. Which means that bad things can happen if some how the symbolic links in rc0.d were not exactly replicated in rc1.d, ... etc.
So how does it really work? Does it just scan the files in a specific rc.X dir or run through all rc.X dirs that have a lower level than rc level passed to init?
[root@centos6 rc.d]# ls -lah /etc/rc.d/rc1.d/
total 8.0K
drwxr-xr-x. 2 root root 4.0K Jun 27 11:59 .
drwxr-xr-x. 10 root root 4.0K Jul 9 15:06 ..
lrwxrwxrwx. 1 root root 13 Jun 12 13:02 K05atd -> ../init.d/atd
lrwxrwxrwx. 1 root root 14 Jun 12 13:01 K10cups -> ../init.d/cups
lrwxrwxrwx. 1 root root 19 Jun 12 10:57 K10saslauthd -> ../init.d/saslauthd
lrwxrwxrwx. 1 root root 18 Jun 12 12:51 K15svnserve -> ../init.d/svnserve
lrwxrwxrwx. 1 root root 14 Jun 12 10:58 K25sshd -> ../init.d/sshd
lrwxrwxrwx. 1 root root 17 Jun 12 10:57 K30postfix -> ../init.d/postfix
lrwxrwxrwx. 1 root root 17 Jun 12 12:26 K50dnsmasq -> ../init.d/dnsmasq
lrwxrwxrwx. 1 root root 20 Jun 12 10:57 K50netconsole -> ../init.d/netconsole
lrwxrwxrwx. 1 root root 15 Jun 12 10:57 K60crond -> ../init.d/crond
lrwxrwxrwx. 1 root root 25 Jun 27 11:59 K65vboxadd-service -> ../init.d/vboxadd-service
lrwxrwxrwx. 1 root root 17 Jun 27 11:58 K70vboxadd -> ../init.d/vboxadd
lrwxrwxrwx. 1 root root 21 Jun 27 11:59 K70vboxadd-x11 -> ../init.d/vboxadd-x11
lrwxrwxrwx. 1 root root 17 Jun 12 12:26 K73winbind -> ../init.d/winbind
lrwxrwxrwx. 1 root root 19 Jun 12 12:26 K74haldaemon -> ../init.d/haldaemon
lrwxrwxrwx. 1 root root 15 Jun 12 11:15 K75netfs -> ../init.d/netfs
lrwxrwxrwx. 1 root root 24 Jun 12 12:26 K84NetworkManager -> ../init.d/NetworkManager
lrwxrwxrwx. 1 root root 24 Jun 27 11:59 K84wpa_supplicant -> ../init.d/wpa_supplicant
lrwxrwxrwx. 1 root root 19 Jun 12 10:58 K85mdmonitor -> ../init.d/mdmonitor
lrwxrwxrwx. 1 root root 20 Jun 12 12:25 K85messagebus -> ../init.d/messagebus
lrwxrwxrwx. 1 root root 20 Jun 12 10:58 K87multipathd -> ../init.d/multipathd
lrwxrwxrwx. 1 root root 21 Jun 12 10:57 K87restorecond -> ../init.d/restorecond
lrwxrwxrwx. 1 root root 16 Jun 12 10:58 K88auditd -> ../init.d/auditd
lrwxrwxrwx. 1 root root 15 Jun 27 11:59 K88iscsi -> ../init.d/iscsi
lrwxrwxrwx. 1 root root 17 Jun 12 10:57 K88rsyslog -> ../init.d/rsyslog
lrwxrwxrwx. 1 root root 16 Jun 12 10:58 K89iscsid -> ../init.d/iscsid
lrwxrwxrwx. 1 root root 21 Jun 12 13:01 K89portreserve -> ../init.d/portreserve
lrwxrwxrwx. 1 root root 15 Jun 12 11:15 K89rdisc -> ../init.d/rdisc
lrwxrwxrwx. 1 root root 17 Jun 12 11:15 K90network -> ../init.d/network
lrwxrwxrwx. 1 root root 19 Jun 12 10:57 K92ip6tables -> ../init.d/ip6tables
lrwxrwxrwx. 1 root root 18 Jun 12 10:57 K92iptables -> ../init.d/iptables
lrwxrwxrwx. 1 root root 22 Jun 12 10:58 S02lvm2-monitor -> ../init.d/lvm2-monitor
lrwxrwxrwx. 1 root root 26 Jun 12 10:58 S25blk-availability -> ../init.d/blk-availability
lrwxrwxrwx. 1 root root 19 Jun 12 10:57 S26udev-post -> ../init.d/udev-post
lrwxrwxrwx. 1 root root 15 Jun 26 12:32 S95jexec -> ../init.d/jexec
lrwxrwxrwx. 1 root root 16 Jun 12 11:15 S99single -> ../init.d/single
|
When you switch runlevel, the only things executed are the scripts in /etc/rc.d/rc${NEW_LEVEL}.d/.
This means that you are right: Every rc*.d directory needs to be able to handle all of the process/service changes when switching from another runlevel. So every rc directory contains a full set of scripts for reaching that runlevel.
Say you're switching to runlevel 3. The /etc/rc.d/rc3.d/K* scripts will attempt to kill any processes that were running in whatever your previous runlevel was (could be any number), and /etc/rc.d/rc3.d/S* scripts will start any processes that need to be started (and weren't already started in the previous runlevel).
Clearly, managing all of these symlinks would be a real pain, so there are utilities to help manage this. On Debian and Ubuntu (at least, maybe others), you can use update-rc.d to selectively enable/disable scripts found in /etc/init.d, or to set them up to "default" or recommended settings for each script. This will create and update all the symlinks for you, to reflect any configuration changes you want to put in place. On CentOS, I understand you can use ntsysv or chkconfig to do the same thing.
Effectively, you never touch the files in /etc/rc*.d/ (or /etc/rc.d/rc*.d/) yourself; you always use the tool (eg. update-rc.d, ntsysv, chkconfig) to make any changes.
| When running to a run level does it execute previous run levels? |
1,402,867,478,000 |
I start a new process from GNOME Terminal and then this process fork a child.
But when I killed the parent process the orphaned process's parent id became something other than 1 which represent init --user pid.
When I do this in virtual terminals, the parent pid is 1 which represent init process.
How can I execute new process from GNOME Terminal so that when it is died, the child process's parent pid became 1 and not pid of init --user process?
Thanks a lot.
|
I already answered a similar question a few months ago. So see that first for technical details. Here, I shall just show you how your situation is covered by that answer.
As I explained, I and other writers of various dæmon supervision utilities take advantage of how Linux now works, and what you are seeing is that very thing in action, almost exactly as I laid it out.
The only missing piece of information is that init --user is your session instance of upstart. It is started up when you first log in to a session, and stopped when you log out. It's there for you to have per-session jobs (similar, but not identical, to MacOS 10's user agents under launchd) of your own.
A couple of years ago, the Ubuntu people went about converting graphical desktop systems to employ upstart per-session jobs. Your GNOME Terminal is being started as a per-session job, and any orphaned children are inherited by the nearest sub-reaper, which is of course your per-session instance of upstart.
The systemd people have been, in recent months, working on the exact same thing, setting up GNOME Terminal to run individual tabs as separate systemd services, from one's per-user instance of systemd. (You can tell that your question is about upstart, not systemd, because on a systemd system the sub-reaper process would be systemd --user.)
How can I execute a new process from GNOME Terminal so that the child process's parent PID becomes 1 and not the PID of the ubuntu session init process?
This is intentionally hard. Service managers want to keep track of orphaned child processes. They want not to lose them to process #1. So the quick précis is: Stop trying to do that.
If you are asking solely because you think that your process ought to have a parent process ID of 1, then wean yourself off this idea.
If you erroneously think that this is an aspect of being a dæmon, then note that dæmons having parent process IDs of 1 has not been guaranteed (and on some Unices, not true across the whole system) since the advent of things like IBM's System Resource Controller and Bernstein's daemontools in the 1990s. In any case, one doesn't get to be a dæmon by double-forking within a login session. That's a long-since known to be half-baked idea.
If you erroneously think that this is a truism for orphaned child processes, then read my previous answer again. The absolutism that orphaned children are re-parented to process #1 is wrong, and has been wrong for over three years, at the time of writing this.
If you have a child process that for some bizarre reason truly needs this, then find out what that bizarre reason is and get it fixed. It's probably a bug, or someone making invalid design assumptions. Whatever the reason, the world of dæmon management changed in the 1990s, and Linux also changed some several years ago. It is time to catch up.
Further reading
"Session Init". upstart Cookbook. Ubuntu.
James Hunt, Stéphane Graber, Dmitrijs Ledkovs, and Steve Langasek (2012-11-12). "Respawning user jobs and PID tracking". Ubuntu Raring upstart user sessions. Ubuntu.
Nathan Willis (2013-04-17). Upstart for user sessions. LWN.
systemd. systemd manual pages. freedesktop.org.
| Orphan process's parent id is not 1 when parent process executed from GNOME Terminal |
1,402,867,478,000 |
init is the first task executed after kernel is loaded, right?
Then who is its owner.
also I can see [swapper/0] [swapper/1] ..... [swapper/7] having pid 0
PID PPID CPU TASK ST %MEM VSZ RSS COMM
0 0 0 c180b020 RU 0.0 0 0 [swapper/0]
0 2 1 f7550ca0 RU 0.0 0 0 [swapper/1]
0 2 2 f7554bc0 RU 0.0 0 0 [swapper/2]
0 2 3 f7570ca0 RU 0.0 0 0 [swapper/3]
0 2 4 f7574bc0 RU 0.0 0 0 [swapper/4]
0 2 5 f75c8ca0 RU 0.0 0 0 [swapper/5]
0 2 6 f75ccbc0 RU 0.0 0 0 [swapper/6]
0 2 7 f75f0ca0 RU 0.0 0 0 [swapper/7]
1 0 2 f7480000 IN 0.1 4676 2568 init
2 0 5 f7480ca0 IN 0.0 0 0 [kthreadd]
|
init is a user-space process that always has PID=1 and PPID=0. It's the first user-space program spawned by the kernel once everything is ready (i.e. essential device drivers are initialised and the root filesystem is mounted). As the first process launched, it doesn't have a meaningful parent.
The other 'processes' in your extract are indeed kernel tasks.
| init: is it a user thread or a kernel thread? |
1,402,867,478,000 |
The iniramfs is like a small os which mount root file system and hand over control to systemd. So, how does initramfs work internally? Is there any scripts executed to mount the root in linux?
|
After that initrd/initramfs (only historical difference) is extracted and mounted, it is the script /init that is run. Mostly it only mounts the real root with help of the modules from the initramfs.
And then it has to pivot/switch root to that new partition, a thing that is only possible as pid 1.
Here is a minimal /init script:
mkdir /newroot
mount /dev/sda2 /newroot
mount --move /sys /newroot
mount --move /dev /newroot
mount --move /proc /newroot
switch_root /newroot /bin/bash
(or /sbin/init for a normal continuation)
The thing is the kernel cannot mount /dev/sda2 without the necessary modules built in. Having the modules on sda2 does not help: egg-and-hen problem.
So the kernel gets a cpio archive with a root filesystem containing modules and scripts. The kernel simply hands over to /init and is done with it's own startup.
That gentoo link starts with:
initramfs is a root filesystem that is embedded into the kernel...
What should that mean?
This is a minimal kernel command line:
vmlinuz root=/dev/sdaX
telling the boot loader to load kernel "vmlinuz" and telling the kernel to mount /dev/sdaX.
And this:
vmlinuz initrd=initramfs.img root=/dev/sdaX
makes the boot loader also load an initrd, which the kernel will find and mount as root, and tells the (default) /init script to pivot/switch to /dev/sdaX (and then run default /sbin/init).
| How does initramfs mount root filesystem? |
1,402,867,478,000 |
Reading What do the brackets around processes mean? I understand that the executable name is printed.
Linux ps man page:
Sometimes the process args will be unavailable; when this happens, ps will instead print the executable name in brackets.
However with ps -Awwo pid,comm,args I get:
PID COMMAND COMMAND
1 init init [2]
What does this mean? Does the "executable name" supposed to be init or [2]?
I suppose the executable is of course init - what is [2]? Why is it printed?
(Also, I don't really get why it can't show the full path if it knows the executable name.)
|
Both the comm column and the first word of the args column in the ps output show the name of the executable program if everybody involved follows the default convention. However it is possible to have discrepancies for various reasons.
When a program starts, the command name as shown in the args column is chosen by the parent program that executes the program and passed as an argument (argv[0]). By convention, the parent chooses the base name of the executable (i.e. the path to the executable without the directory part), but this is not enforced. Once the program is running, it can overwrite that string.
Init (at least the traditional Linux SysVinit) overwrites its argv[0] to indicate the current runlevel.
On Linux, the comm column is initially filled in by the kernel to the first 16 characters of the base name of the executable. The process can change the content with the prctl system call.
If the executable is renamed or deleted, neither the comm column nor the args column will reflect this.
ps doesn't display the path to the executable, that's not in its job description. lsof can tell you with lsof -a -p 1 -d txt.
On Linux, you can see this information in files in /proc/PID/:
The process name (comm field) in in /proc/1/stat (second field in parentheses) and /proc/1/status (Name field).
The path to the executable via /proc/1/exe.
The arguments (starting with argv[0]) in /proc/1/cmdline (the arguments are separated by null bytes).
| What does `init [2]` mean in the COMMAND column of ps? |
1,402,867,478,000 |
I'm trying to get a Qt application to launch immediately after booting up. When booted, the Linux image does nothing more than launch an X server and a terminal. It also has the cron daemon running in the background. Obviously, my Qt application needs the X server to be running to do anything.
I've seen a similar question for Red Hat and SUSE Linux.
However, I don't see this working for my image.
I'm wondering if there is a standard way in Linux/UNIX to make a GUI application start immediately after the X Server.
[sj755@localhost X11]$ tree /etc/X11/
/etc/X11/
|-- functions
|-- Xdefaults
|-- Xinit
|-- Xinit.d
| |-- 01xrandr
| |-- 11zaurus
| |-- 12keymap
| |-- 40xmodmap
| |-- 50setdpi
| |-- 55xScreenSaver
| |-- 60xXDefaults
| |-- 89xTs_Calibrate
| `-- 98keymap-fixup
|-- xmodmap
| |-- a716.xmodmap
| |-- collie.xmodmap
| |-- default.xmodmap
| |-- h1910.xmodmap
| |-- h2200.xmodmap
| |-- h6300.xmodmap
| |-- hx4700.xmodmap
| |-- keyboardless.xmodmap
| |-- omap5912osk.xmodmap
| |-- poodle.xmodmap
| |-- shepherd.xmodmap
| |-- simpad.xmodmap
| |-- slcXXXX.xmodmap
| |-- xmodmap-invert
| |-- xmodmap-left
| |-- xmodmap-portrait
| `-- xmodmap-right
|-- xorg.conf
|-- Xserver
|-- xserver-common
|-- Xsession
`-- Xsession.d
|-- 60xXDefaults
|-- 89xdgautostart
`-- 90xXWindowManager
3 directories, 36 files
root@devboard:~# cat /etc/X11/Xsession.d/90xXWindowManager
if [ -x $HOME/.Xsession ]; then
exec $HOME/.Xsession
elif [ -x /usr/bin/x-session-manager ]; then
exec /usr/bin/x-session-manager
else
exec /usr/bin/x-window-manager
fi
#!/bin/sh
#
# Very simple session manager for Mini X
#
# Uncomment below to enable parsing of debian menu entrys
# export MB_USE_DEB_MENUS=1
if [ -e $HOME/.mini_x/session ]
then
exec $HOME/.mini_x/session
fi
if [ -e /etc/mini_x/session ]
then
exec /etc/mini_x/session
fi
MINI_X_SESSION_DIR=/etc/mini_x/session.d
if [ -d "$MINI_X_SESSION_DIR" ]; then
# Execute session file on behalf of file owner
find $MINI_X_SESSION_DIR -type f | while read SESSIONFILE; do
set +e
USERNAME=`stat -c %U $SESSIONFILE`
# Using su rather than sudo as latest 1.8.1 cause failure [YOCTO #1211]
# su -l -c '$SESSIONFILE&' $USERNAME
sudo -b -i -u $USERNAME $SESSIONFILE&
set -e
done
fi
# This resolution is big enough for hob2's max window size.
xrandr -s 1024x768
# Default files to run if $HOME/.mini_x/session or /etc/mini_x/session
# don't exist.
matchbox-terminal&
exec matchbox-window-manager
|
Have a look at /etc/X11/xinit/xinitrc (this may be different places on different systems) to see what files it sources. Generally, this will have an if..elif..else structure, so that only one initialization file is read, with $HOME/.Xclients prioritized then /etc/X11/xinit/Xclients. That's almost certainly where the terminal that appears comes from (I am presuming you do not have a desktop environment installed or anything).
Anyway, if you just want to run a single GUI app, create (or modify) an Xclients file like this:
#!/bin/sh
myGUIapp
This should be executable. It's pretty much a normal shell script, I believe, so you can have more stuff in there, although obviously not backgrounding a GUI app will block execution at that point.
[later addition]
Your installation doesn't have exactly those files, but it does have an /etc/X11/Xinit.d and if you look, I am sure those are short shell scripts and they are sourced from somewhere, probably one of the files in /etc/X11 -- Xsession, Xserver, or xserver-common. You might want to check if $XINITRC is defined in your environment; that will be a clue.
Your best bet is probably to just create a $HOME/.Xclients file (or as jofel mentions, $HOME/.xinitrc, which is probably more universal) and try it -- exactly that spelling and case, with a leading dot, and it should be set chmod 755 (the group and other permissions may not matter). Almost certainly this will be sourced from somewhere properly.
You can put files in /etc/X11/Xinit.d yourself, but doing it for this purpose is not a good idea because yours should run last and block further execution. So have a look at the scripts in /etc/X11 (again: Xsession, etc., they don't have a .sh suffix) and try to figure out in what order they all chain together. It is also likely that somewhere one of them checks
for an Xclients file, eg via something like
if [ -x /some/path/Xclients ]; then
$HOME may also be used, and .xinitrc. Which is why creating at least one of these variations should work (write the file and move around/rename it if at first you don't succeed). To summarize: prime candidates for the name: .xinitrx and .Xclients, in either $HOME or /etc/X11/, but if in the later, ditch the leading dot.
| Starting Qt Application On Startup for Embedded Linux |
1,402,867,478,000 |
From: https://wiki.debian.org/LSBInitScripts
Add a block like this in the init.d script:
### BEGIN INIT INFO
# Provides: scriptname
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
These variables are also present on SysVinit LSB header from scripts like "ssh".
Does anyone knows about these variables?
|
These are system facility names in Linux Standard Base. They're not treated like shell variables, they're just special names allowing init scripts to depend on certain system states.
In particular, $remote_fs and $syslog are defined as follows:
$remote_fs
all remote file systems are available. In some configurations, file systems such as /usr may be remote. Many applications that require $local_fs will probably also require $remote_fs.
$syslog
system logger is operational.
| What are the variables $remote_fs and $syslog on SysVinit LSB header? |
1,402,867,478,000 |
I recently updated some of our machines to Fedora 17. I have noticed that there are some services that I can configure their runlevels using chkconfig, while others don't appear there at all, and can be configured using systemctl.
For example, there are the similar commands chkconfig network off and systemctl disable NetworkManager.service. (I understand that network and NetworkManager are different, that's not the point.)
Why are some services configurable via one tool and not the other?
Does one tool replace the other? For example, runlevels are very obvious with chkconfig, but I can't even tell if that concept exists with systemd.
Edit: I found a table that maps calls from chkconfig to systemctl
|
From the fedora wiki page about systemd:
Does chkconfig command work with systemd?
Yes, for turning on/off services, compatibility has been provided both
ways. chkconfig has been modified to call systemctl when dealing with
systemd service files. Also systemctl automatically calls chkconfig
when dealing with a traditional sysv init file.
This means you should be able to use either one of the tools for managing your services.
The concept of runlevels still exists, e.g (this is a Debian system):
ls -l runlevel*.target
lrwxrwxrwx 1 root root 15 Jun 5 22:57 runlevel0.target -> poweroff.target
lrwxrwxrwx 1 root root 13 Jun 5 22:57 runlevel1.target -> rescue.target
lrwxrwxrwx 1 root root 17 Jun 5 22:57 runlevel2.target -> multi-user.target
lrwxrwxrwx 1 root root 17 Jun 5 22:57 runlevel3.target -> multi-user.target
lrwxrwxrwx 1 root root 17 Jun 5 22:57 runlevel4.target -> multi-user.target
lrwxrwxrwx 1 root root 17 Jun 5 22:57 runlevel5.target -> multi-user.target
lrwxrwxrwx 1 root root 13 Jun 5 22:57 runlevel6.target -> reboot.target
| How do systemd and chkconfig interact with respect to services and runlevels? |
1,402,867,478,000 |
I tried to remove some services from startup using various software like:
bum
sysv-rc-conf
rcconf
But... some services are still executed, like MySQL, OpenVPN, MongoDB etc.
I wonder if I am missing something, I did not understand what systemd is used for. Maybe these software are deprecated and should not be used anymore... Therefore, I do not see all services in it, VBox services are load but I cannot see them is these software.
I am just trying to save my battery's life.
Here's a screenshot from sysv-rc-conf.
|
Use # systemctl disable <your_service> to disable it.
| Startup services on Debian 9 |
1,402,867,478,000 |
I'd like to learn about how systemd starts services, specifically which user the service is started as, and I'd like to use Jenkins running on my Linux PC as an example.
I know that init is pid 1, the mother of all processes in Linux, and in my case pid 1 belongs to systemd, which I can see from running top:
$ top
Tasks: 646 total, 1 running, 645 sleeping, 0 stopped, 0 zombie
%Cpu(s): 1.0 us, 0.6 sy, 0.0 ni, 97.0 id, 1.3 wa, 0.0 hi, 0.1 si, 0.0 st
MiB Mem : 257826.8 total, 198695.4 free, 28529.6 used, 30601.7 buff/cache
MiB Swap: 262012.0 total, 262012.0 free, 0.0 used. 227579.3 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 root 20 0 171284 11196 7904 S 0.3 0.0 31:49.54 systemd
I had naively assumed that because systemd runs as root, all services that it runs would run as root.
But I think that Jenkins is running as admin on my PC.
I tried to use systemctl to determine which user Jenkins was running as, but I didn't see any user info in the stdout:
user@linux_box:~$ systemctl status jenkins
● jenkins.service - LSB: Start Jenkins at boot time
Loaded: loaded (/etc/init.d/jenkins; generated)
Active: active (exited) since Fri 2023-05-05 11:50:06 PDT; 3 days ago
Docs: man:systemd-sysv-generator(8)
Tasks: 0 (limit: 4915)
Memory: 0B
CGroup: /system.slice/jenkins.service
Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.
user@linux_box:~$
...so I tried ps aux:
user@linux_box:~$ ps aux | grep jenkins
admin 2042 0.0 0.0 14164 196 ? S May05 0:00 /usr/bin/daemon --name=admin --inherit --env=JENKINS_HOME=/home/admin/jenkins --output=/var/log/jenkins/jenkins.log --pidfile=/var/run/admin/admin.pid -- /usr/bin/java -Djava.awt.headless=true -jar /home/admin/jenkins/jenkins.war --webroot=/var/cache/jenkins/war --httpPort=8080
admin 2043 1.7 5.3 48146100 14118144 ? Sl May05 83:41 /usr/bin/java -Djava.awt.headless=true -jar /home/admin/jenkins/jenkins.war --webroot=/var/cache/jenkins/war --httpPort=8080
admin 29932 0.0 0.0 6204 892 pts/1 S+ 20:37 0:00 grep jenkins
...I think that leftmost column is saying that Jenkins is running as admin, no?
Can someone please explain the relationship between systemd, the user that it runs as vs. the user that services are run as? It would be great if the answer could tie that to what's specifically going on with Jenkins on this Linux PC.
|
The default user that systemd uses for running system services is indeed root, but of course this customisable using the User option. From man 5 systemd.exec:
User=, Group=
Set the UNIX user or group that the processes are executed as, respectively. Takes a single
user or group name, or a numeric ID as argument. For system services (services run by the system service
manager, i.e. managed by PID 1) and for user services of the root user (services managed by root's instance of
systemd --user), the default is "root", but User= may be
used to specify a different user. [...]
In your Jenkins case, systemd is using a generated unit based on the sysv init script /etc/init.d/jenkins, so it's not using the User option (the generated units are very basic: How does systemd use /etc/init.d scripts?). The init script seems to be calling /usr/bin/daemon to start Jenkins, and from man 1 daemon:
The preparatory tasks that daemon performs for other processes are:
[...]
• Change the process uid and gid if the --user option was supplied. Only root can use
this option. Note that the uid of daemon itself is changed, rather than just changing
the uid of the client process.
However, this option is not present in the ps output, so it might be using some other way to change the UID. Check the /etc/init.d/jenkins script to find out.
| Which user does systemd start services as? |
1,402,867,478,000 |
The init process exists as an ancestor of all of processes on a linux system. Does this process have any kind of IPC entry point ? Do other processes ever do IPC with init for any reason ?
|
Don't conflate processes and programs. There's one process #1, but it can be running one of a number of different programs.
If it is running the systemd program from the systemd package:
There is an internal systemd API accessible via D-Bus, that is not guaranteed stable and not intended to be used by things outwith the systemd package.
It responds to a large set of signals, ranging from SIGWINCH and SIGPWR to SIGRTMIN + 4.
If it is running the system-manager program from the nosh package:
It responds to a fairly large subset of the signals recognized by systemd, with the same meanings where applicable.
If it is running the init program from upstart:
There is an internal upstart API, accessible via D-Bus.
It reads command messages from the initctl FIFO.
It responds to small set of signals.
If it is running Joachim Nilsson's finit:
It reads command messages from the initctl FIFO.
It responds to a small set of signals.
If it is running the System 5 init then:
It reads command messages from the initctl FIFO.
It responds to a very small set of signals.
Some notes:
The signal API is mandated by the things that send the signals to process #1. These include the operating system kernel, which sends things like SIGWINCH, SIGINT, and SIGPWR, and various widespread system utility programs.
Both systemd and the nosh system-manager extend this with signals that command system state changes (such as shutting down and powering off the system).
Not all programs document supporting the full set of system-mandated signals. upstart makes no mention of responding to SIGPWR, for example.
finit recognizes a different set of non-system-mandated extended signals, including SIGSTOP and SIGCONT.
Although the systemd package doesn't implement the initctl FIFO API in the program that runs as process #1, it does provide a compatibility shim in another process, running another program, that translates that mechanism onto native systemd mechanisms. (The nosh toolset has its own initctl-read compatibility shim that similarly translated into the native mechanisms of the nosh toolset's system management.)
initctl really isn't native to anything but System V init, as the others (if they do so at all) only implement the notion of run levels as a limited backwards-compatibility mechanism.
As the upstart man page for its init program says, the initctl mechanism isn't well documented. Even the System V init people go around telling people that only things in the System V init package should use it. It doesn't help, moreover, that the Debian System V maintainers relocated it from /dev to /run.
So yes, programs do IPC with process #1. Their reasons for doing so vary.
The systemd program is a combination system manager, service manager, and control groups manager and so there are a lot of purposes for which programs employ IPC to process #1. The same for upstart's init.
For nosh's system-manager, conversely, service management is done by another program (service-manager) in another process with its own (daemontools-compatible) APIs. So the only reason to do IPC with process #1 is for system state management, such as (say) rebooting the machine.
For many (not all) purposes, one is better off sticking to other APIs, using conventional system utilities to do things like shutdown and reboot the system, rather than sending the signals understood by the system-manager and systemd programs when they are running as process #1.
Further reading
https://superuser.com/questions/886825/
| Linux - IPC with init |
1,402,867,478,000 |
I am used to the old method of calling init 0 to shutdown. Bad, I know; but when I tried it on my new Arch install I get this:
# init 0
Excess Arguments
This confuses me because I thought systemd was supposed to support run levels? Looking at the man page, it mentions this:
For compatibility with SysV, if systemd is called as init and a PID
that is not 1, it will execute telinit and pass all command line
arguments unmodified. That means init and telinit are mostly
equivalent when invoked from normal login sessions. See telinit(8) for
more information.
Am I just using the wrong syntax or have I completely misunderstood systemd?
More Init/Systemd Information
# command -v init
/usr/bin/init
# file /bin/init
/usr/bin/init: symbolic link to ../lib/systemd/systemd
# /lib/systemd/systemd --version
systemd 234
+PAM -AUDIT -SELINUX -IMA -APPARMOR +SMACK -SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 -SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN default-hierarchy=hybrid
# command -v telinit
/usr/bin/telinit
# file /bin/telinit
/bin/telinit: symbolic link to systemctl
# systemctl --version
systemd 234
+PAM -AUDIT -SELINUX -IMA -APPARMOR +SMACK -SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 -SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN default-hierarchy=hybrid
General System Info
# uname -a
Linux arch 4.12.5-1-ARCH #1 SMP PREEMPT Fri Aug 11 12:40:21 CEST 2017 x86_64 GNU/Linux
# bash --version
GNU bash, version 4.4.12(1)-release (x86_64-unknown-linux-gnu)
|
For compatibility with SysV, […]systemd 234
[…] -SYSVINIT […]
You've built systemd without the compatibility option, so the compatibility behaviour described in the manual is not going to be present.
| Why does `init 0` result in "Excess Arguments" on Arch install? |
1,402,867,478,000 |
The book "How Linux Works" says the general shutdown procedure (independent of init system) is something like this:
init asks every process to shut down cleanly.
If a process doesn’t respond after a while, init kills it, first trying a TERM signal.
If the TERM signal doesn’t work, init uses the KILL signal on any stragglers.
The system locks system files into place and makes other preparations for shutdown.
The system unmounts all filesystems other than the root.
The system remounts the root filesystem read-only.
The system writes all buffered data out to the filesystem with the sync program.
The final step is to tell the kernel to reboot or stop with the reboot(2) system call. This can be done by init or an auxiliary program such as reboot, halt, or poweroff.
How can sync write its buffers if the filesystem is read-only?
|
You're right to be surprised: that order doesn't make sense. If a book presents it that way, it's sloppy and misleading.
Unmounting a filesystem, or mounting it read-only, writes all the data to the disk. When the umount command or mount -o remount,ro returns, all the data is written to the disk and sync has nothing left to do. It's pointless to call sync before (the data will be written by the umount operation anyway) and pointless to call it after (it won't do anything).
I think this wasn't true in some ancient Unix systems, where you had to call sync before unmounting. Calling it after was still pointless.
If you look beyond filesystems, there may be cases where sync does something. For example, I think that on Linux sync ensures that the metadata of RAID arrays are written to the disk. This is useful even in the absence of any filesystem mounted read-write.
| Shutdown procedure clarification |
1,402,867,478,000 |
I'm getting the following errors every 10-30 seconds on a virtual Red Hat Enterprise Linux 6.5 2 Server on Amazons EC2.
Sep 23 09:57:05 ServerName init: ttyS0 (/dev/ttyS0) main process (1612) terminated with status 1
Sep 23 09:57:05 ServerName init: ttyS0 (/dev/ttyS0) main process ended, respawning
Sep 23 09:57:05 ServerName agetty[1613]: /dev/ttyS0: tcgetattr: Input/output error
Does anyone know what is causing this and how I could go about fixing it?
Thanks.
|
A virtual Red Hat installation probably doesn't have any serial ports connected (which is what /dev/ttyS0 is: COM1 in DOS parlance), so trying to start agetty to listen to the serial port is doomed to fail. Find the line in /etc/inittab that contains agetty and ttyS0 and change
respawn to off.
EDIT: In case the system is using upstart, as in redhat 6, do
stop ttyS0
to stop the service now, and do
echo manual | sudo tee /etc/init/ttyS0.override
to prevent starting the service after a reboot according to https://askubuntu.com/a/468250/146273
For documentation purposes, you might also consider doing:
sudo tee -a /etc/init/ttyS0.conf <<EOF
# Disabled. See https://unix.stackexchange.com/a/157489/9745
EOF
Further reading: http://upstart.ubuntu.com/cookbook/#disabling-a-job-from-automatically-starting
| ERROR: init: ttyS0 (/dev/ttyS0) main process (1612) terminated with status 1 |
1,402,867,478,000 |
I am running program using runit to run at startup. I want all the output by from the program that is run by runit to be logged to a file.
I have looked at svlogd but I cannot figure out how to get it running.
|
I cannot figure out how to get it running.
In the daemontools family world, log services are just services like any other. So you run svlogd with a run program just like you would run a "main" service with a run program.
The special things about "log" services are merely that:
The "log" service directory is located using a symbolic link from (or a straight subdirectory beneath) the "main" service directory.
Some, but not all, daemontools family toolsets tightly bind "log" and "main" services and operate upon the twain as a unit. This is to a degree the case with runit.
Otherwise, they are just like everything else.
So make a "log" service to run svlogd just like you would make any other service, put it into the right place relative to your "main" service, and set things off.
Further reading
Jonathan de Boyne Pollard (2015). "Logging". The daemontools family. Frequently Given Answers.
Gerrit Pape. "How do I create a new service directory with an appendant log service?". runit Frequently Asked Questions.
Daniel J. Bernstein. "How do I create a service directory with a log?". daemontools Frequently Asked Questions.
| How to log output to log file using runit |
1,402,867,478,000 |
I have a init script which is poorly designed because it does not conform to the Linux Standard Base Specifications
The following should have an exit code of 0 if running, and 3 if not running
service foo status; echo $?
However because of the way the script is designed, it always returns a 0.
I can not fix the script without a significant rewrite (because service foo restart is dependent on service foo status).
How could you work around the issue so that service foo status returns a 0 if running, and a 3 if not running?
What I have so far:
root@foo:/vagrant# service foo start
root@foo:/vagrant# /etc/init.d/foo status | /bin/grep "up and running"|wc -l
1
root@foo:/vagrant# /etc/init.d/foo status | /bin/grep "up and running"|wc -l;echo $?
0 # <looks good so far
root@foo:/vagrant# service foo stop
root@foo:/vagrant# /etc/init.d/foo status | /bin/grep "up and running"|wc -l
0
root@foo:/vagrant# /etc/init.d/foo status | /bin/grep "up and running"|wc -l;echo $?
0 # <I need this to be a 3, not a 0
|
You are piping the grep output to wc and echo $? would return the exit code for wc and not grep.
You could easily circumvent the problem by using the -q option for grep:
/etc/init.d/foo status | /bin/grep -q "up and running"; echo $?
If the desired string is not found, grep would return with a non-zero exit code.
EDIT: As suggested by mr.spuratic, you could say:
/etc/init.d/foo status | /bin/grep -q "up and running" || (exit 3); echo $?
in order to return with an exit code of 3 if the string is not found.
man grep would tell:
-q, --quiet, --silent
Quiet; do not write anything to standard output. Exit
immediately with zero status if any match is found, even if an
error was detected. Also see the -s or --no-messages option.
(-q is specified by POSIX.)
| How to trick an init script into returning 0 |
1,402,867,478,000 |
After reading this answer, I thought it would be funny to roll my own init on Python, so I wrote this in /init-python.
#!/usr/bin/python3
import os
import subprocess
# Make / writable!
subprocess.call(['/bin/mount', '-o', 'rw,remount', '/'])
# Became IPython (Now we're at it, get a good shell!)
os.execv('/usr/bin/ipython3', ['init'])
Then added init=/init-python to the linux line in GRUB config. It works.
So I was wondering now... how to power off or reboot my system with my homemade init?
|
It can be done with reboot function (man 2 reboot).
import ctypes
libc = ctypes.cdll['libc.so.6']
RB_POWER_OFF = 0x4321fedc
RB_AUTOBOOT = 0x01234567
def shutdown():
libc.reboot(RB_POWER_OFF)
def reboot():
libc.reboot(RB_AUTOBOOT)
| Rolling your own init: How to shutdown/restart? |
1,402,867,478,000 |
If something prevents a Linux system from booting, it is common to see this message:
kernel panic - not syncing: [Error Message]
But what does "not syncing" mean? What exactly isn't syncing?
The only place I have seen sync before is the sync system call, ie., commit buffer cache to disk
|
You are correct in that it is referring to syncing the disks. If the kernel panics, there could be a multitude of reasons - including a software bug in file system code.
Syncing the disks could write corrupt data to the disks, such as if the panic was due to a bug in Ext4, for example - so the kernel plays it safe and doesn't flush anything to disk because it no longer trusts that the data is valid anymore.
Additionally, if the panic occurred due to a hardware issue (e.g. bad RAM), syncing the disks could also write corrupted data from memory to the disk. If the filesystem then became corrupt as a result, the system might refuse to boot after being restarted, or may need to be fsck'ed.
The overall idea is that if the kernel itself has just crashed, don't trust anything anymore and just halt the system.
| What is a sync during kernel boot? |
1,402,867,478,000 |
I made a script that runs fine manually, but can't get it to run with the description in How to start a script file on boot?.
I have run update-rc.d -f minecraft.start defaults
This is what my /etc/init.d/minecraft.start is like
#!/bin/bash
case "$1" in
start)
screen -S minecraft.start /home/phirephoenix/minecraft/bukkitserver/start_server.sh
echo "Server started on screen minecraft"
;;
stop)
screen -X -S minecraft.start kill
echo "Server shutting down"
;;
*)
echo "Usage: /etc/init.d/minecraft.start {start|stop}"
exit 1
;;
esac
exit 0
~
As the script works, I won't be adding it, since it's the default.
And this is my startup log /var/log/boot.log
Begin: Loading essential drivers ... done.
Begin: Running /scripts/init-premount ... done.
Begin: Mounting root file system ... Begin: Running /scripts/local-top ... done.
Begin: Running /scripts/local-premount ... done.
Begin: Running /scripts/local-bottom ... done.
done.
Begin: Running /scripts/init-bottom ... done.
fsck from util-linux 2.20.1
/dev/sda1: clean, 66452/4325376 files, 1205648/17301248 blocks
* Starting configure network device [ OK ]
* Starting Mount network filesystems [ OK ]
* Starting Failsafe Boot Delay [ OK ]
* Stopping Mount network filesystems [ OK ]
* Starting Bridge socket events into upstart [ OK ]
* Starting SMB/CIFS File Server [ OK ]
* Starting configure network device [ OK ]
* Stopping OpenSSH server [ OK ]
* Starting OpenSSH server [ OK ]
* Starting NetBIOS name server [ OK ]
* Starting Mount network filesystems [ OK ]
* Stopping Failsafe Boot Delay [ OK ]
* Starting configure network device [ OK ]
* Starting System V initialisation compatibility [ OK ]
* Stopping Mount network filesystems [ OK ]
* Starting SMB/CIFS File and Active Directory Server [ OK ]
* Stopping cold plug devices [ OK ]
* Stopping log initial device creation [ OK ]
* Starting enable remaining boot-time encrypted block devices [ OK ]
* Starting configure network device security [ OK ]
* Starting configure virtual network devices [ OK ]
* Stopping configure virtual network devices [ OK ]
* Starting save udev log and update rules [ OK ]
* Stopping save udev log and update rules [ OK ]
Skipping profile in /etc/apparmor.d/disable: usr.sbin.rsyslogd
* Starting AppArmor profiles [ OK ]
* Stopping System V initialisation compatibility [ OK ]
* Starting System V runlevel compatibility [ OK ]
* Starting ACPI daemon [ OK ]
* Starting save kernel messages [ OK ]
* Starting automatic crash report generation [ OK ]
* Starting regular background program processing daemon [ OK ]
* Starting deferred execution scheduler [ OK ]
* Stopping save kernel messages [ OK ]
* Starting CPU interrupts balancing daemon [ OK ]
* Starting crash report submission daemon [ OK ]
* Starting domain name service... bind9 [ OK ]
**<BIG BLANK AREA RIGHT HERE, DON'T GET IT>**
**[screen is terminating]**
**Server started on screen minecraft**
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
* Starting web server apache2 [ OK ]
* Stopping System V runlevel compatibility [ OK ]
It does execute the echo inside start, but it also says screen is terminating.
What is causing this problem here? I run Ubuntu Server, it seems screen is installed and working.
So new approach, using the upstart feature (or what I should call it). I kind of understood the runtimelevel things after some short googeling, and it should now start on one of the four runtimelevels i have set, or stop, on halt/reboot etc.
made /etc/init/bukkit.conf much like the one warlock made. All the # are added for commenting here, and are not on the actual script.
description "Bukktiserver"
author "[email protected]"
start on runlevel [2345]
stop on runlevel [016]
pre-start script
echo " * Bukkitserver started"
# I don't know if this does anything at all
end script
exec sudo /home/phirephoenix/minecraft/bukkitserver/start_server.sh
# Had to sudo, or else it would get permission denied. Any ideas?
Now I can start the server with typing sudo start bukkit, but it still does not run automaticly.
bukkit is in my initctl list with bukkit stop/waiting
(For everyone wondering bukkit is a minecraft server software.)
So. I use a .conf to make it a upstart service, want the script to run without me having to do anything (automaticly before any logon). Is there a problem with the actuall jarfile to be run is in my homefolder? I can't really remember if my homefolder is encrypted or not, but it might be. Could this be a problem? Will I have to use symlinks or something (if symlinks are almost like shortcuts, but it ain't?)
What am I missing here?
Ps: I has also removed the screen startup thingy, with update-rc.d remove.
|
I didn't remember screen having a daemon mode, apparently it does. Change the screen line for the following:
screen -dmS minecraft.start /home/phirephoenix/minecraft/bukkitserver/start_server.sh
The new parameter -dmS "Start as daemon: Screen session in detached mode.", which is the combination of -d -m and the -S that you are already using.
| Make screen start as Daemon for a Minecraft server |
1,402,867,478,000 |
I know 'init' is first process that is started after the kernel is loaded, but there is an ambiguity for me. If it is a process it must have a binary executable file. However, the following shared object is compiled code that looks like an executable file, but there is no main function.
sardari@mint / $ file /sbin/init
/sbin/init: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=7a4c688d009fc1f06ffc692f5f42ab09e68582b2, stripped
Apparently a shared object can be an executable file, but why?
|
When a file compiled with -pie (Position Independent Executable) such as :
gcc -pie -fPIC hello.c
Then you have :
#file ./a.out
a.out: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0x2afb7892000a1dc5b9010c591b75987188aa2d66, stripped
If you need more information , You can visit Position-independent code
| /sbin/init is shared object? |
1,402,867,478,000 |
My OS is RHEL 6.2
I disable Ctrl+Alt+Del by changing in /etc/init/control-alt-del.conf the line
exec /sbin/shutdown -r now "Control-alt-del pressed"
by
exec /bin/true
I'll be testing it next Sunday.
My questions:
are there any daemons to restart?
I keep a copy on original /etc/init/control-alt-del.conf in /etc/init, is it safe?
I mean won't the shutdown part of exec be fired?
more official way to disable Ctrl+Alt+Del?
edit:
tested on vmware player 6.0.3 (for what it is worth, this is not a virtualization issue)
editing file, no exec line, no restart, user logged on gui, send Ctrl+Alt+Del : shutdown prompt
after restart, no exec line, user logged on gui, send Ctrl+Alt+Del : shutdown prompt
after restart, exec /bin/true, user logged on gui, send
Ctrl+Alt+Del : shutdown prompt
after restart, exec /bin/true, no user logged on gui, send
Ctrl+Alt+Del : no shutdown prompt
|
change in /etc/init/control-alt-del.conf are taken immediatly.
I tested in ESX and physical hosts.
when I inserted
exec date > /var/log/cad.log
in /etc/init/control-alt-del.conf
and issue Ctrl-AltDel I get date in /var/log/cad.log.
So no need to reboot.
| How to disable ctrl-alt-del and /etc/init/control-alt-del.conf in Linux? |
1,402,867,478,000 |
I am wondering how I can run a daemon, in this case NTP, with custom parameters.
For example in my Ubuntu PC I observe that I've got ntpd running this way:
$ ps aux | grep ntpd
ntp 5936 ... 0:00 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 119:127
You may notice that -g parameter.
But in my Gentoo PC I run the same command and I can observe that the ntp daemon is not running with that -g parameter and I want to add it!
Is this a distribution specific issue? How can I handle this?
|
Guessing from the Gentoo Wiki, editing NTPD_OPTS in /etc/conf.d/ntpd probably does the trick (regardless of the question if -g is advisable, no idea).
| How can I run a daemon with custom parameters |
1,402,867,478,000 |
When I boot my system, I can see the boot messages on my physical console tty1. After my X server has started, I can switch back to tty1 with CTRLALT+F1, and still see the output on the console. There is no getty running, because I have commented out the following line in /etc/inittab:
#1:2345:respawn:/sbin/getty 38400 tty1
However, I am not able to scroll back in the console, nothing works, and even enter does not do anything. I would like to scroll back, to see the earlier boot messages (output of init scripts, which I cannot see in dmesg)
I am using Debian and SysVinit as my init
|
It's not possible and it has never been possible AFAIK.
This is well explained in the Linux keyboard and console HOWTO: the console display history uses the video memory witch is flushed when you switch console.
Upon changing virtual consoles, the screen content of the old VT is copied to kernel memory, and the screen content of the new VT is copied from kernel memory to video memory. Only the visible screen is copied, not all of video memory, so switching consoles means losing the scrollback information.
| cannot scroll back in console (tty1) |
1,402,867,478,000 |
I'm trying to understand the Linux init system.
I don't understand how there are three competing systems, yet the service command seems to work on all of them.
From the service commands man page:
service runs a System V init script or upstart job...
I'm using lubuntu 16.4 I think systemd is the default init system (pstree shows systemd as root process). Systemd is not mentioned in the man page for service. Yet I still start and stop scripts using it.
Can anyone explain why this is?
|
Some distributions have opted to include compatibility scripts so that old style commands still work. For example, on Debian 8.
root@matrix:~# which service
/usr/sbin/service
root@matrix:~# file /usr/sbin/service
/usr/sbin/service: POSIX shell script, ASCII text executable, with very long lines
root@matrix:~# grep upstart /usr/sbin/service
# Operate against system upstart, not session
&& initctl version 2>/dev/null | grep -q upstart \
# Upstart configuration exists for this job and we're running on upstart
# Action is a valid upstart action
root@matrix:~# grep systemd /usr/sbin/service
is_systemd=
if [ -d /run/systemd/system ]; then
is_systemd=1
# On systems using systemd, we just perform a normal restart:
# A restart with systemd is already a full restart.
if [ -n "$is_systemd" ]; then
# When this machine is running systemd, standard service calls are turned into
if [ -n "$is_systemd" ]
# the systemd service file does not (yet) support reload for a
| Why does using the service command work on a systemd distro? |
1,402,867,478,000 |
Supposedly I passed the kernel a parameter that it doesn't understand, for example blabla or eat=cake, what would the kernel do with these unknown parameters, the traditional case would be passing any unknown parameter to init, in case if the the Linux kernel starts with early user space (initramfs) would it pass it to /init in initramfs?
|
From the kernel documentation:
The kernel parses parameters from the kernel command line up to --;
if it doesn't recognize a parameter and it doesn't contain a ., the
parameter gets passed to init: parameters with = go into init's
environment, others are passed as command line arguments to init.
Everything after -- is passed as an argument to init.
This also applies to /init on an initramfs. In the source code, both the initramfs's /init and the final root's /sbin/init (or other locations) are invoked via run_init_process which uses the same arguments (apart from argument 0 which is the path to the executable). I can't find it stated in the documentation but kernel interfaces are stable so this won't change.
Note that this does not apply to /linuxrc on an initrd. This one is invoked with no arguments, but with the same environment as /init and /sbin/init. It can mount the proc filesystem and read /proc/cmdline to see the kernel command line arguments.
| What does the Linux kernel do with unknown kernel parameters? |
1,402,867,478,000 |
I have looked and looked and none of the threads I have found are helping.
We have a tomcat startup script that we modified slightly for our needs. It works fine on Centos / redhat 6 boxes, but does not work on centos/redhat 5 boxes.
Here is the output of chkconfig --add tomcat:
$ chkconfig --add tomcat
service tomcat does not support chkconfig
Here is the top part of the tomcat script
#!/bin/bash
#
# Tomcat 8 start/stop/status init.d script
# Initially forked from: https://gist.github.com/valotas/1000094
# @author: Miglen Evlogiev <[email protected]>
#
# Release updates:
# Updated method for gathering pid of the current proccess
# Added usage of CATALINA_BASE
# Added coloring and additional status
# Added check for existence of the tomcat user
# Added termination proccess
#chkconfig: 2345 20 80
#discription Tomcat Starup Script
#Location of JAVA_HOME (bin files)
|
Replace "discription" by "description:" (typo and missing colon).
RHEL 5 needs "chkconfig:" and "description:", RHEL6 only "chkconfig:".
| chkconfig does not support my script |
1,402,867,478,000 |
my platform:
SOC = STM32H743 (ARMv7E-M | Cortex-M7)
Board = Waveshare CoreH7XXI
Linux Kernel = 5.8.10 (stable 2020-09-17)
initial defconfig file = stm32_defconfig
rootfs = built using busybox | busybox compiled using arm-linux-gnueabihf-gcc
I've created rootfs by following this guide.
my kernel cannot execute any file even the init file >>> /linuxrc or /sbin/init.
for making sure that the problem is not from busybox files, I wrote a C helloworld program with -mcpu=cortex-m7 flag and compiled it with arm-linux-gnueabi-gcc but again the kernel paniced and throwed the -8 error (Exec format error).
my busybox files are all linked to the busybox binary and the binary is correctly compiled for 32bit arm:
$ readelf -A bin/busybox
Attribute Section: aeabi
File Attributes
Tag_CPU_name: "Cortex-M7"
Tag_CPU_arch: v7E-M
Tag_CPU_arch_profile: Microcontroller
Tag_ARM_ISA_use: Yes
Tag_THUMB_ISA_use: Thumb-2
Tag_ABI_PCS_wchar_t: 4
Tag_ABI_FP_rounding: Needed
Tag_ABI_FP_denormal: Needed
Tag_ABI_FP_exceptions: Needed
Tag_ABI_FP_number_model: IEEE 754
Tag_ABI_align_needed: 8-byte
Tag_ABI_align_preserved: 8-byte, except leaf SP
Tag_ABI_enum_size: int
Tag_CPU_unaligned_access: v6
the kernel error:
[ 0.925859] Run /linuxrc as init process
[ 0.943257] Kernel panic - not syncing: Requested init /linuxrc failed (error -8).
[ 0.950654] ---[ end Kernel panic - not syncing: Requested init /linuxrc failed (error -8). ]---
my helloworld program:
$ readelf -A hello
Attribute Section: aeabi
File Attributes
Tag_CPU_name: "7E-M"
Tag_CPU_arch: v7E-M
Tag_CPU_arch_profile: Microcontroller
Tag_ARM_ISA_use: Yes
Tag_THUMB_ISA_use: Thumb-2
Tag_ABI_PCS_wchar_t: 4
Tag_ABI_FP_rounding: Needed
Tag_ABI_FP_denormal: Needed
Tag_ABI_FP_exceptions: Needed
Tag_ABI_FP_number_model: IEEE 754
Tag_ABI_align_needed: 8-byte
Tag_ABI_align_preserved: 8-byte, except leaf SP
Tag_ABI_enum_size: int
Tag_CPU_unaligned_access: v6
the kernel error:
[ 1.189550] Run /hello as init process
[ 1.198670] Kernel panic - not syncing: Requested init /hello failed (error -8).
[ 1.205977] ---[ end Kernel panic - not syncing: Requested init /hello failed (error -8). ]---
Why the kernel can't execute binaries?
|
the problem is that you are compiling it in a normal static elf format. you should compile it as an FDPIC-ELF executable (because you need a position independent executable (FDPIC) due to the lack of MMU).
FDPIC ELF is not ET_EXEC type. it is ET_DYN (it means it's shared) type and it is loaded by the Linux dynamic loader.
just add a -mfdpic flag to it and turn off the built static binary in the busybox's kconfig menu.
note that -mfdpic flag is on by default in arm-uclinux-fdpicabi toolchains.
| kernel cannot execute binaries (error -8) |
1,402,867,478,000 |
In my ps output:
root 1 0.0 0.0 225552 5316 ? Ss /lib/systemd/systemd --system --deserialize 19
message+ 572 0.0 0.0 51564 3076 ? Ss /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
root 590 0.0 0.0 71084 2084 ? Ss /lib/systemd/systemd-logind
t 929 0.0 0.0 76872 1988 ? Ss /lib/systemd/systemd --user
t 980 0.0 0.0 50792 2688 ? Ss /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
systemd+ 2632 0.0 0.0 71240 2464 ? Ss /lib/systemd/systemd-resolved
systemd+ 2637 0.0 0.0 143976 712 ? Ssl /lib/systemd/systemd-timesyncd
root 2642 0.0 0.4 232544 37308 ? S<s /lib/systemd/systemd-journald
root 3334 0.0 0.0 46108 2252 ? Ss /lib/systemd/systemd-udevd
testme 22693 0.0 0.0 76964 3428 ? Ss /lib/systemd/systemd --user
Why do I have so many systemd related processes?
In particular, why is there a systemd process owned by each user that is logged in?
In the boot sequence of Linux, the kernel starts the init system as the first process, and then the init process runs login so that each user can login. I think the init system should be run as as a singleton process, regardless of how many users login, and regardless of whether the init system is sysvinit or systemd, correct?
Does root have to log in to start its systemd process?
For those systemd processes not owned by root, are they run as daemons?
Thanks.
|
The init process is pid 1, and root most certainly doesn’t have to log in to start it. The other processes aren’t the init process.
The various per-user systemd processes manage each user’s services. These include user services (systemctl --user start ...), and a number of “per-user dæmons” (in GNOME, you’ll see PulseAudio, various GVFS processes, etc.).
The other systemd processes handle specific services: the resolver, the time synchronisation service, the journal, etc.
Your ps output shows that none of these processes has a controlling terminal, so they’re all running as dæmons (for some value of dæmon).
systemd has very good documentation, try man systemd, man systemd-logind etc.
| Why is there a `systemd` process owned by each user that is logged in? |
1,470,427,386,000 |
I am running Debian testing. I have the following entry in my /etc/default/grub which was probably done a year or two before. Time-stamp says July 2015 but that may be when I made some other changes.
GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1 init=/lib/systemd/systemd"
Anyways, IIRC systemd has been the default since Jessie
https://www.debian.org/releases/jessie/amd64/release-notes/ch-whats-new.en.html#systemd
So I could just delete it and it reads
GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1"
and then update-grub for the action to happen. Is there anything else I should be aware of ?
The ISP's don't have IPV6 hence keeping it disabled for now.
|
Usually yes, but it depends on what you changed on the system.
Do dpkg -S /sbin/init to see what your system default is. If it is systemd-sysv (the default for clean Jessie upgrade) then systemd is default and you can safely remove it from and systemd will still run after reboot. If it is sysvinit-core however, you need to install systemd-sysv package if you want systemd to remain default init system.
| A way to know if systemd is indeed the default init |
1,470,427,386,000 |
Does Linux sends SIGCHLD to init (PID 1 process) when it inherits orphaned zombie processes (processes that have not been reaped by its original parent)?
|
Yep. I tested it. And you can see where this happens in the Linux code.
Test: Start a nested shell. From elsewhere, kill -s STOP the parent shell. Then kill -s KILL the child shell and then the parent.
Note:
If you try this inside gnome-terminal, for example, the reaper will not be PID 1. It will be a sub-reaper, the process systemd --user.
Also, systemd handles signals using a signalfd. So when you run strace -p on the systemd process, you will not see a signal being received. You will instead see that systemd wakes from epoll_wait() and performs a read() on a file descriptor.
You can confirm the file descriptor number is a signalfd using ls -l /proc/<PID>/fd/<FD>. It will say anon_inode:[signalfd].
| Does Linux sends `SIGCHLD` to `init` when it inherits orphaned zombie processes? |
1,470,427,386,000 |
I played around with a LSB init script under Debian Wheezy(init is from sysvinit package version 2.88dsf-41+deb7u1) for learning purposes. My script is following:
# cat /etc/init.d/test-script
#! /bin/sh
### BEGIN INIT INFO
# Provides: test
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: test script
# Description: test script
### END INIT INFO
# always executes
touch /tmp/test-file
case "$1" in
start)
echo "Starting script test"
touch /tmp/test-file-start
;;
stop)
echo "Stopping script test"
touch /tmp/test-file-stop
;;
restart)
echo "Restarting script test"
touch /tmp/test-file-restart
;;
force-reload)
echo "Force-reloading script test"
touch /tmp/test-file-force-reload
;;
status)
echo "Status of test"
touch /tmp/test-file-status
;;
*)
echo "Usage: /etc/init.d/test {start|stop}"
exit 1
;;
esac
exit 0
#
I made the /etc/init.d/test-script file executable and added a symlink to /etc/rc2.d/ directory:
lrwxrwxrwx 1 root root 21 Nov 2 13:19 /etc/rc2.d/S04test-script -> ../init.d/test-script
..as my default runlevel is 2 and reloaded the machine, but script was not started. As a final step I also added test to /etc/init.d/.depend.start file, but /etc/init.d/test-script was still not executed during a bootup.
Which additional steps does insserv take to install an init script?
|
In addition to symlinks to /etc/rc<runlevel>.d/ directories, insserv adds a <script_name>: line to /etc/init.d/.depend.start file. My mistake was that I added <boot_facility>: line to /etc/init.d/.depend.start file. If we take the /etc/init.d/test-script as an example which has following LSB header:
### BEGIN INIT INFO
# Provides: test
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: test script
# Description: test script
### END INIT INFO
..then one needs to add test-script: line to /etc/init.d/.depend.start not the test: line.
| Which steps does "insserv" take to install an init(System-V) script? |
1,470,427,386,000 |
Why are some deamons run out of service and some out of initctl in Ubuntu? Do both tools do the same thing and it is just a matter of personal preference of the user what they will use?
E.g.
sudo service --status-all
vs
sudo initctl list
In my particular instance cron runs out of initctl, and ssh runs out of service. But on Fedora, for example, both of those will be in systemctl.
|
Some distributions are replacing the legacy System V to manage services. Ubuntu uses upstart while Fedora uses systemd. Generally speaking do the same, but systemd is more different that upstart respect System V. upstart is based in events, whereas systemd try to do aggressive parallelization and manage not only services, but sockets, devices, etc.
HTH
| service vs. initctl in Ubuntu |
1,470,427,386,000 |
I recently acquired a laptop with a ssd and in order not to weigh too much on the ssd (which I was told had a limited number of write cycles), I decided to write a systemd unit file for setting up a swap and a filesystem (to use later with asd) respectively on devices zram0 and zram1.
I'm not really familiar with systemd and udev so I may have made a stupid error but I couldn't find it...
here are my files :
etc/udev/rules.d/10-zram.rules :
KERNEL=="zram0",SYMLINK+="zramswap" ,ATTR{disksize}="1G" ,ENV{SYSEMD_WANTS}+="zram-swap@%k.service"
KERNEL=="zram1",SYMLINK+="zramfs",ATTR{disksize}="250m", ENV{SYSTEMD_WANTS}+="zram-fs@%k.service"
/etc/systemd/system/[email protected]
[Unit]
Description="Daemon that sets xfs on %i device"
BindsTo=dev-%i.swap
After=dev-%i.device
Requires=dev-%i.device
Before=dev-%i.swap
Wants=dev-%i.swap
[Service]
Type=oneshot
ExecStart="/usr/bin/mkswap /dev/%i"
[email protected] is pretty much the same except it uses /usr/bin/mkfs.xfs (because I read xfs was fast to create)
and finally, the end of my fstab :
/dev/zram0 swap swap defaults 0 0
/dev/zram1 /media/asd xfs defaults 0 0
The problem is thar my system won't launch normally with this setup... when I try to swapon and mount these two devices, it tells me the swap and fs don't exist, and looking in journalctl -xb , there is an error while trying to mount and swapon these two devices for the same reason.
But when I look in /sys, the devices sizes are the one I set up in the udev rules so I guess my rules are read and work, the problem seems to be my service files which aren't run and/or don't work...
|
I found what were my problems... the main one is that zram is not by default handeled by systemd.
As a consequence, there was no dev-zram0.device unit, so my services failed because of the unsatisfied dependencies.
The solution was to add
TAG+="systemd"
to my udev rules
There was another little error which was the line ExecStart in the daemon needed no double quotes " and that made it fail...
Thanks anyway if anyone tried to answer !
| systemd : write a .service daemon for setting up swap and fs in zram |
1,470,427,386,000 |
When I switch from rulevel 5 to 3 (with init command) and I press CtrlAltF1 up to F7, I realize that now I’m on TTY1 instead of TTY7 and when I switch back to runlevel 5 I return back to TTY7. Why?
More generally, what’s the relationship among runlevels and virtual terminals (TTY)?
|
You can check here for the explanation of tty (teletype)
But summing up, tty 1-6 are for CLI terminal and tty7 up for GUI.
Check also here why tty7 is for X
Regarding the relationship for:
run-level 1 (single-user) you have only one tty
run-level 3 (multi-user text mode) you have by default from 1 to 6 and permits several users.
run-level 5 (multi-user graphical mode) on this level vt7 comes into play to allow you to have a GUI.
So, whenever you switch to run-level 3, you don't have the services that enable tty7. When you get back into run-level 5 the service that creates tty7 will start, hence you are back to tty7.
This is the default, of course that you can change the settings.
Nowadays and if the distro you are using has systemd, the tty are dynamically generated but if you want to force you can edit /etc/systemd/logind.conf and change the parameter #NAutoVTs=6
| Relationship among runlevels and virtual terminals (TTY) |
1,470,427,386,000 |
Every time I boot my PC (Ubuntu 20.04.2 LTS), I have a defunct process:
johan@johan-desktop:~$ ps -AF | grep qemu
libvirt+ 1596 1 0 0 0 15 07:17 ? 00:00:00 [qemu-system-x86] <defunct>
johan 4109 4099 0 2260 2688 6 07:17 pts/1 00:00:00 grep --color=auto qemu
I can kill it just fine, and the kill signal gets processed instantly:
johan@johan-desktop:~$ sudo kill -9 1596
johan@johan-desktop:~$ ps -AF | grep qemu
johan 6924 4099 0 2260 660 6 07:30 pts/1 00:00:00 grep --color=auto qemu
If I don't, the system will hang during shutdown. It'll shutdown the UI, but then get stuck after "Reached target Power-Off":
At first it didn't even show the "Waiting for process" bit, making the last bit "Reached target Power-Off" but the PC would keep running.
I do have this entry in dmesg, which also referes to qemu:
[ 12.315976] BUG: kernel NULL pointer dereference, address: 0000000000000040
[ 12.315978] #PF: supervisor read access in kernel mode
[ 12.315978] #PF: error_code(0x0000) - not-present page
[ 12.315979] PGD 0 P4D 0
[ 12.315981] Oops: 0000 [#1] SMP NOPTI
[ 12.315983] CPU: 15 PID: 1596 Comm: qemu-system-x86 Tainted: P OE 5.4.0-73-generic #82-Ubuntu
[ 12.315984] Hardware name: System manufacturer System Product Name/ROG CROSSHAIR VII HERO, BIOS 2901 10/16/2019
[ 12.315990] RIP: 0010:sev_ioctl_do_pdh_export+0x185/0x2f0 [ccp]
[ 12.315991] Code: 48 01 d0 48 0b 05 db 0c 2c cb 49 89 44 24 10 8b 45 cc 41 89 44 24 18 eb 06 45 31 ff 45 31 f6 48 8b 05 07 5d 00 00 48 8d 53 0c <83> 78 40 01 74 1b 48 89 d7 48 89 55 b0 e8 29 f5 ff ff 48 8b 55 b0
[ 12.315992] RSP: 0018:ffffa87f8248fd98 EFLAGS: 00010246
[ 12.315993] RAX: 0000000000000000 RBX: ffffa87f8248fe00 RCX: 0000000000000000
[ 12.315994] RDX: ffffa87f8248fe0c RSI: ffffffffc038e2d9 RDI: ffff9b2478407800
[ 12.315994] RBP: ffffa87f8248fde8 R08: ffff9b247ebf0080 R09: ffff9b2478407800
[ 12.315995] R10: ffff9b247ebe9ac0 R11: ffffffffffc352a6 R12: ffff9b246589f920
[ 12.315996] R13: ffff9b247875f690 R14: 0000000000000000 R15: 0000000000000000
[ 12.315997] FS: 00007f00b59735c0(0000) GS:ffff9b247ebc0000(0000) knlGS:0000000000000000
[ 12.315997] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 12.315998] CR2: 0000000000000040 CR3: 0000000feb17e000 CR4: 0000000000340ee0
[ 12.315999] Call Trace:
[ 12.316004] sev_ioctl+0x3f2/0x510 [ccp]
[ 12.316007] do_vfs_ioctl+0x407/0x670
[ 12.316008] ? putname+0x4a/0x50
[ 12.316009] ksys_ioctl+0x67/0x90
[ 12.316011] __x64_sys_ioctl+0x1a/0x20
[ 12.316014] do_syscall_64+0x57/0x190
[ 12.316017] entry_SYSCALL_64_after_hwframe+0x44/0xa9
[ 12.316018] RIP: 0033:0x7f00b6d7750b
[ 12.316019] Code: 0f 1e fa 48 8b 05 85 39 0d 00 64 c7 00 26 00 00 00 48 c7 c0 ff ff ff ff c3 66 0f 1f 44 00 00 f3 0f 1e fa b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 55 39 0d 00 f7 d8 64 89 01 48
[ 12.316020] RSP: 002b:00007fffd3258698 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
[ 12.316021] RAX: ffffffffffffffda RBX: 000055aac046fab0 RCX: 00007f00b6d7750b
[ 12.316022] RDX: 00007fffd32586b0 RSI: 00000000c0105300 RDI: 0000000000000010
[ 12.316022] RBP: 0000000000000010 R08: 0000000000000000 R09: 0000000000000005
[ 12.316023] R10: 0000000000000000 R11: 0000000000000246 R12: 00007fffd32586b0
[ 12.316023] R13: 00007fffd32587d0 R14: 00007fffd32587c8 R15: 00007fffd32586c0
[ 12.316025] Modules linked in: ip6t_REJECT nf_reject_ipv6 xt_CHECKSUM xt_MASQUERADE xt_conntrack ipt_REJECT nf_reject_ipv4 xt_tcpudp ip6table_mangle ip6table_nat iptable_mangle iptable_nat nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 libcrc32c nf_tables nfnetlink ip6table_filter ip6_tables iptable_filter bpfilter bridge stp llc aufs overlay binfmt_misc nls_iso8859_1 snd_hda_codec_hdmi snd_hda_codec_realtek snd_hda_codec_generic ledtrig_audio snd_hda_intel snd_intel_dspcfg snd_hda_codec snd_usb_audio snd_hda_core snd_usbmidi_lib snd_hwdep snd_pcm snd_seq_midi snd_seq_midi_event snd_rawmidi snd_seq uvcvideo kvm snd_seq_device videobuf2_vmalloc snd_timer videobuf2_memops videobuf2_v4l2 eeepc_wmi videobuf2_common snd asus_wmi videodev sparse_keymap joydev mc input_leds video wmi_bmof mxm_wmi ccp k10temp soundcore mac_hid nvidia_uvm(OE) sch_fq_codel parport_pc ppdev lp parport ip_tables x_tables autofs4 uas usb_storage hid_maltron hid_generic usbhid hid nvidia_drm(POE) nvidia_modeset(POE)
[ 12.316048] nvidia(POE) crct10dif_pclmul crc32_pclmul ghash_clmulni_intel aesni_intel drm_kms_helper crypto_simd cryptd syscopyarea glue_helper sysfillrect sysimgblt fb_sys_fops drm nvme igb i2c_piix4 dca i2c_algo_bit ahci nvme_core libahci gpio_amdpt wmi gpio_generic
[ 12.316056] CR2: 0000000000000040
[ 12.316057] ---[ end trace f90d6aeffb75307d ]---
[ 12.316060] RIP: 0010:sev_ioctl_do_pdh_export+0x185/0x2f0 [ccp]
[ 12.316060] Code: 48 01 d0 48 0b 05 db 0c 2c cb 49 89 44 24 10 8b 45 cc 41 89 44 24 18 eb 06 45 31 ff 45 31 f6 48 8b 05 07 5d 00 00 48 8d 53 0c <83> 78 40 01 74 1b 48 89 d7 48 89 55 b0 e8 29 f5 ff ff 48 8b 55 b0
[ 12.316061] RSP: 0018:ffffa87f8248fd98 EFLAGS: 00010246
[ 12.316062] RAX: 0000000000000000 RBX: ffffa87f8248fe00 RCX: 0000000000000000
[ 12.316062] RDX: ffffa87f8248fe0c RSI: ffffffffc038e2d9 RDI: ffff9b2478407800
[ 12.316063] RBP: ffffa87f8248fde8 R08: ffff9b247ebf0080 R09: ffff9b2478407800
[ 12.316064] R10: ffff9b247ebe9ac0 R11: ffffffffffc352a6 R12: ffff9b246589f920
[ 12.316064] R13: ffff9b247875f690 R14: 0000000000000000 R15: 0000000000000000
[ 12.316065] FS: 00007f00b59735c0(0000) GS:ffff9b247ebc0000(0000) knlGS:0000000000000000
[ 12.316066] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 12.316066] CR2: 0000000000000040 CR3: 0000000feb17e000 CR4: 0000000000340ee0
Lastly, often I have to systemctl restart libvirtd because otherwise any virsh command will just hang.
I don't even know why it's trying to run qemu at startup, I have no VMs that are expected to boot on startup.
qemu runs fine after I kill defunct process and restart libvirtd, so I'm guessing there's something at boot going funky that makes the whole thing act weird? Any ideas?
|
In the end this was resolved by upgrading to Ubuntu 22. I still have no idea what caused it.
| Defunct process on every boot, if I don't kill it, it hangs during shutdown |
1,470,427,386,000 |
I have a Raspberry PI running the standard Raspbian distribution. I have this little C program that I need to run at the very end of the shutdown sequence. All it does is send a couple of logical high pulses on a GIPO output to a power supply to tell it to cut the power to the Raspberry board. The shutdown script should be called if, and only if, the system is being powered down but not when the PI is being rebooted or started up.
I have been trying and failing to use update-rc.d to do this. The way I understand the update-rc.d documentation what I have to do is:
Copy my executable (poweroff.bin), copy it to /sbin and give it the required permissions and a LSB header:
#!/bin/sh
### BEGIN INIT INFO
# Provides: poweroff
# Required-Start:
# Required-Stop: $all
# Default-Start:
# Default-Stop: 0
# Short-Description: Power off.
# Description: Send a power off signal to the PM board.
# X-Interactive: false
### END INIT INFO
/sbin/poweroff.bin
exit 0
Create a script called poweroff in /etc/init.d
Run the command sudo update-rc.d poweroff stop 99 0.
This will yield me a script: /etc/rc0.d/K99poweroff which will call /sbin/poweroff.bin if, and only if the system is being halted.
I have three questions:
Whenever I run sudo update-rc.d poweroff stop 99 0 . it only results in a script called /etc/rc0.d/K01poweroff being created. What am I doing wrong? what happened to the 99?
What is the significance of the start and stop options during run level 0? Should this script be a K99 or an S99? there seems little point in a start script in run level 0.
Is run level 0 only used when shutting down? I.e if I do a 'shutdown -r now" does the computer get sent down to run level 0 and then back to runlevel 6?
|
The numbering requested is ignored by dependency based meta init systems. you have the wrong provides!. The critical clue is from another script. lets take a look at umountroot:
### BEGIN INIT INFO
# Provides: umountroot
# Required-Start:
# Required-Stop:
# Should-Stop: halt reboot kexec
# Default-Start:
# Default-Stop: 0 6
# Short-Description: Mount the root filesystem read-only.
### END INIT INFO
Lets look closely at the Should-Stop line. notice that it depends on halt, not poweroff. We can see this definitively by looking at debian's halt script:
### BEGIN INIT INFO
# Provides: halt
# Required-Start:
# Required-Stop:
# Default-Start:
# Default-Stop: 0
# Short-Description: Execute the halt command.
# Description:
### END INIT INFO
Note that the update script will still not call it K99, but will probably call it something like K15 unless you have a very complicated set of dependencies. but if you change your provides line to halt, it should work.
| Creating a shutdown only script with update-rc.d |
1,470,427,386,000 |
In start_kernel(), one of the first things the kernel does is run setup_arch(). setup_arch() is defined for every supported architecture, so it is passed a pointer to the appropriate command line.
How is this pointer initialized, and how and when does the kernel get the architecture of the computer?
|
A given kernel is built for a single architecture, so it has a single implementation of setup_arch. The generic start_kernel calls that, but it doesn’t pass an initialised pointer to the command line, it passes a pointer to a pointer to the command line, and it’s part of setup_arch’s job to initialise that pointer.
For example, x86 has a global command_line variable, and its setup_arch stores its address in the pointer provided by start_kernel.
So the kernel effectively gets the architecture of the computer when it’s built.
| How does the Linux kernel know the computer architecture? |
1,470,427,386,000 |
I noticed in somewhere that most of the Linux distro are based on Systemd instead of SysV init.
So I just want to know without installing and booting. Is there any possible way to find distro based on Systemd or SysV init ?
|
On distrowatch.com you can search for distributions using the init system as a criterion. You can even select "not systemd".
| How to determine a Linux distro is systemd or sysV init without installing or booting? |
1,470,427,386,000 |
I need to create a file /etc/init/start_swift.conf with following commands:
description "mount swift drives"
start on runlevel [234]
stop on runlevel [0156]
exec /opt/swift/bin/mount_devices
But the problem is that I even don't have the init directory. I have put start_swift.conf into /etc/init.d/ but it doesn't work.
How to create this type of upstart files in CentOS7?
|
There are two answers for this question.
On CentOS 7 systemd is how you can run a service or script on start
You put a .service file under /etc/systemd/system, which can look like this:
; /etc/systemd/system/swift.service
[Unit]
Description=Swift
[Service]
Type=notify
ExecStart=myscript
[Install]
; Runlevel here:
WantedBy=multi-user.target
But actually systemd can be used for mounting devices directly, if this is the intention of your script.
For a (non-rpm-packaged) service you would put the a ".mount" file under /etc/systemd/system, e.g. /etc/systemd/system/var-lib-docker.mount.
You might also want look into auto-mount options of systemd, see references.
In order to load the files, use systemd daemon-reload.
; /etc/systemd/system/var-lib-docker.mount
[Unit]
Description="Mount a volume"
Before=network.service
[Mount]
What=/dev/sdb1
Where=/var/lib/docker
;Options=
There is a lot you can tune, please refer to:
References
- https://www.freedesktop.org/software/systemd/man/systemd.service.html
- https://www.freedesktop.org/software/systemd/man/systemd.mount.html
- https://www.freedesktop.org/software/systemd/man/systemd.automount.html
| How to use Upstart scripts on CentOS7? |
1,470,427,386,000 |
What if boot like this:
Pass INIT=/bin/sh(or /bin/bash) parameter to kernel, through GRUB command line or similar ways, then boot;
Once shell is loaded, exit immediately. Then the computer has no response to any key pressed.
I am quite curious about the STATUS of the system at this moment. As I have learned that init is the first process which would be executed once kernel is loaded and other processes are all forked from it, it seems that when execute /bin/sh as described above instead of init with normal boot procedure, then system has no processes any more and nothing to do.
Is it idle like running
while (1) {
sleep(1);
}
or what else?
Thanks all of you for your advices. Maybe more information is helpful, which I used to think as unnecessary.
I worked on a CentOS 7.2 server recently, and one XFS disk partition is not normal that it cost endless time doing check and recover when system booted. I planed to edit /etc/fstab to turn off auto mounting of this partition. As normal boot procedure was stuck, I used init=/bin/bash to make system boot into bash. After edit fstab, I executed shell exit carelessly, then no response on screen to any key pressed including Ctrl-Alt-Del, and no information prompted kernel panic(I could not tell whether CPU was hard working because that room was very noisy). I regarded it as idle as just nothing to do. This phenomenon made me think about the question I wrote down at beginning.
And I made some tests tonight, on my own notebook computer with Debian 8. Kernal panic obviously.
|
I'm surprised. My understanding was that terminating PID 1 causes a kernel panic. I can tell you what happened in that case.
Panic behaviour is configurable. With the default options, you will reach a loop that looks exactly as you say.
The delay function used is documented as being a "busy-wait". It is not expected to enter the power-saving CPU sleep states used when the OS idles normally.
If you look at the backtrace printed by the panic, I think you see this all happens within sys_exit(). I think technically PID 1 doesn't get destroyed, it just never returns from making that system call. Any other CPUs are stopped first.
(There is something called a "boot idle thread". I don't see it involved in this process. AFAICT you can never see this thread. And if you wanted to understand it as an idle thread, you'd also have to ask what provides the idle thread for the other cpus once they are brought online).
| Is system totally idle if boot with INIT=/bin/sh kernel parameter then quit immediately from shell? |
1,470,427,386,000 |
How can I mount /dev from C? I'm writing a simple init, and I know this sounds stupid but I would like to have /dev mounted to another folder.
The manpages for mount() don't show dev as a supported option.
|
The manpage for mount(2) only gives examples and mentions /proc/filesystems for an exhaustie list. This latter file lists devtmpfs which is what you are looking for.
The resulting C program would then be something like:
if (mount("-", "/.../dev", "devtmpfs", 0, NULL) != 0) perror("mount");
| How can I mount /dev from C? |
1,470,427,386,000 |
On an Amazon Linux (RHEL + CentOS fusion) OS server (this is actually an EC2 instance within a EMR cluster 4.5.0 AMI if that helps), we can see –
$ ls /etc/init.d/
acpid cloud-init-local instance-controller ntpd
…..
$ ls /etc/init/
control-alt-delete.conf hadoop-yarn-resourcemanager.conf hive-metastore.conf
…..
Further we can also see the following –
$ sudo stat /proc/1/exe
File: ‘/proc/1/exe’ -> ‘/sbin/init’
$ /sbin/init --version
init (upstart 0.6.5)
which tells us that the Amazon Linux based EC2 hosts are using upstart init system during boot process.[1]
Based on this, my understanding is that –
Different daemons or services on this host are using either upstart or systemd.
systemd and upstart init systems coexist together and both of them are active at any given time. Is this possible? Is this understanding correct (including the verbiage)?
If yes, can you please let me know how can we achieve this (I do not see any ‘systemd’ named script on any of the EC2 hosts)?
Note : I think this might be a classic repeated question, but I am a little confused with multiple articles with inconclusive answers.
Ref –
[1] https://forums.aws.amazon.com/message.jspa?messageID=731256 (“Systemd is not a one-to-one drop-in replacement.“)
|
Different daemons or services on this host are using either upstart or systemd.
I suspect your system is using upstart exclusively. What makes you think systemd is involved?
systemd and upstart init systems coexist together and both of them are active at any given time. Is this possible? Is this understanding correct (including the verbiage)?
Different init systems do not coexist, and you would certainly not have more than one active at any time. They can coexist only in the limited sense that configurations might exist for both, but only one is in use at any given time.
| Can systemd and upstart coexist together on a Unix system? |
1,470,427,386,000 |
Is there any difference between these two methods for application to start on boot? I need an application to start before a logon occurs and am questioning whether or not Ubuntu's Startup Application menu will accomplish this for me. Otherwise, I can put a startup script in the init.d but then have to find some way of remebering thats where I stuck it (not be confused with /etc/rc.local which does not seem to work in Ubuntu 11.04) I have no other way of verifying that in fact the program is running without logging in at this time. Thanks.
|
Yes, there's a big difference between those. What you can setup in the "Startup Applications" menu are all applications run after the user logs on into his/her desktop environment. And scripts under /etc/init.d are system startup scripts - they affect (almost) everything that is loaded from the moment your system finishes the kernel stage of booting (when init program is executed with PID=1).
| Ubuntu 11.04 Startup Applicatation vs /etc/init.d |
1,470,427,386,000 |
I have a really basic doubt, which part creates all these directories, where is this configuration of creating directories stored while installing a new OS?
What is the order in which these directories are created? Are they created after /boot has been mounted by the kernel, by which part of the kernel?
|
The root filesystem is mounted first (readonly) at bootime, as your bootlog could tell you :
[kernel] [ 2.242830] VFS: Mounted root (ext4 filesystem) readonly on device 8:24.
It will then be remounted at init time :
[kernel] [ 2.266181] Run /sbin/init as init process
...
[kernel] [ 6.882156] EXT4-fs (sdb8): re-mounted. Opts: (null)
[kernel] [ 6.882160] ext4 filesystem being remounted at /
From there incidentally populating with (at the very least) all standard base directories (/bin, /usr, /dev, /etc…) possibly empty, possibly serving as mountpoints on which, still as part of the init process…
other disk filesystems will be mounted following /etc/fstab directives :
[kernel] [ 7.155270] EXT4-fs (sdb9): mounted filesystem with writeback data mode. Opts: data=writeback,commit=120
[kernel] [ 7.155274] ext4 filesystem being mounted at /var
[kernel] [ 7.222851] EXT4-fs (sdb10): mounted filesystem with writeback data mode. Opts: data=writeback
[kernel] [ 7.222855] ext4 filesystem being mounted at /home
This as a successful result of some init service (e.g. localmount in openrc), incidentally populating every standard directory of any *x sytem as well as possibly… even more.
BTW, since the kernel does not need /boot filesystem it might well never be mounted. It just can be, at init time, depending on /etc/fstab entries.
Network File Systems can (v.g. not necessarily) be mounted as well at init time, in a way depending on the init system (e.g. netmount service in openrc) taking care network services will have been successfully launched before as an obvious prerequisite.
Special file systems (procfs / sysfs / configfs or other virtual? pseudo? filesystems presenting non-file elements of an operating system as files) will, depending on appropriate CONFIG_* kernel tuneables be mounted at init time, depending on the init system (e.g. execution of /lib/rc/sh/init.sh for openrc) and being consequently automomagically populated.
Temporary File Systems (data is stored in volatile memory instead of a persistent storage device) can also be mounted at init time following directives found in /etc/fstab e.g.
tmpfs /tmp tmpfs rw,nosuid,noatime,nodev,size=4G,mode=1777
/dev particular case :
The /dev directory exists as per / mount together with two nodes the kernel needs at early boot time : /dev/console and /dev/null.
The kernel will add new nodes into /dev directory at boot time following devices' enumeration.
If the kernel is configured to enable temporary file systems, the nodes won't be created in the root partition :
The kernel will first mount an empty temporary file system on the /dev directory, overlaying its content.
[kernel] [ 2.262470] devtmpfs: mounted
Hence allowing the devices to be created dynamically into that filesystem as they are detected (or accessed).
Of course, Linux being a plug&play OS, the population is subject to change at runtime.
| Who actually mounts the file system and creates directories like /bin, /dev, /etc |
1,470,427,386,000 |
When I run podman run --init, I get
$> podman run --init -ti cp /sbin/init
Error: container-init binary not found on the host: stat /usr/libexec/podman/catatonit: no such file or directory
But I can easily verify that there is an init there,
$> podman run cp ls -- /sbin | grep init
init
telinit
What is catatonit? Why am I getting this error and how can I resolve it?
|
The error isn’t complaining about /sbin/init but about /usr/libexec/podman/catatonit, which points to /usr/libexec/catatonit/catatonit. The latter is provided by the catatonit package which is presumably not installed on your system (it’s only a weak dependency for podman).
On Fedora,
sudo dnf install catatonit
should fix things (but the package should be installed for you if you install podman).
On Debian, you’re running into #971815; you’ll have to either wait for a fix for that bug, or provide your own container init. One method is
sudo ln -sf /usr/bin/docker-init /usr/libexec/podman/catatonit
or configure podman to use docker-init directly instead of catatonit (in ~/.config/containers/containers.conf).
[containers]
init_path="/usr/bin/docker-init"
| podman run with --init gives me: Error: container-init binary not found on the host: stat /usr/libexec/podman/catatonit: no such file or directory |
1,470,427,386,000 |
I have a linux machine that I was accessing remotely and I made the mistake of doing #init 1 which turned off networking on the machine.
What is the easiest way to turn networking back on and/or get the machine out of single user mode?
I do have personnel that can access the machine locally if necessary.
|
You'll need the remote hands to get into the system via the console and run telinit 3 or telinit 5 if either of those were the runlevels you were using previously.
| How to turn off single user mode on a remote machine? |
1,470,427,386,000 |
I have a daemon/service (milter-regex), that is dying. I'm only using it temporarily (A few months), so don't care too much, but I want it to restart when it dies.
It is an init.d script. 'service milter-regex start' etc. The init script lives at /etc/init.d/milter-regex
I know if I have something in /etc/inittab, it will automagically respawn if it dies. Are init scripts supposed to do this as well, or do I need to put it in inittab?
It could be failing to restart as it isn't cleaning up a stale sock file, which I will fix today, but thought I'd ask the question anyway.
Running on RHEL4 (Yes, old)
Thanks, Brock
|
Scripts in init.d don't get rerun automatically when the service crashes. If you want to do the minimum amount of work to make sure it runs, inittab may be your best bet. It's icky though, almost as icky as still running RHEL 4.
| /etc/init.d/script, or /etc/inittab - respawn on die |
1,470,427,386,000 |
Last night I broke my Arch. Now, when trying to boot, it says:
[0.595364] Failed to execute /init (error -13)
: can't log to /dev/tty5
starting pid 131, tty '': '/etc/init.d/rcS'
: can't log to /dev/tty5
can't run '/etc/init.d/rcS': No such file or directory
Please press Enter to activate this console. : can't log to /dev/tty5
: can't log to /dev/tty5
: can't log to /dev/tty5
can't open /dev/tty4: No such file or directory
can't open /dev/tty3: No such file or directory
can't open /dev/tty2: No such file or directory
: can't log to /dev/tty5
process '-/bin/sh' (pid 133) exited. Scheduling for restart.
: can't log to /dev/tty5
process '-/bin/sh' (pid 134) exited. Scheduling for restart.
: can't log to /dev/tty5
process '-/bin/sh' (pid 135) exited. Scheduling for restart.
...
The messages after Please press enter keep repeating (more or less) so rapidly that I can't read them directly, I took a picture and wrote down the messages manually.
I have tried pressing Enter a few times without success.
Ctrl + Alt + Del or trying to switch to tty7, tty6 or tty1 showed no reaction.
I don't know why it complains about tty5 first.
What I did before:
I installed android-studio from the AUR (with git clone and makepkg -si).
I made updates pacman -Syu (actually I am not a 100% sure when exactly I did the updates).
Android studio tried to install the android SDK and stuff. It was claiming it had plenty of space. I don't remember the exact numbers it displayed but I was sure that the available space it displayed could not be true so I cleared roughly 35GB on my data partition (where I explicitly told it it should install the SDK) beforehand.
The process finished with several error messages that it had ran out of space.
It seems it has used hardly any of the 35GB I had freed for it on the data partition but instead tried to install on the system partition (which had less than 1 or 2GB available).
Android studio informed me that my machine was capable of accelerating the android emulator but I don't think it really tried to install KVM.
So I tried to free some space from the system partition by removing some AUR packages (around 3) which I had tried to install once but never really used (either because the installation failed or because I did not configure them appropriately or because they turned out to be something different than I needed.) For each of those I first ran pacman -Rs (which in most cases failed probably because I had not managed to install it in the first place) followed by a rm -rf.
One of those packages was cdm (a login manager) but when I uninstalled it I was absolutely sure that I am using ly instead.
What I have tried since then:
I have read what I should have read before the update:
https://www.archlinux.org/news/
but there is nothing new since the last update.
I have verified that the arch system partition is not completely full, there are still 664MB left.
I have arch-chrooted from a live stick into the system and ran pacman -Syu hoping it might tell me what is broken but it just happily installed two new packages.
I have verified that /etc/init.d/rcS does not exist (the entire directory /etc/init.d is missing).
/etc/init.d does not exist on the live stick either.
Therefore I am assuming it never existed in the first place. But why does it try executing a not-existing file all of sudden?
I think I read somewhere that this file is usually called differently on arch but I can't find that source again.
What should be executed instead of /etc/init.d/rcS and how do I tell it to do so? Or how do I recreate it if it should exist?
EDIT: I have tried booting the system with the rescue and emergency kernel parameters but they make no difference.
init=/bin/sh as kernel parameter gives the following error message:
[ 3.058545] Failed to execute /init (error -13)
/bin/sh : can't access tty; job control turned off
|
I have found the answer in /var/log/pacman.log. There were lots of lines saying "No space left on device" while trying to update mkinitcpio.
So I booted up a live stick and arch-chrooted into the arch system on my local ssd:
# loadkeys ... # change keyboard layout if needed
# mount /dev/sda1 /mnt
# arch-chroot /mnt
Removed the the files created during the installation of the android-studio which are not needed anymore (around 5GB).
Reinstalled mkinitcpio:
# pacman -Sy mkinitcpio
exit, poweroff and booted into my arch system
now it's running again.
| Failed to execute /init (error -13), can't run '/etc/init.d/rcS': No such file or directory |
1,470,427,386,000 |
I have the following myweb.service file
[Unit]
Description=myweb - A simple hello world program
After=bluetooth.service
[Service]
Type=simple
User=root
ExecStart=/usr/bin/docker run -p 2222:4343 manikanth/webapp
Restart=on-failure
[Install]
#WantedBy=multi-user.target
I purposefully disabled bluetooth.service and checked. But still the service becomes active. I thought it could be due to WantedBy and hence I commented it. The problem persists still
What's the right way not to bring up the service if the dependent service e.g. bluetooth.service is not active?
|
You are probably looking for the Requisite= option along with the After= option.
From the man page
Similar to Requires=. However, if the units listed here are not started already, they will not be started and the transaction will fail immediately.
Requires= does not work in this case is because the bluetooth.service will be started when you start myweb.service. Requisite= option will not attempt to start the bluetooth.service. However, it will show the myweb.service as failed.
| systemd After [unit] option not working |
1,470,427,386,000 |
I booted my system using in grub :
linux /boot/vmlinuz-4.5.0 root=/dev
initrd /boot/initrd-4.5.0
I set root to dev to specifically not get it to boot correctly.
Of course it falls back to the busybox stuffs; I've seen around the net that you can use mount and somehow start init. I searched around and found switch_root under /sbin and tried to use it, but to no success. How does one change the root and start init with a PID of 1? Also, my init is System V and everything is on the same partition.
|
You need to mount your root into which you will switch. I assume you already know how to do that. Basically it's just mkdir /newroot; mount -r /dev/something /newroot
Then you need to replace your currently running fallback shell. It's running with PID 1 (you can verify that with echo $$), and target init needs to get this number again. So you need an exec shell builtin to be used.
switch_root accepts at least two arguments: root directory to be switched, and init executable file name to run after switch.
So you just replace your fallback shell:
exec switch_root /newroot /sbin/init, and /sbin/init gains PID 1 again after changing root to mounted /newroot and it can continue further initialization.
| When in the fallback shell, how do you start init? |
1,470,427,386,000 |
Various older Linux distributions, which support System V type init scripts, require one to add LSB header to init script. For example a LSB header from /etc/init.d/sshd from OpenSUSE 11.4:
### BEGIN INIT INFO
# Provides: sshd
# Required-Start: $network $remote_fs
# Required-Stop: $network $remote_fs
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Description: Start the sshd daemon
### END INIT INFO
However, init scripts should be simple bash scripts where every line, which begins with # is a comment. Which utility reads those LSB headers?
|
On debian it's update-rc.d which calls insserv (which is not usually run directly). On Suse it is probably chkconfig.
You can read about it here: suse 11
(note: this all changes in openSUSE 12, which has adopted systemd).
| Which utility reads LSB headers in System V style init scripts? |
1,470,427,386,000 |
I'm running Gentoo with the default SysV-style OpenRC init system. The boot time is short enough to not bother me. Is there any reason to try systemd?
|
Ther are multiple advantages of running systemd even after booting is done, some might interest you, some might not, a quick summary:
Service Monitoring: systemd can monitor services and restart them on failure while most clients will not even notice the service has restarted.
Clean management of services: in systemd your current environment variables do not influence the environment of a manually started service.
Watchdog support: if you are on server hardware or an embedded platform (or even on some desktop platforms) you can have systemd talk to the hardware watchdog and trigger a reboot when critical services fail.
Start less on startup: while this is mostly a boot speed improvement, it also minimizes memory usage since less services are loaded into memory.
The journal: An easy and reliable logging daemon which logs more metadata than your classic syslogd, and allows you to easy filter on this information
...
for more information i redirect you to the systemd homepage
| Once the system has been started, is there any advantage in using systemd? |
1,470,427,386,000 |
I have a Debian Jessie build, and I want to add keyboard shutdown. I've tried the following, without any success:
Attempt 1
To /etc/inittab I added
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now
I also tried
ca::ctrlaltdel:/sbin/shutdown -t1 -a -r now
Then I tried to create a file /etc/init/control-alt-delete.conf and added:
start on control-alt-delete
exec /sbin/shutdown -h now "Control-Alt-Delete pressed"
Attempt 2
I also, installed kbd and to rc.local added:
loadkeys << EOF
alt keycode 103 = KeyboardSignal
EOF
And to /etc/inittab added:
kb::kbrequest:/sbin/shutdown -h now
Again nothing.
Attempt 3
To /etc/kbd/default.map.gz, I added
keycode 111 = Select
altgr control keycode 111 = KeyboardSignal
control alt keycode 111 = KeyboardSignal
And to /etc/inittab I added
kb:12345:kbrequest:/sbin/shutdown -t1 -h now
I've had no success with any of these attempts. I obviously restarted after each attempt.
My ultimate goal is to allow reboot from the login prompt page when you use console without GUI
Help is appreciated
|
sysvinit is deprecated in favor of systemd in Debian jessie. So you cannot change the system's behavior by editing /etc/inittab or /etc/init/*.conf.
When user presses Ctrl+Alt+DEL on the console, systemd invokes /lib/systemd/system/ctrl-alt-del.target which is by default a symlink to reboot.target in the same directory, that results in a simple reboot.
You can override that behavior by creating /etc/systemd/system/ctrl-alt-del.target. If you want to shut down and power off the system, make a symlink to poweroff.target:
ln -f /lib/systemd/system/poweroff.target /etc/systemd/system/ctrl-alt-del.target
See systemd's manual about special targets mentioned above.
| Shutdown with keyboard press doesn't work |
1,470,427,386,000 |
OpenSUSE 11.4 has rc<boot_facility> named symbolic links in /usr/bin/, /usr/sbin/ and /sbin/ directories:
# find / -type l -iname "rc*"
/etc/rc.d
/usr/bin/rcs2log
/usr/sbin/rcmysql
/usr/sbin/rcpcscd
/usr/sbin/rcsnmpd
/usr/sbin/rchal
/usr/sbin/rcntp
/usr/sbin/rcraw
/usr/sbin/rcfirewall
/usr/sbin/rcpowerfail
/usr/sbin/rccpufreq
/usr/sbin/rcsendmail
/usr/sbin/rcatftpd
/usr/sbin/rcdbus
/usr/sbin/rccron
/usr/sbin/rcnscd
/usr/sbin/rcsshd
/usr/sbin/rcsetserial
/usr/sbin/rcjuniper-backup
/usr/sbin/rcmdadmd
/usr/sbin/rcirq_balancer
/usr/sbin/rcrandom
/usr/sbin/rcsingle
/usr/sbin/rcrsyncd
/usr/sbin/rcsplash
/usr/sbin/rcapache2
/usr/sbin/rcrpmconfigcheck
/sbin/rcfbset
/sbin/rckbd
/sbin/rccrypto
/sbin/rcnetwork
/sbin/rcsyslog
#
What is the reason for rc<boot_facility> named symbolic links pointing to corresponding System-V type init scripts in /etc/initd/ directory? Which utilities/scripts use those symlinks?
|
Isn't that to ease typing the service command for admin? Instead of typing something like /etc/init.d/svc reload, they just use rcsvc reload directly. At least some quick googling confirms that.
| Reason for rc<boot_facility> named symbolic links in OpenSUSE |
1,382,994,068,000 |
It's a fresh install of Sabayon Linux. I installed mysql (equo install dev-db/mysql), configured it (emerge --config ...), but it doesn't start using /etc/init.d script:
# /etc/init.d/mysql start
* WARNING: mysql is already starting
# /etc/init.d/mysql status
* You are attempting to run an openrc service on a
* system which openrc did not boot.
* You may be inside a chroot or you may have used
* another initialization system to boot this system.
* In this situation, you will get unpredictable results!
* If you really want to do this, issue the following command:
* touch /run/openrc/softlevel
# /etc/init.d/mysql stop
* ERROR: mysql stopped by something else
Touching /run/openrc/softlevel causes even more errors. Googling doesn't advise much.
I remember recent OpenRC migration on my Gentoo box, but there I'm still using init.d scripts. Anything else changed I didn't notice?
|
Some of services run by process manager such as : upstart, systemd, OpenRC (your case) , SysV and so on. if get ps ax |ergep -i mysql you'll find out myql is running,
Use the following documentation: OpenRC doc
| Sabayon - mysql (and other services) won't start |
1,382,994,068,000 |
I have a virtual server running Ubuntu 14.04 LTS x64 and I want to create a persistent process that restarts with the system and when it crashes.
To do that, I've added the following lines to the "inittab" in the etc-directory:
test:5:respawn:echo "HELLO TEST" > /test.log
sometestname:234:/var/path/to/process/myprocess
After running "init q" or "telinit q", nothing happens. The test.log file isn't created, the process isn't started (It's not listed when using pstree) and there's nothing in the syslog either. Restarting the server also doesn't help.
I've also tried to use systemd to create a new service, by creating a new "myprocess.service" in "/etc/systemd/system/" with these commands:
[Unit]
Description=Process Name
[Service]
ExecStart=/var/path/to/process/myprocess
Restart=restart-always
[Install]
WantedBy=multi-user.target
Again, after a server restart the process isn't there.
Are there any other ways to create a persistent process in Ubuntu?
Also, the process acts as a server, but can also accept user inputs. Since it'll run as a background process most of the time, is it possible to "attach" it to the main console at whim to run some commands, and detach it later on? I'm using putty for remote access to the server.
|
You can use crontab. Crontab can start a process every minute, the process should check if it is already running and exit if it is. http://linux.die.net/man/1/crontab
| Create persistent process without inittab |
1,382,994,068,000 |
I know that PID 1 is init. Now I would like to knom, can I replace init process ID to another one and assign to PID 1 a new process. If yes how can I do that?
|
The first process that is started at boot time receives PID 1.
The first process that is started at boot time has a job: it has to start all other processes, directly or indirectly. All processes¹ are ultimately descendants of this, since apart from the kernel running a program at boot time the only way a process gets created is that some process executed a system call to create a new process.
The process whose PID is 1 has a job: if a process dies while it has running child processes, the children's parent process ID is set to 1. When the children die, PID 1 should reap them, i.e. call the wait system call, otherwise a zombie of the child process stays behind.
The various programs called init (there are multiple implementations) perform both of these jobs.
The Linux kernel has a command line argument to change which executable is executed as the first process². It can be used to run any executable, but if that executable doesn't perform the jobs of init, the system isn't going to run normally. This feature is mostly used to enter a system repair mode, e.g. only running a shell on the console and nothing else.
Once the system has started normally, it is not possible to replace PID 1 because init doesn't die. Not only does init not die, because it's programmed to run forever (init is supposed to keep running until the system shuts down), but it even gets a special protection from signals that would kill other processes, such as SIGKILL.
Linux has a PID namespace feature that allows defining a subsystem with its own set of process IDs. The processes in a PID namespace have different PIDs when viewed from inside the namespace and from outside the namespace. The first process in the namespace gets PID 1 in the namespace. Outside the namespace it won't have PID 1 (unless init chose to enter a new PID namespace, but init doesn't do that because that would prevent it from doing its job).
¹ This isn't completely true, some kernels have other ways to launch a process. For example Linux launches modprobe when some hardware is discovered under certain circumstances. But descendants of init account for a vast majority of processes.
² First after the initramfs or initrd.
| replacing PID 1 in linux [closed] |
1,382,994,068,000 |
I sometimes mistakenly shutdown the remote machine by using sudo init 0, so I wrote something like in one of my rc files:
alias sudo='sudo '
if [ $SSH_CLIENT ]; then
alias init 'echo Never use init when ssh'
fi
However although the rc files is executed, init still runs /sbin/init rather than the alias. And I don't like to add a global wrapper script into /usr/local/bin. Is it possible to disable sudo init 0 then? Or I have to ask the administrator for help?
|
Redefine sudo as a function:
sudo() if [ "$1" = init ] && [ -n "$SSH_CLIENT" ]; then
echo >&2 "Never use init when ssh"
return 1
else
command sudo "$@"
fi
If you want your aliases expanded after sudo, you can still add a
alias sudo='sudo '
it will still call our sudo function.
| Is there any way to disable shutdowning remote machine? |
1,382,994,068,000 |
I installed a minimal Debian system (stable) without GUI, switched to testing/jessie to be able to get the Cinnamon desktop, but X didn't start on boot. If I log in as myself at the CLI, I can type startx to launch the GUI, and I don't have any problems. So, I added the following to /etc/inittab:
# The default runlevel.
id:5:initdefault:
# ...
sx:45:once:/bin/su -c /usr/bin/startx -l bateman
This has no effect whatsoever. Why not? More importantly, how do I make it work, without installing any more software?
Edit
It looks like my /etc/inittab doesn't do anything at all.
Changing
1:2345:respawn:/sbin/getty 38400 tty1
to
1:2345:respawn:/sbin/getty -a bateman 38400 tty1
does not autologin (even after creating and adding myself to the group autologin) (a wild stab from here), and commenting out
3:2345:respawn:/sbin/getty 38400 tty3
does not disable tty3. What is going on?
|
You only have the permission to start an X session with startx if you're logged in on a console. Remote users (for example) don't get this permission. When you run /bin/su -c /usr/bin/startx -l bateman from /etc/inittab, you don't get a console so starting the X server fails.
The normal way to get a GUI at run time is to run a display manager. A display manager starts an X server and shows a login prompt in graphical mode. On Debian wheezy, you get a choice of gdm3 (Gnome look and feel), kdm (KDE look and feel), lightdm (modern, DE-independent), slim (lightweight, configurable), wdm (WindowMaker look and feel) and xdm (old-timey, Athena look and feel). What you use as the display manager is independent of what graphical environment you use after logging in: the display manager choice is up to the system administrators, and users can each use their preferred environment after logging in.
If you don't want to have to log in on the console because your computer is in a room that only you can enter, several display managers let you set up autologin. For example, with LightDM, edit /etc/lightdm/lightdm.conf and uncomment the line autologin-user= and add your username after the equal sign.
| startx autologin does not run in /etc/inittab in after Debian Jessie update |
1,382,994,068,000 |
How to determine the library or libraries being used by the /sbin/init and the /bin/sh in FreeBSD? Is it dynamically linked or static?
|
Using file and ldd:
$ file /bin/sh
/bin/sh: ELF 64-bit LSB pie executable, x86-64, version 1 (FreeBSD), dynamically linked, interpreter /libexec/ld-elf.so.1, for FreeBSD 13.1, FreeBSD-style, stripped
$ ldd /bin/sh
/bin/sh:
libedit.so.8 => /lib/libedit.so.8 (0x80108d000)
libc.so.7 => /lib/libc.so.7 (0x8010c8000)
libncursesw.so.9 => /lib/libncursesw.so.9 (0x8014d2000)
$ file /sbin/init
/sbin/init: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), statically linked, for FreeBSD 13.1, FreeBSD-style, stripped
$ ldd /sbin/init
ldd: /sbin/init: not a dynamic ELF executable
/bin/sh is dynamically linked, and /sbin/init is (not surprisingly) statically linked.
| Determine the library or libraries used by the /sbin/init and /bin/sh in FreeBSD |
1,382,994,068,000 |
When I do
ll /proc/1/exe
I get
lrwxrwxrwx. 1 root root 0 Oct 16 11:28 /proc/1/exe -> /usr/lib/systemd/systemd
Which means i am running systemd daemon not init.
But when I list
ll /etc/init.d/
I still get some services which are running by init (stripped output),
-rwxr-xr-x 1 root root 2269 Apr 22 2017 acpid*
-rwxr-xr-x 1 root root 5336 Apr 15 2016 alsa-utils*
-rwxr-xr-x 1 root root 2014 Dec 29 2014 anacron*
-rwxr-xr-x 1 root root 4335 Mar 23 2018 apparmor*
-rwxr-xr-x 1 root root 2802 Jan 3 2018 apport*
-rwxr-xr-x 1 root root 2134 Jul 7 2015 autofs*
-rwxr-xr-x 1 root root 2401 Nov 5 2015 avahi-daemon*
-rwxr-xr-x 1 root root 2968 Mar 2 2016 bluetooth*
-rwxr-xr-x 1 root root 1275 Jan 20 2016 bootmisc.sh*
-rwxr-xr-x 1 root root 2125 Apr 27 2016 brltty*
-rwxr-xr-x 1 root root 1904 Nov 18 2015 cgroupfs-mount*
-rwxr-xr-x 1 root root 3807 Jan 20 2016 checkfs.sh*
-rwxr-xr-x 1 root root 1098 Jan 20 2016 checkroot-bootclean.sh*
-rwxr-xr-x 1 root root 9353 Jan 20 2016 checkroot.sh*
-rwxr-xr-x 1 root root 1232 Aug 9 09:32 console-setup.sh*
-rwxr-xr-x 1 root root 3049 Apr 6 2016 cron*
-rwxr-xr-x 1 root root 2804 Mar 28 2018 cups*
-rwxr-xr-x 1 root root 1961 Feb 14 2016 cups-browsed*
-rwxr-xr-x 1 root root 2813 Dec 2 2015 dbus*
-rw-r--r-- 1 root root 1195 Oct 7 06:13 .depend.boot
-rw-r--r-- 1 root root 2459 Oct 7 06:13 .depend.start
-rw-r--r-- 1 root root 1926 Oct 7 06:13 .depend.stop
and a lot more services when I list,
ll /lib/systemd/system
Can someone please tell me why there are so many services running under init?
|
There is only systemd running in your system and it is starting all the services, including the ones defined in /etc/init.d.
For compatibility with older systems using traditional init (also known as "sysvinit" or "System V init"), systemd implements a mechanism by which it is able to start services using the traditional init scripts.
This compatibility layer is implemented by the systemd-sysv-generator, which looks for legacy init scripts and wraps them into native systemd service units. (For example, it will find /etc/init.d/avahi-daemon and create a /run/systemd/system/avahi-daemon.service wrapper for it, which has an ExecStart= that runs /etc/init.d/avahi-daemon start and similarly for stop and reload operations, emulating the way legacy init scripts work.)
Some distributions also provide wrappers for executables such as service and chkconfig providing further compatibility with sysvinit.
In order to check which services are defined for systemd, you can use commands such as systemctl (shows all unit files), systemctl list-units (shows active units in memory) or systemctl status service, which you can use on one of the legacy init services, since it exists in systemd through the wrapper.
| some process are started through init even i am using systemd |
1,382,994,068,000 |
I'm a little new to this so I apologize if my question is hard to follow.
I'm running Arch Linux, systemd as the init system, and I would like to boot into a plain TTY with no graphics. I've tried to disable the display manager I am currently using, as well as set the default target to multi-user, but I'm greeted with a blank screen whenever I boot up. I have to pull out the installation CD and chroot in every time this happens, as the typical keyboard shortcut to switch to a TTY does not work. How would I go about setting it up to boot into a plain TTY? Is there something I'm missing?
|
Read through this helpful page of the Arch Wiki: Systemd Targets. Systemd targets are roughly equivalent to the old runlevels when everything used the init system. Change your target from 5(multi-user graphical) to 3(multi-user no graphics). This should drop you into a terminal login screen upon boot. If you want to go graphical just type "startx."
| Booting Into a TTY with No Graphics? |
1,382,994,068,000 |
I have written my custom init (PID 1) script. In that script I have just mounted the necessary filesystems, but if I run ps aux the list is similar to below:
/ # ps aux
PID USER TIME COMMAND
1 root 0:00 /custom/init
2 root 0:00 [kthreadd]
3 root 0:00 [rcu_gp]
4 root 0:00 [rcu_par_gp]
5 root 0:00 [kworker/0:0-eve]
6 root 0:00 [kworker/0:0H-kb]
7 root 0:00 [kworker/u2:0-ev]
8 root 0:00 [mm_percpu_wq]
9 root 0:00 [ksoftirqd/0]
10 root 0:00 [rcu_sched]
11 root 0:00 [rcu_bh]
12 root 0:00 [migration/0]
13 root 0:00 [cpuhp/0]
14 root 0:00 [kworker/0:1-eve]
15 root 0:00 [kdevtmpfs]
16 root 0:00 [netns]
17 root 0:00 [kauditd]
18 root 0:00 [kworker/u2:1-ev]
21 root 0:00 [oom_reaper]
22 root 0:00 [kworker/u2:2-ev]
161 root 0:00 [writeback]
162 root 0:00 [kcompactd0]
164 root 0:00 [ksmd]
165 root 0:00 [crypto]
166 root 0:00 [kintegrityd]
167 root 0:00 [kblockd]
275 root 0:00 [kswapd0]
289 root 0:00 [kworker/u3:0]
443 root 0:00 [kthrotld]
491 root 0:00 [iscsi_eh]
518 root 0:00 [ipv6_addrconf]
527 root 0:00 [kstrp]
543 root 0:00 [ext4-rsv-conver]
544 root 0:00 [kworker/0:1H-kb]
546 root 0:00 /bin/ash
547 root 0:00 ps aux
What is creating these daemons, even though I have not handled this in my custom init script?
|
They are started by the kernel; for example, the ksoftirqd threads are started in kernel/softirq.c.
| How are the kernel daemons running automatically? |
1,382,994,068,000 |
When I see status of sysstat is see the following,
● sysstat.service - Resets System Activity Logs
Loaded: loaded (/usr/lib/systemd/system/sysstat.service; enabled;
vendor preset: enabled)
Active: active (exited) since Wed 2018-11-28 11:46:45 EST; 4s ago
Process: 4159 ExecStart=/usr/lib64/sa/sa1 --boot (code=exited,
status=0/SUCCESS)
Main PID: 4159 (code=exited, status=0/SUCCESS)
Nov 28 11:46:45 localhost systemd[1]: Starting Resets System
Activity Logs...
Nov 28 11:46:45 localhost systemd[1]: Started Resets System
Activity Logs.
Also couldn’t find any pid specified above.
Question is, why this happens?
|
Your assumption is wrong. sysstat is a "oneshot" type service, meaning it executes once and then it exits:
$ cat /usr/lib/systemd/system/sysstat.service
#... elided ...
[Service]
Type=oneshot
RemainAfterExit=yes
User=root
ExecStart=/usr/lib64/sa/sa1 --boot
#... elided ...
... which explains why there is no PID -- because there is no process any more.
The documentation for systemd services says, in part:
Behavior of oneshot is similar to simple; however, it is expected that the process has to exit before systemd starts follow-up units.
| Status of sysstat.service showing active(exited) |
1,382,994,068,000 |
I want that for a given number of system boots (say, 1 or 2 system boots), a message will appear.
I will store the message somewhere, maybe in a variable:
message='If you finished testing, make sure to remove the testing application.'!'
Notes:
I use Ubuntu server 16.04 and aim for a solution for GUI-less systems.
The purpose of the code is to have a nice way to remind myself of a certain task, if, for some reason, I didn't recall that it is a good time to do it.
I assume I should store the variable somewhere "deeper" than RAM, maybe in a file I'll create for it, maybe another method. I'm not sure.
Cron isn't good because it's repetitive, and not for a given number of executions.
This is good in case you reboot / turn off / power outage --- you get a reminder for an important task.
Clarification
I tried to describe a case when a user turnes on the machine, and in the moment the primary prompt appears, along with it, will appear the message I mentioned.
|
IMHO no purpose doing it "on boot" if there is noone to see it, so it is best made part of your login... You can call a script from your ~/.profile. The script can check if 1) the test application is still there and 2) some delay has passed since it last warned you (for instance by checking the time stamp of some file in in /var/tmp) in which case it warns you again (and touch'es the marker file).
With such a "don't pester me too often" script you can even run it each time bash returns to the command prompt by putting it in bash's PROMPT_COMMAND variable.
| Print a message a given number of times, right after system boot (init) in a GUI-less system [duplicate] |
1,382,994,068,000 |
I wrote a daemon which watches for files in certain directory and if a new file is copied to this directory, then it is committed to SVN. New files appear in this directory only if remote devices copy files there over scp. Now I would like to create a System-V init script for this daemon in OpenSUSE 11.4. It's clear that Required-Start: line should contain only the $sshd boot facility as this ensures that local file-system is mounted, networking is operational and sshd is started. Those three boot facilities are prerequisites for the daemon, i.e. there is no point to start the daemon if sshd is not operational and thus it is impossible that it receives new files over scp. However, I'm bit puzzled how should I configure the Required-Stop: line, which lists any boot facilities which should NOT be stopped before shutting down the daemon. It looks logical to me to have local file systems mounted and networking operational(for uploading the files to SVN) while sshd is stopped(for not receiving any new files) before the daemon is stopped. Required-Stop: $sshd could create a situation where daemon is stopped while a new file is received over scp before the sshd is stopped.
So in a nutshell, following approach seems to be most logical to me:
# Required-Start: $sshd
# Required-Stop: $local_fs $network
Am I correct?
|
According to https://wiki.debian.org/LSBInitScripts in the section on Required-Stop
Normally you would include here the same facilities as for the
Required-Start keyword.
Having this script running before ssh starts isn't a problem like you suggested in the OP it just means this daemon will be waiting for files that will never appear until ssh starts. This script, however, definitely does need the functionality of $local_fs and $network so I would use the following two lines
# Required-Start: $local_fs $network
# Required-Stop: $local_fs $network
| "Required-Stop:" line in System-V type init script LSB header |
1,382,994,068,000 |
One argument I hear often about systemd is that it more adapted to current hardware needs, e.g. here
Computers changed so much that they often doesn’t even look like
computers. And their operating systems are very busy : GPS, wireless
networks, USB peripherals that come and go, tons of softwares and
services running at the same time, going to sleep / waking up in a
snap… Asking the antiquated SysVinit to manage all this is like asking
your grandmother to twerk.
What I don't understand is how an init system manages hot pluggable devices.
What does replacing a hot plugable disk drive it have to do with how the system is booted?
Maybe this all done at the none init parts of systemd?
I know this is a hot topic for some people. It is not meant to ignite a war, rather to understand.
Please explain it to me with out flames.
|
Systemd reimplements many functionalities previously scattered over the whole OS (eg. in udev daemon), and is able to recognize that device was just plugged in or out.
At the same time, systemd holds all system services configuration: what need to be run, how to run it etc. And simply, it has all knowledge needed to start, stop, or even reconfigure services related to hot pluggable devices.
Classic init system doesn't manage hot pluggable devices at all. It just starts services in a defined order and that's mostly all.
One of such services is udev daemon, which handles hot pluggable devices. But it's not able to start a service, when device is plugged in, at least without custom scripts made for local machine.
| systemd in the era of hotplugable devices |
1,382,994,068,000 |
I am building a small embedded system for a x86_64 target, with a Linux kernel and an initramfs which contains a dynamically linked busybox.
I tried to install the needed libraries (libm.so.6, libc.so.6) into /lib and the linker ld-linux-x86-64.so.2 into /lib64( because the busybox binary request it at this place).
lib
├── libc.so.6
└── libm.so.6
lib64
└── ld-linux-x86-64.so.2
but it failed to link:
/sbin/init: error while loading shared libraries: libm.so.6: cannot open shared object file: No such file or directory
I managed to make it work by moving everything in /lib64:
lib64
├── ld-linux-x86-64.so.2
├── libc.so.6
└── libm.so.6
or by creating a symlink between /lib and /lib64
lib
├── ld-linux-x86-64.so.2
├── libc.so.6
└── libm.so.6
lib64 -> lib
But I still don't understand why the first configuration do not work. Why the linker is not able to find libraries in /lib ?
EDIT: To make it working properly (Thanks to yaegashi):
Go into your initramfs root directory.
Create a file /etc/ld.so.conf with the library path you need.
echo /lib > etc/ld.so.conf
Generate your ld.so.cache file.
ldconfig -r .
Re generate your initramfs. It's done
|
Read the manual of ld.so (the dynamic linker/loader). The actual search paths are mainly determined by /etc/ld.so.cache (which is compiled from /etc/ld.so.conf by ldconfig) or built-in paths in your ld.so binary. So check your platform configurations and how you built your glibc.
You can watch detailed activities of ld.so by running any binary with LD_DEBUG=libs set in the environment variable.
$ LD_DEBUG=libs ls
17441: find library=libselinux.so.1 [0]; searching
17441: search cache=/etc/ld.so.cache
17441: trying file=/lib/x86_64-linux-gnu/libselinux.so.1
17441:
17441: find library=libacl.so.1 [0]; searching
17441: search cache=/etc/ld.so.cache
17441: trying file=/lib/x86_64-linux-gnu/libacl.so.1
17441:
17441: find library=libc.so.6 [0]; searching
17441: search cache=/etc/ld.so.cache
17441: trying file=/lib/x86_64-linux-gnu/libc.so.6
...
| The linker does not find libraries in /lib |
1,382,994,068,000 |
Possible Duplicate:
Add item to inittab on OpenSuse 12.1
I have the following entry in my /etc/inittab (on OpenSuse 12.1):
gp:2345:respawn:/usr/local/gpm/bin/gpsrvd
Which won't execute no matter what I try to do.
comment it out
run init q
uncomment it
run init q again
Still it will not run!
I then run it manually as root:
lorraine:/home/joseph # /usr/local/gpm/bin/gpsrvd &
[1] 5646
and it runs :
lorraine:/home/joseph # ps aux | grep gpsr
root 5646 0.0 0.0 45960 2276 pts/0 S 12:24 0:00 /usr/local/gpm/bin/gpsrvd
So, what could be different when running this via init? Does the init behavior vary in 12.1 that it was on earlier versions of OpenSuse?
Thanks in advance for constructive answers...
|
OpenSuse 12.1 has switched to systemd which doesn't use /etc/inittab anymore but /etc/systemd/ with separate configuration files instead.
| Why process will not start in Inittab [duplicate] |
1,382,994,068,000 |
I made a bit of research on the matter and also asked ChatGPT, but there doesn't seem to be a way to measure full boot time of an alpine distribution with OpenRC.
Using dmesg, I can see the last message [ 0.689037] Run /sbin/init as init process
But I want to know how much time it took to "complete" the init process. My use case is boot time sensitive, that's why I'm asking.
Note I was able to boot an ubuntu 22.04 with systemd in 1s including kernel boot. In systemd, systemd-analyze is very useful. So I hope there is an equivalent (or a way) in openRC.
|
First, install coreutils in order to get millisecond precision in alpine.
apk add coreutils
Then, we will create two services:
In /etc/init.d/boot-start
#!/sbin/openrc-run
description="Boot Start Service"
start() {
ebegin "Starting boot-start"
date +%s%3N > /var/boot-time.log
eend $?
}
And in /etc/init.d/boot-end
#!/sbin/openrc-run
description="Boot End Service"
depend() {
after *
}
start() {
ebegin "Starting boot-end"
boot_start_time=$(cat /var/boot-time.log)
boot_end_time=$(date +%s%3N)
duration=$((boot_start_time - boot_end_time))
echo "Boot started at: $boot_start_time" > /var/boot-time.log
echo "Boot ended at: $boot_end_time" >> /var/boot-time.log
echo "Total duration: $duration milliseconds" >> /var/boot-time.log
eend $?
}
And then we'll start the first at boot and the second last
chmod +x /etc/init.d/boot-start
rc-update add boot-start boot
chmod +x /etc/init.d/boot-end
rc-update add boot-end default
The result will look like this
Boot started at: 1686811355808
Boot ended at: 1686811357194
Total duration: -1386 milliseconds
| How to know the boot time (kernel + init) in Alpine using openRC? |
1,382,994,068,000 |
I am aware that the reason you can't install runit or openrc on a distro and expect it to work is that some packages and stuff rely on systemd. What exactly do they rely on? The systemctl command? What is systemd-specific here?
|
For the most part, the desktop environments require the component activation logic provided by dbus, which now pretty much requires systemd, and there are a few features that depend on having a declarative configuration interface to activate and deactivate features.
For example, having a dropdown button that lets the user select whether the machine suspends, hibernates or ignores it when the user closes the lid requires systemd-logind, because it is the only existing implementation that has a corresponding setting.
The traditional Unix daemons largely don't care whether they are started from systemd and usually don't profit much from it.
| What packages in a systemd distro rely on it? |
1,382,994,068,000 |
I have found some chinese characters in one of a file on my linux mint 20.1
File - /proc/1/cmdline
Chinese Characters - 猯楢⽮湩瑩猀汰獡h
But when i open same file in terminal using less command, it shows : /sbin/init^@splash^@
Is this normal or is there anything to worry about in terms of security?
|
If you take the nul-terminated strings /sbin/init and splash, and convert them from the UCS-2LE (or UNICODELITTLE, or UCS-2-INTERNAL) encoding using iconv, you get
$ printf '/sbin/init\0splash\0' | iconv -f UCS-2LE
猯楢⽮湩瑩猀汰獡h
The output from less is more correct. The less utility shows nul bytes (\0) as ^@.
Conclusion: The "Chinese text" that you are seeing is due to your editor determining that the data is encoded as UCS-2LE (for whatever reason). It is not actually Chinese but simply the two nul-terminated strings /sbin/init and splash.
There is nothing you need to worry about.
For more information about /sbin/init splash see:
ps axf shows "/sbin/init splash" for PID1
Splash in PID =1
Additionally, you should not expect a text editor to be able to correctly understand the contents of the virtual file /proc/1/cmdline as it's not a text file. This is probably why your text editor tried to determine the file's encoding, but failed to do so correctly.
See: Encoding of /proc/<pid>/cmdline files
| Chinese Characters in One of a File |
1,382,994,068,000 |
I newly installed Fedora 30 on a machine then I installed Oracle Database 12c and restored a really big dump (took two days). Then, I installed samba server and shared a folder with that.
After that, I rebooted the system for the first time, but it didn't boot up saying:
[!!!!!!] Failed to start up manager
and nothing else (the system freezes and doesn't respond to any key).
I can currently get a root shell by using rd.break kernel parameter and chrroting to sysroot, but I don't have networking and I can't use systemctl.
I also ran fsck on the computer's disk (using live os) and it says there is no error in filesystem.
I also found the code generating this error in systemd source code here.
How can I boot my system normally, get networking and systemctl working
|
OK, I found the answer myself.
After removing the quiet kernel option it showed some errors about the SELinux contexts.
The problem was the selinux kernel module.
I started the system with selinux=0 kernel option in grub to prevent selinux from loading and it worked!
| Fedora 30 can't boot: faild to start up manager |
1,382,994,068,000 |
I had a question earlier, it is tied into this, that one was looking for the proper procedure, this one is looking how to implement. If you need a backstory refer to My first question
I have a local device. I am the only one I want to have "local access". lets call this device charles.local
I want to have it, so when I do addusr bob it spins up a VM bob.charles.local
When bob is at the computer, and logs in, it drops him into his little environment instead of
I know how to spin up a VM, a full instance with an OS, not what I am looking to do, but I can make mods where needed, I know how to manage a local computer using linux, I know how to fdisk create loop dev's.
Would init be able to handle the login process that I am aiming for, so when the login screen pops up, and bob logs in, it automatically drops him in the VM, or would I need a separate login server, such as kerberus?
Is it possible to spin up a VM with only 1 user, no additional user to be added and make it look like bob just logged into the computer like normal.
I was able to track down, skel, login, logout, adduser, deluser, passwd, shadow, config files, would I have to modify the initd config? are there any other configs I need to get this ball running?
Do I need any other specific software outside of a VMM?
I am trying to get a local device setup, so that a class can login to a machine, and have 0 access to the actual machine so they can tinker with root without disrupting the other students, and with minimal input from them... Basically, the only input to the local machine they can do is their user name and password. Everything else would be handled in their environment.
|
I don't have enough points to comment, but there's some chance this might also answer your question.
If I'm understanding you correctly, you want to allow local user logins, and once a user is logged in, spin up a new VM from scratch and auto-configure a user session of the same name? That could get pretty hair very quickly, if I'm understanding your requirement correctly.
How about this instead, which sounds like your intended goal--a "kiosk" mode except where the user has unlimited local power even to destroy the whole OS, but it's easily reset. (In this case, automatically.) The only difference, I think, is that there are no specific individual user sessions involved, because for this idea to work, individual user sessions aren't actually needed, and in fact complicate things. (But if individual user sessions ARE a requirement, then at least this solution could still get you started in the right direction. Think "read-only, immutable Base VM disk image that is accessible by all users, but each user has their own VM definition file and read/write differencing disk, both of which get deleted and restored with each login.)
First some quick definitions:
"Host", or "Machine": The physical machine. Might be running Windows, MacOS, or Linux, it shouldn't matter too much--each of those can be configured this way, although it's not always obvious how to intercept logouts and shutdowns in any of them. (I know both can be done in Windows and Linux, and strongly suspect in MacOS. All of them can also be configured for auto-login on startup.)
"VM", "virtual machine", or "guest": A virtual machine running on a host machine. By the sounds of it, you want this to be Linux, but it could just as easily be Windows, except for potential licensing headaches. (E.g. if a user screws up the licensing, that screw-up persists even if the OS itself starts completely over from a checkpoint.)
Every host machine will have a single "user" session, and within that user session, a single, transparent guest session. The user will only see or necessarily know of the existence of, the guest session. (But the security of the host session shouldn't--and doesn't have to--rely on that obscurity.)
General steps:
Set up the host machine to automatically log into one locked-down user account upon startup, e.g. "vmuser". Deactivate session timeout/lock, and screensaver. (Screen power off OK but without locking the session.)
Create a VM for that user session, with an immutable disk and a differencing file, or a snapshot to roll back to.
Upon initial host login (at startup), have a login script launch a VM session in full screen mode (with an obscure redefined "host" key. e.g. scroll lock). That script should wait until the VM powers down, because it will have more work to do later.
That VM also then auto-logs-in to root, or a user with admin rights.
Guest logout script: Shut down the whole VM.
Once the VM shuts down, your login script resumes. It rolls the back to a predefined snapshot. If the host user session is not also ending, that script should then start the VM back up again. (It then auto-logs in again and your back and rolling with a fresh new session.)
Host logout script: You'll need to communicate with the login script in one of myriad possible ways, to either abort it, or tell it to not start the VM back up after doing its rollback stuff. Either way, what you want to happen is to power off the VM (even a "hard" power off is acceptable). Rolls the VM back to snapshot. Then either have the host auto-logs back in again (which would require a service or daemon watching and would result in a clean restored VM coming back up), or power-down the host machine completely.
If the user shuts down the host, the same thing happens as logging out (because the user session first logs out), except you'd want to communicate with that script to preempt logging back in, or shutting down the host (redundantly).
Whenever the host user session logs in (which ironically may be more reliable in terms of timing than doing this on host startup), the login script should always roll the VM back to snapshot before starting it up (or at least check to make sure), just in case it wasn't cleanly shut down last time. Or if you REALLY want to be robust, a host machine startup script could do all the cleanup it needs to--deleting any files potentially used for inter-process communication, rolling back the VM just in case, etc.--all the while the login script, if inevitably initiated while all this is going on, waits until that process is done before proceeding.
This way, the user can do whatever they want in the VM, including "rm -rf /", and a VM shutdown, a logout of the host user session, or a host reboot will restore it automagically. As long as the host user session is reasonably well locked down and secure, and the immutable VM disk not user-deletable (which would be a good reason to set it up that way rather than snapshots), then it would be REALLY hard for users to screw the system up, even if they broke out of the VM. (That said, anyone with physical access can compromise a computer. And it should go without saying--therefore I wish it didn't need to be said--that any exploits to the host OS could also compromise your solution. But at least exploits to the guest are mostly moot in terms of permanent guest OS damage, as it gets rolled-back/reset anyway.)
I'm pretty confident something along these lines is possible, reasonably close to what was outlined--because I know each of the individual steps are possible and have done many of them myself.
Your general need is something along the idea of "kiosk-mode", which you can Google for. Granted, kiosk modes usually also involve locking down the user's experience, which is the opposite of what you want, but there may be some ideas out there that get you close, or similar to this but with different tech (e.g. containers).
Good luck!
| Setting up VM login instead of Local login [closed] |
1,382,994,068,000 |
I'm using Amazon Linux. I just Apache via yum, however, I can't get it to automatically start when I reboot my server, despite the fact it starts on the command line ...
[myuser@mymachine ~]$ sudo service httpd start
[sudo] password for myuser:
Starting httpd: httpd: apr_sockaddr_info_get() failed for mymachine
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[ OK ]
[myuser@mymachine ~]$ telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
I have set up these links below, with the following permissions. The configuration file was crated automatically for me upon installation ...
[myuser@mymachine ~]$ ls -al /etc/init.d/httpd
-rwxr-xr-x 1 root root 3371 Sep 15 20:58 /etc/init.d/httpd
[myuser@mymachine ~]$ ls -al /etc/rc3.d/*httpd*
lrwxrwxrwx 1 root root 15 Oct 18 22:03 /etc/rc3.d/K15httpd -> ../init.d/httpd
[myuser@mymachine ~]$ cat /etc/init.d/httpd
#!/bin/bash
#
# httpd Startup script for the Apache HTTP Server
#
# chkconfig: - 85 15
# description: The Apache HTTP Server is an efficient and extensible \
# server implementing the current HTTP standards.
# processname: httpd
# config: /etc/httpd/conf/httpd.conf
# config: /etc/sysconfig/httpd
# pidfile: /var/run/httpd/httpd.pid
#
### BEGIN INIT INFO
# Provides: httpd
# Required-Start: $local_fs $remote_fs $network $named
# Required-Stop: $local_fs $remote_fs $network
# Should-Start: distcache
# Short-Description: start and stop Apache HTTP Server
# Description: The Apache HTTP Server is an extensible server
# implementing the current HTTP standards.
### END INIT INFO
# Source function library.
. /etc/rc.d/init.d/functions
if [ -f /etc/sysconfig/httpd ]; then
. /etc/sysconfig/httpd
fi
# Start httpd in the C locale by default.
HTTPD_LANG=${HTTPD_LANG-"C"}
# This will prevent initlog from swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""
# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
# with the thread-based "worker" MPM; BE WARNED that some modules may not
# work correctly with a thread-based MPM; notably PHP will refuse to start.
# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/sbin/apachectl
httpd=${HTTPD-/usr/sbin/httpd}
prog=httpd
pidfile=${PIDFILE-/var/run/httpd/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
RETVAL=0
STOP_TIMEOUT=${STOP_TIMEOUT-10}
# The semantics of these two functions differ from the way apachectl does
# things -- attempting to start while running is a failure, and shutdown
# when not running is also a failure. So we just do it the way init scripts
# are expected to behave here.
start() {
echo -n $"Starting $prog: "
LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}
# When stopping httpd, a delay (of default 10 second) is required
# before SIGKILLing the httpd parent; this gives enough time for the
# httpd parent to SIGKILL any errant children.
stop() {
echo -n $"Stopping $prog: "
killproc -p ${pidfile} -d ${STOP_TIMEOUT} $httpd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
reload() {
echo -n $"Reloading $prog: "
if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
RETVAL=6
echo $"not reloading due to configuration syntax error"
failure $"not reloading $httpd due to configuration syntax error"
else
# Force LSB behaviour from killproc
LSB=1 killproc -p ${pidfile} $httpd -HUP
RETVAL=$?
if [ $RETVAL -eq 7 ]; then
failure $"httpd shutdown"
fi
fi
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p ${pidfile} $httpd
RETVAL=$?
;;
restart)
stop
start
;;
condrestart|try-restart)
if status -p ${pidfile} $httpd >&/dev/null; then
stop
start
fi
;;
force-reload|reload)
reload
;;
graceful|help|configtest|fullstatus)
$apachectl $@
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|reload|status|fullstatus|graceful|help|configtest}"
RETVAL=2
esac
exit $RETVAL
Yet after a server restart, things aren't running (I can't connect on Telnet via port 80). What else do I need to do to get this to start upon reboot?
|
[myuser@mymachine ~]$ ls -al /etc/rc3.d/*httpd*
lrwxrwxrwx 1 root root 15 Oct 18 22:03 /etc/rc3.d/K15httpd -> ../init.d/httpd
That is your problem. Script that start with K, which stands for kill, in /etc/rc3.d will not start at boot time, scripts that start with S will.
If you do:
[myuser@mymachine ~]$ mv /etc/rc3.d/K15httpd /etc/rc3.d/S15httpd
Your problem will be solved.
However, that's the manual thing to do. the best way would be to use the chkconfig command like so:
[myuser@mymachine ~]$ chkconfig httpd on
| Why isn't my Apache server starting automatically wnen I reboot my server? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.