Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

0 votes
0 answers
17 views
How to config uboot loglevel to get debug logs on boot
The problem is while booting up rasbberry pi with uboot as boot loader not able to decrypt encrypted rootfs partition with initramfs,to debug and analyse what happening want to enable uboot debug logs. When checked with current loglevel in Kconfig it show default i.e. CONFIG_LOGLEVEL=4 these are boo...
The problem is while booting up rasbberry pi with uboot as boot loader not able to decrypt encrypted rootfs partition with initramfs,to debug and analyse what happening want to enable uboot debug logs. When checked with current loglevel in Kconfig it show default i.e. CONFIG_LOGLEVEL=4 these are boot logs : U-Boot 2024.04 (Apr 02 2024 - 10:58:58 +0000) DRAM: 948 MiB (effective 7.9 GiB) RPI 4 Model B (0xd03114) Core: 213 devices, 16 uclasses, devicetree: board MMC: mmcnr@7e300000: 1, mmc@7e340000: 0 Loading Environment from MMC... *** Warning - bad CRC, using default environment In: serial,usbkbd Out: serial,vidconsole Err: serial,vidconsole Net: eth0: ethernet@7d580000 PCIe BRCM: link up, 5.0 Gbps x1 (SSC) starting USB... Bus xhci_pci: Register 5000420 NbrPorts 5 Starting the controller USB XHCI 1.00 scanning bus xhci_pci for devices... 2 USB Device(s) found scanning usb for storage devices... 0 Storage Device(s) found Hit any key to stop autoboot: 0 Card did not respond to voltage select! : -110 ethernet@7d580000 Waiting for PHY auto negotiation to complete......... TIMEOUT! bcmgenet: PHY startup failed: -110 ethernet@7d580000 Waiting for PHY auto negotiation to complete......... TIMEOUT! bcmgenet: PHY startup failed: -110 U-Boot> updated the common/Kconfig default to 7 still cannot see any change in the logs kconfig snippet: config LOGLEVEL int "loglevel" default 7 range 0 10 help All Messages with a loglevel smaller than the console loglevel will be compiled in. The loglevels are defined as follows: 0 - emergency 1 - alert 2 - critical 3 - error 4 - warning 5 - note 6 - info 7 - debug 8 - debug content 9 - debug hardware I/O don't know if im able to config it correctly or are there other config parameters need to configure and which are those please let me know if any one has done this before.
URegal (1 rep)
Jul 26, 2025, 07:58 AM
0 votes
2 answers
2277 views
is there a proper way to shut down from single user mode
I've found a lot of inconsistent documentation on single user mode. I don't need to use it often, but I get curious, and I remember not being to use shut down commands in single user mode and pressing the reset button. Is there a better way to leave single user mode after resetting passwords?
I've found a lot of inconsistent documentation on single user mode. I don't need to use it often, but I get curious, and I remember not being to use shut down commands in single user mode and pressing the reset button. Is there a better way to leave single user mode after resetting passwords?
volare (11 rep)
Mar 27, 2019, 03:37 AM • Last activity: Jul 21, 2025, 09:08 PM
0 votes
0 answers
39 views
Docker attach on a container running /sbin/init
I run a Cisco XRd docker container on my Linux Ubuntu host. I run the image using `docker run -it -d` command. The image's entrypoint is `/usr/sbin/init`, indeed: root@eve-ng-6:/opt/unetlab/html# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2ed1b2e66197 ios-xr/xrd-control-plane:la...
I run a Cisco XRd docker container on my Linux Ubuntu host. I run the image using docker run -it -d command. The image's entrypoint is /usr/sbin/init, indeed: root@eve-ng-6:/opt/unetlab/html# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2ed1b2e66197 ios-xr/xrd-control-plane:latest "/usr/sbin/init" 20 hours ago Up 3 hours 75bc86e8-108a-4300-863a-2141b5718b55-0-2 root@eve-ng-6:/opt/unetlab/html# Then by using docker attach, I can attach to the running docker container. Af far as I understand, see Comparing Docker Exec and Docker Attach , docker attach does not start any new process within the container but simply attaches the current terminal to the stdin/stdout/stderr of the container's primary process (i.e. to the process running the image's entrypoint). In my case it is /usr/sbin/init from Cisco XRd. My question: is the /usr/sbin/init process that is actually "talking" with the user (me) by reading and writing to the attached pseudo-terminal ? P.s. note that a pseudo-terminal is allocated by virtue of the -d option in docker run command.
CarloC (385 rep)
May 30, 2025, 04:31 PM • Last activity: May 30, 2025, 05:07 PM
110 votes
23 answers
77752 views
Detect init system using the shell
This may have more to do with detecting operating systems, but I specifically need the init system currently in use on the system. Fedora 15 and Ubuntu now use systemd, Ubuntu used to use Upstart (long time default until 15.04), while others use variations of System V. I have an application that I a...
This may have more to do with detecting operating systems, but I specifically need the init system currently in use on the system. Fedora 15 and Ubuntu now use systemd, Ubuntu used to use Upstart (long time default until 15.04), while others use variations of System V. I have an application that I am writing to be a cross-platform daemon. The init scripts are being dynamically generated based on parameters that can be passed in on configure. What I'd like to do is only generate the script for the particular init system that they are using. This way the install script can be run reasonably without parameters as root and the daemon can be "installed" automagically. This is what I've come up with: * Search for systemd, upstart, etc in /bin * Compare /proc/1/comm to the systemd, upstart, etc * Ask the user **What would be the best cross/platform way of doing this?** Kind of related, **Can I depend on bash to be on the majority of *nix or is it distribution/OS dependent?** Target platforms: * Mac OS * Linux (all distributions) * BSD (all versions) * Solaris, Minix, and other *nix
beatgammit (7843 rep)
Aug 6, 2011, 11:29 PM • Last activity: Mar 31, 2025, 02:48 PM
1 votes
3 answers
9866 views
Understand the /etc/inittab
I am using the following `/etc/inittab` file (systemv): ``` # /etc/inittab: init(8) configuration. # $Id: inittab,v 1.91 2002/01/25 13:35:21 miquels Exp $ # The default runlevel. id:5:initdefault: # Boot-time system configuration/initialization script. # This is run first except when booting in emer...
I am using the following /etc/inittab file (systemv):
# /etc/inittab: init(8) configuration.
# $Id: inittab,v 1.91 2002/01/25 13:35:21 miquels Exp $

# The default runlevel.
id:5:initdefault:

# Boot-time system configuration/initialization script.
# This is run first except when booting in emergency (-b) mode.

si::sysinit:/etc/init.d/rcS

# What to do in single-user mode.
~~:S:wait:/sbin/sulogin

# /etc/init.d executes the S and K scripts upon change
# of runlevel.
#
# Runlevel 0 is halt.
# Runlevel 1 is single-user.
# Runlevels 2-5 are multi-user.
# Runlevel 6 is reboot.

l0:0:wait:/etc/init.d/rc 0
l1:1:wait:/etc/init.d/rc 1
l2:2:wait:/etc/init.d/rc 2
l3:3:wait:/etc/init.d/rc 3
l4:4:wait:/etc/init.d/rc 4
l5:5:wait:/etc/init.d/rc 5
l6:6:wait:/etc/init.d/rc 6
# Normally not reached, but fallthrough in case of emergency.
z6:6:respawn:/sbin/sulogin
S0:12345:respawn:/sbin/getty -L 115200 ttyS0
In order to understand how things really work I'll appreciate if your answers to 1-3 you'll distinguish between two situations: 1. I'm connected to my system using a serial port. 2. I have a "regular" desktop pc. Questions: 1. If I'll add another getty line, once linux startup I will see two separate terminals? 2. If I open several getty lines, how I assigned which getty will run my si::sysinit:/etc/init.d/rcS command and which getty will run the other script's commands? (the ones who run scripts according to the system run level) in other words: in the /etc/inittab file - can i assign different commands to different gettys? (i mean to the terminals which will open by these gettys) 3. the last script in /etc/init.d/rc5 folder run the following command:
su nobody -c /bin/sh
and the output is:
sh: cannot set terminal process group (1618): Inappropriate ioctl for device
    sh: no job control in this shell
    sh-4.3$ whoami
    nobody
So I verified that i am nobody but why it writes the first two lines? also why the prompt is sh-4.3$ and not nobody@... 4. I'm using serial connection. Can I change the /etc/inittab file and the last script that will run by init in order to: 1. run a program before login as low privileged user (init process will wait for termination) 2. once the program exits get the regular login prompt to my system 3. what is the best way to create a low privileged user and let him run this program during init process (if I don't want to use the nobody user)
hutcruchi (399 rep)
Nov 5, 2019, 07:58 AM • Last activity: Feb 13, 2025, 05:02 AM
0 votes
0 answers
39 views
Kernel Boot custom init script and rootfs
i am using passing a script as init= for kernel boot. I use this script to setup overlayfs using two partitions on an mmc device. This works fine. I use root=/dev/mmcblk0p1 as the root. at boot, i want to be able to update the p1 partition with new data from mmcblk0p3. Since p1 is mounted at root i...
i am using passing a script as init= for kernel boot. I use this script to setup overlayfs using two partitions on an mmc device. This works fine. I use root=/dev/mmcblk0p1 as the root. at boot, i want to be able to update the p1 partition with new data from mmcblk0p3. Since p1 is mounted at root i cant seem to find a way to umount it so i can blast it with new data and remount it again so i can proceed with regular boot sequence. Is it possible to do switch root or pivot root away from mmcblk0p1 to say mmcblk0p3 and switch back? system is an arm based cpu with uboot
RookieBeotch (1 rep)
Feb 4, 2025, 09:50 PM • Last activity: Feb 5, 2025, 06:40 AM
2 votes
2 answers
1142 views
Alpine Linux in Raspberry Pi not activating swap partition on boot
Probably this is a really naïve question, but I can’t make this work by trying the methods I’ve found in the existing documentation or in other solutions. I have Alpine Linux installed on a Raspberry Pi, which SD card is formatted to have the usual boot partition and an ext4 to host `/`, I adde...
Probably this is a really naïve question, but I can’t make this work by trying the methods I’ve found in the existing documentation or in other solutions. I have Alpine Linux installed on a Raspberry Pi, which SD card is formatted to have the usual boot partition and an ext4 to host /, I added a swap partition since my Pi has not much RAM. The issue is that the swap partition does not activates at boot. As far as I’m aware, the conventional method to configure a dedicated swap partition, is to declare it on the /etc/fstab file. This does not work, so my other approach was to try making a script in the /etc/init.d folder to force its activation. To my surprise, an init.d file already exists in this build to do exactly that, which is the /etc/init.d/swap, which reads as follows.
lang-sh
depend()
{
        after clock root
        before localmount
        keyword -docker -jail -lxc -openvz -prefix -systemd-nspawn -vserver
}

start()
{
        ebegin "Activating swap devices"
        case "$RC_UNAME" in
                NetBSD|OpenBSD) swapctl -A -t noblk >/dev/null;;
                *)              swapon -a >/dev/null;;
        esac
        eend 0 # If swapon has nothing todo it errors, so always return 0
}

stop()
{
        ebegin "Deactivating swap devices"
        case "$RC_UNAME" in
                NetBSD|OpenBSD) swapctl -U -t noblk >/dev/null;;
                *)              swapoff -a >/dev/null;;
        esac
        eend 0
}
Somehow, this does not run properly, neither the /etc/init.d/swap.apk-new which has the exact same contents as /etc/init.d/swap. I know that the /etc/fstab is properly configured as running swapon -a >/dev/null activates the swap partition the intended way! Yet Alpine refuses to do this at boot despite being declared already… Am I missing something? I know I can activate the swap manually each time I turn on the device, but I’m sure the system should do it automatically on boot. If it serves of any help, the line I added in /etc/fstab reads as follows.
lang-sh
UUID= none swap defaults 0 0
And swapon -a recognizes the partition. This Alpine build was made using the sys install, and its specs are the followings
OS:     Alpine Linux v3.18 aarch64
Host:   Raspberry Pi 3 Model B Rev 1.2
Kernel: 6.1.37-0-rpi
Thanks in advance.
user578535
Jul 8, 2023, 06:59 PM • Last activity: Jan 26, 2025, 04:42 AM
1 votes
0 answers
77 views
Initramfs for Live CD of Linux distribution
I have problems with creating initramfs for ISO live cd. I don't know whats wrong with `init` script in initramfs, you can see below the screenshots about trying to boot kernel and initramfs, the first screenshot is booting in VM with UEFI, the second screenshot - VM with legacy firmware (BIOS): [![...
I have problems with creating initramfs for ISO live cd. I don't know whats wrong with init script in initramfs, you can see below the screenshots about trying to boot kernel and initramfs, the first screenshot is booting in VM with UEFI, the second screenshot - VM with legacy firmware (BIOS): In VM with UEFI In VM with BIOS I'm running ISO in Hyper-V. And there is a code of init script:
#!/busybox

# Mount essential filesystems
mount -t proc none /proc
mount -t sysfs none /sys
mount -t tmpfs none /tmp
mount -t devtmpfs none /dev
mknod /dev/console c 5 1
mknod /dev/tty1 c 4 1
mknod /dev/tty2 c 4 2
mknod /dev/tty3 c 4 3
mknod /dev/tty4 c 4 4
mount -t devpts none /dev/pts

# Search for the root filesystem
for dev in /dev/sr* /dev/sd* /dev/loop* /dev/mmcblk*; do
    echo "Checking $dev..."
    if mount -o ro "$dev" /mnt 2>/dev/null; then
        if [ -f /mnt/sysroot.squashfs ]; then
            echo "Found root filesystem on $dev"
            break
        fi
        umount /mnt
    else
        echo "Failed to mount $dev"
    fi
done

# Check if the root filesystem was found
if [ ! -f /mnt/sysroot.squashfs ]; then
    echo "Live CD root not found. Dropping to shell..."
    exec sh
fi

# Mount the root filesystem
echo "Mounting root filesystem..."
mount -t squashfs /mnt/sysroot.squashfs /sysroot
mount --bind /dev /sysroot/dev
mount --bind /dev/pts /sysroot/dev/pts
mount --bind /proc /sysroot/proc
mount --bind /sys /sysroot/sys
mount --bind /tmp /sysroot/tmp
mknod /sysroot/dev/console c 5 1
mknod /sysroot/dev/tty1 c 4 1
mknod /sysroot/dev/tty2 c 4 2
mknod /sysroot/dev/tty3 c 4 3
mknod /sysroot/dev/tty4 c 4 4

# Switch root and start the real init process
exec switch_root /sysroot /sbin/init
sh
sysroot.squashfs is a rootfs of live cd to load. The structure of initramfs:
vadim@GoldenVadim:~/Initramfs$ l
busybox*  dev/  init*  proc/  sys/  sysroot/  tmp/
Can you help me with init script (initramfs/initrd)? Thank you
GoldenVadim (11 rep)
Jan 25, 2025, 12:17 PM
0 votes
0 answers
86 views
How Do SSH-Launched Long-Running Background Jobs Detach Without nohup or disown?
When running a long-running command in the background over SSH from a non-interactive shell script, I noticed the process continues running on the remote machine **without** using `nohup`, `disown`, or similar tools. Remote Environment (SSH target): - Linux 6.12.9 - OpenSSH 9.9p1, OpenSSL 3.3.2 - Lo...
When running a long-running command in the background over SSH from a non-interactive shell script, I noticed the process continues running on the remote machine **without** using nohup, disown, or similar tools. Remote Environment (SSH target): - Linux 6.12.9 - OpenSSH 9.9p1, OpenSSL 3.3.2 - Login Shell: bash 5.2.37 - Also for non-interactive sessions (verified by ssh -T $HOST "echo \$SHELL") - Distribution: NixOS 24.11 On the client side, I can execute:
# Closing outgoing FDs (stdout and stderr) important to end
# SSH session immediately (EOF). We also need a non-interactive
# session (-T).
ssh -T $HOST "long_running_command >/dev/null 2>/dev/null &"
to start a long running command on the remote without having to keep the SSH session alive. I expected that background jobs would terminate or receive SIGHUP when the SSH session ends. However, the process is automatically reparented to PID 1 (init) and keeps running. I can verify this using htop, ps, et. al. Why does this work **without** nohup or disown? - Why does it just work like that? Why are no SIGHUP or similar events being send to long_running_command? - Why does job control (&) work in bash in non-interactive mode? - Who decides that the running background job will switch ownership to the init process? Bash? Is this documented?
phip1611 (101 rep)
Jan 17, 2025, 08:43 AM
0 votes
0 answers
30 views
sinit failing to run in firecracker vmm
I am playing around with firecrackver VMM. I have extracted rootfs from a python docker image like this. ``` docker export $(docker create python:latest) --output="python.tar" mkdir python tar -xf python.tar -C python/ dd if=/dev/zero of=python.ext4 bs=1M count=1500 mkfs.ext4 python.ext4 mkdir pytho...
I am playing around with firecrackver VMM. I have extracted rootfs from a python docker image like this.
docker export $(docker create python:latest) --output="python.tar"
mkdir python
tar -xf python.tar -C python/
dd if=/dev/zero of=python.ext4 bs=1M count=1500
mkfs.ext4 python.ext4
mkdir python-mnt
sudo mount python.ext4 python-mnt
sudo cp -r python/* python-mnt/
sudo umount python-mnt
I am using the kernel that is provided in the firecracker readme. If I try running this sudo ./firecracker --api-sock "fc1.socket" --config-file vmconfig.json I will get kernel panic because it cant find init system. I compiled suckless init (sinit) and tried using that but my vm doesnt start. I might be doing something wrong with my config file
{
  "boot-source": {
    "kernel_image_path": "vmlinux",
    "boot_args": "console=ttyS0 reboot=k panic=1 pci=off "
  },
  "drives": [
    {
      "drive_id": "init",
      "is_root_device": false,
      "is_read_only": false,
      "path_on_host": "sinit"
    },
    {
      "drive_id": "rootfs",
      "is_root_device": true,
      "is_read_only": false,
      "path_on_host": "python.ext4"
    }
  ],
  "machine-config": {
    "vcpu_count": 2,
    "mem_size_mib": 1024,
    "smt": false,
    "track_dirty_pages": false,
    "huge_pages": "None"
  },
  "cpu-config": null,
  "balloon": null,
  "network-interfaces": [],
  "vsock": null,
  "logger": null,
  "metrics": null,
  "mmds-config": null,
  "entropy": null
}
I have two drives here because I am following https://github.com/superfly/init-snapshot/blob/public/README.md this example. It has not worked so I thought of starting with a simple init. PS: I am very new to this subject and I am interested to learn more. I might have asked a very stupid question and please point me to resources where I can learn about it.
Raaz (131 rep)
Jan 1, 2025, 01:42 PM
5 votes
1 answers
573 views
Why /sys/devices/.../product_serial sometimes reads as garbage?
Service reads `sys/devices/virtual/dmi/id/product_serial` somewhere at start and generally it contains some typical hex number of ten digits (e.g. `01212302C5`) with newline. However sometimes the content is not parsable to string - bytes in hex are `f8 6a 32 6d 0a` and I can't figure out why and ho...
Service reads sys/devices/virtual/dmi/id/product_serial somewhere at start and generally it contains some typical hex number of ten digits (e.g. 01212302C5) with newline. However sometimes the content is not parsable to string - bytes in hex are f8 6a 32 6d 0a and I can't figure out why and how this happens. The last 0a seems to hint it still was supposed to be text. Happens generally in CI but I'm not sure may containerized environment somehow be the reason of the issue. What could be the reason of such a queer behavior?
Rodion Gorkovenko (163 rep)
Nov 14, 2024, 08:50 AM • Last activity: Nov 14, 2024, 10:25 AM
1 votes
0 answers
269 views
How to add a custom init process to initramfs image built with Dracut?
I want to use Dracut for initramfs image creation. This image should be able to shrink a root filesystem on a Fedora machine. I would like to test partition shrinking flow manually first. If everything is okay, I will replace these commands with a script to do shrinking automatically in non-interact...
I want to use Dracut for initramfs image creation. This image should be able to shrink a root filesystem on a Fedora machine. I would like to test partition shrinking flow manually first. If everything is okay, I will replace these commands with a script to do shrinking automatically in non-interactive mode on a remote machine. I was able to add the 'parted' and 'resize2fs' tools that I needed for this task. However, the image still uses 'systemd' as the init process and just boots the main Fedora installation. So I need to boot into some kind of shell and run the 'parted' and 'resize2fs' commands by hand. My attempt to add a simple 'init' script to the initramfs image failed (I put it as '/sbin/init' and turned the execution bit on. But the kernel complains that it can't find a runnable init process). So my question my question is: how to add your own init process to an initramfs image with Dracut?
Zzaponka (111 rep)
Nov 7, 2024, 05:36 PM
0 votes
1 answers
56 views
lsns reports different output based on user running it
The output of `lsns` looks different based on the privilege of the user running it. `ubuntu` user and `root` user get different results: ubuntu@ubuntu:~$ lsns NS TYPE NPROCS PID USER COMMAND 4026531834 time 6 134628 ubuntu /lib/systemd/systemd --user 4026531835 cgroup 6 134628 ubuntu /lib/systemd/sy...
The output of lsns looks different based on the privilege of the user running it. ubuntu user and root user get different results: ubuntu@ubuntu:~$ lsns NS TYPE NPROCS PID USER COMMAND 4026531834 time 6 134628 ubuntu /lib/systemd/systemd --user 4026531835 cgroup 6 134628 ubuntu /lib/systemd/systemd --user 4026531836 pid 6 134628 ubuntu /lib/systemd/systemd --user 4026531837 user 5 134628 ubuntu /lib/systemd/systemd --user 4026531838 uts 6 134628 ubuntu /lib/systemd/systemd --user 4026531839 ipc 6 134628 ubuntu /lib/systemd/systemd --user 4026531840 net 6 134628 ubuntu /lib/systemd/systemd --user 4026531841 mnt 5 134628 ubuntu /lib/systemd/systemd --user 4026532290 user 1 134689 ubuntu /usr/bin/podman 4026532291 mnt 1 134689 ubuntu /usr/bin/podman ubuntu@ubuntu:~$ ubuntu@ubuntu:~$ ubuntu@ubuntu:~$ sudo lsns NS TYPE NPROCS PID USER COMMAND 4026531834 time 115 1 root /sbin/init 4026531835 cgroup 115 1 root /sbin/init 4026531836 pid 112 1 root /sbin/init 4026531837 user 113 1 root /sbin/init 4026531838 uts 112 1 root /sbin/init 4026531839 ipc 115 1 root /sbin/init 4026531840 net 115 1 root /sbin/init 4026531841 mnt 101 1 root /sbin/init 4026531862 mnt 1 25 root kdevtmpfs 4026532284 mnt 1 414 root /lib/systemd/systemd-udevd 4026532285 uts 1 414 root /lib/systemd/systemd-udevd 4026532286 mnt 1 469 systemd-timesync /lib/systemd/systemd-timesyncd 4026532287 uts 1 469 systemd-timesync /lib/systemd/systemd-timesyncd 4026532288 mnt 1 572 systemd-network /lib/systemd/systemd-networkd 4026532289 mnt 1 608 systemd-resolve /lib/systemd/systemd-resolved 4026532290 user 1 134689 ubuntu /usr/bin/podman 4026532291 mnt 1 134689 ubuntu /usr/bin/podman 4026532292 mnt 1 5369 root /usr/libexec/upowerd 4026532293 user 1 5369 root /usr/libexec/upowerd 4026532295 mnt 2 134974 root unshare --fork --pid --mount-proc /bin/bash 4026532296 pid 2 134975 root /bin/bash 4026532297 mnt 2 134981 root unshare --fork --pid --mount-proc /bin/zsh 4026532298 pid 1 134982 root /bin/zsh 4026532345 uts 1 655 root /lib/systemd/systemd-logind 4026532346 mnt 1 631 root /usr/sbin/irqbalance --foreground 4026532347 mnt 1 655 root /lib/systemd/systemd-logind 4026532348 mnt 1 678 root /usr/sbin/ModemManager ubuntu@ubuntu:~$ Furthemore the name of Ubuntu system's init process is different: systemd vs /sbin/init. What is the reason for this ? Thanks.
CarloC (385 rep)
Oct 29, 2024, 09:29 AM • Last activity: Oct 31, 2024, 10:34 AM
0 votes
0 answers
70 views
Shell-init errors when starting the system with pivot_root
I am using sysvinit and I can start the system directly by these kernel options: ``` root=/dev/sda1 rootfstype=ext4 init=/sbin/init ``` And it works perfectly. But if I add a middle filesystem like with this: (a simplified example) ``` root=/dev/sdb2 rootfstype=squashfs init=/myscript ``` Where `/my...
I am using sysvinit and I can start the system directly by these kernel options:
root=/dev/sda1 rootfstype=ext4 init=/sbin/init
And it works perfectly. But if I add a middle filesystem like with this: (a simplified example)
root=/dev/sdb2 rootfstype=squashfs init=/myscript
Where /myscript is a BusyBox script like this:
#!/busybox sh
echo Welcome
mount /dev/sda1 /newroot
cd /newroot/mnt
pivot_root /newroot .
exec /sbin/init
Then it also starts up, but during the SysVInit boot after pivot_root and exec, I see many messages in console like this:
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
What is the issue?
melonfsck - she her (150 rep)
Oct 21, 2024, 01:09 PM
3 votes
2 answers
432 views
How is PID 1 made special and unkillable?
Using docker, I recently found that PID 1 is by default unkillable by `SIGTERM`. Yet you can still catch `SIGTERM` in PID 1 if you setup a handler in the process. So this doesn't seem to be the case of the kernel just masking `SIGTERM` for PID 1. How is this implemented? How does the process as PID...
Using docker, I recently found that PID 1 is by default unkillable by SIGTERM. Yet you can still catch SIGTERM in PID 1 if you setup a handler in the process. So this doesn't seem to be the case of the kernel just masking SIGTERM for PID 1. How is this implemented? How does the process as PID 1 have the default SIGTERM handler be a noop?
rrauenza (852 rep)
May 17, 2024, 10:18 PM • Last activity: Oct 14, 2024, 02:36 AM
0 votes
0 answers
142 views
Correct way to edit /etc/init.d entries
At some point in the lifetime of my present Devuan (stable) installation, I edited an entry in `/etc/init.d`, in this specific case, `/etc/init.d/halt`. This may have been as early as Jesse or Beowulf, dist upgraded now to Daedalus via Chimaera. It has been a good while so I cannot recall but I may...
At some point in the lifetime of my present Devuan (stable) installation, I edited an entry in /etc/init.d, in this specific case, /etc/init.d/halt. This may have been as early as Jesse or Beowulf, dist upgraded now to Daedalus via Chimaera. It has been a good while so I cannot recall but I may have used jed (my usual), nano or the mc editor. The thing is that, as a result, I ended up with two entries:
/etc/init.d/halt
/etc/init.d/halt~
At that time and thinking that the newly generated entry (obviously a backup) would just stay there, I left it at that. ie: by *stay there* I mean oblivious as to what was going on within the system and *not* taken into account.
~$ ls -1 /etc/init.d
--- snip ---
halt
--- snip ---
halt~
--- snip ---
~$
While I have a look at my log files every fortnight or so to see if I catch anything strange, I don't do the same with running services unless it is warranted. eg: something seems to be amiss or the latest CUPS/cups-browsed CVE thing which had everyone scrambling. So I had a look at and, to my surprise, found this:
~$ sudo service --status-all
--- snip ---
 [ - ]  halt~     <- this is the *backup* file being loaded.
--- snip ---
~$
As I have explained, both files are present in /etc/init.d and have the same attributes. They also have the same size because, for testing purposes, I have edited the original file to reflect the contents of the backup file.
~$ ls -l /etc/init.d/halt
-rwxr-xr-x 1 root root 1417 Sep 29 08:01 /etc/init.d/halt
~$
~$ ls -l /etc/init.d/halt~
-rwxr-xr-x 1 root root 1417 Sep 28 07:56 /etc/init.d/halt~
~$
Can anyone tell me *why* the backup file is being loaded instead of the edited file? ie: /etc/init.d/halt~ instead of /etc/init.d/halt. What have I missed / done the *wrong* way? Where should I be looking?
Groucho (31 rep)
Oct 1, 2024, 11:47 AM • Last activity: Oct 1, 2024, 01:26 PM
1 votes
1 answers
170 views
How to print logs to serial port without specifying 'console' in Linux?
I am working on an embedded Linux system (5.19.10), and I am using busybox as the main part of file system. Now I am trying to run a test which should output logs to the serial port (ttyS0). But I did NOT configure `console` in the kernel command line. The `/etc/inittab` is as follows, ``` # now run...
I am working on an embedded Linux system (5.19.10), and I am using busybox as the main part of file system. Now I am trying to run a test which should output logs to the serial port (ttyS0). But I did NOT configure console in the kernel command line. The /etc/inittab is as follows,
# now run any rc scripts
::sysinit:/etc/init.d/rcS

# Put a getty on the serial port
#::respawn:/sbin/getty -L ttyS1 115200 vt100
#no login
::respawn:-/bin/sh

# Stuff to do for the 3-finger salute
::ctrlaltdel:/sbin/reboot

# Stuff to do before rebooting
null::shutdown:/etc/init.d/rcK
null::shutdown:/bin/umount -a -r
null::shutdown:/sbin/swapoff -a
I changed the /etc/profile as follows,
export PATH="/bin:/sbin:/usr/bin:/usr/sbin"
stty -F /dev/ttyS0 speed 38400
setconsole /dev/ttyS0
echo "Hello world" > /dev/ttyS0
/home/test/test_app 2>&1 &
When system booted up, I can see Hello world in the serial port. But I cannot see the shell prompt or the logs from the test_app. I think the system console is NOT being configured correctly in this case. So, I am wondering is there any _gentle_ way to set the system console in my own script (e.g. /etc/init.d/rcS or /etc/profile) without using getty or console=XXX and make the log output to the serial expected console??
wangt13 (631 rep)
Sep 6, 2024, 03:21 AM • Last activity: Sep 6, 2024, 12:04 PM
1 votes
1 answers
160 views
How to start the busybox shell in initramfs in Linux?
I am working on an embedded Linux system (kernel-5.10.24), and now I am trying to create the initramfs where there is an interactive shell. The rootfs is mainly based on `busybox`, and the `initramfs source` has following layout. ``` ├── bin ├── dev ├── etc ├── lib ├── lib32 -> lib/ ├── linuxrc -> b...
I am working on an embedded Linux system (kernel-5.10.24), and now I am trying to create the initramfs where there is an interactive shell. The rootfs is mainly based on busybox, and the initramfs source has following layout.
├── bin
├── dev
├── etc
├── lib
├── lib32 -> lib/
├── linuxrc -> bin/busybox
├── mnt
├── root
├── sbin
├── sys
└── usr

and,
initramfs/dev/
├── console
├── fd -> ../proc/self/fd
├── log -> ../tmp/log
├── null
├── stderr -> ../proc/self/fd/2
├── stdin -> ../proc/self/fd/0
└── stdout -> ../proc/self/fd/1
The initramfs/etc/inittab is
# /etc/inittab
#
# Copyright (C) 2001 Erik Andersen 
#
# Note: BusyBox init doesn't support runlevels.  The runlevels field is
# completely ignored by BusyBox init. If you want runlevels, use
# sysvinit.
#
# Format for each entry: :::
#
# id        == tty to run on, or empty for /dev/console
# runlevels == ignored
# action    == one of sysinit, respawn, askfirst, wait, and once
# process   == program to run

# now run any rc scripts
::sysinit:/etc/init.d/rcS
#no login
::respawn:-/bin/sh
# Stuff to do for the 3-finger salute
::ctrlaltdel:/sbin/reboot

# Stuff to do before rebooting
null::shutdown:/etc/init.d/rcK
null::shutdown:/bin/umount -a -r
null::shutdown:/sbin/swapoff -a
* When the kernel command line is
loglevel=8 console=ttyS0,115200 rdinit=/linuxrc
The kernel bootup showing,
[    2.684513] Freeing unused kernel memory: 4156K
[    2.689193] This architecture does not have kernel memory protection.
[    2.695885] Run /linuxrc as init process
[    2.699931]   with arguments:
[    2.703000]     /linuxrc
[    2.705610]   with environment:
[    2.708849]     HOME=/
[    2.711289]     TERM=linux
[    2.714262] process '/bin/busybox' started with executable stack
There is NO shell prompt for interaction. * When the kernel command line is,
loglevel=8 console=ttyS0,115200 rdinit=/bin/sh
kernel booted up, showing
[    2.684492] Freeing unused kernel memory: 4156K
[    2.689172] This architecture does not have kernel memory protection.
[    2.695861] Run /bin/sh as init process
[    2.699818]   with arguments:
[    2.702888]     /bin/sh
[    2.705409]   with environment:
[    2.708646]     HOME=/
[    2.711086]     TERM=linux
[    2.714059] process '/bin/busybox' started with executable stack
[    2.722175] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000000
[    2.730109] Rebooting in 10 seconds..
Kernel panic! * Thirdly, I built a hello into initramfs/bin/hello, it printed out Hello World! to its stdout and looped forever. The command line is set to
loglevel=8 console=ttyS0,115200 rdinit=/bin/hello
There is NO Hello World! shown!!! So, now I am wondering how can I start the busybox shell in the initramfs, what configuration should I do? Thanks,
wangt13 (631 rep)
Aug 8, 2024, 01:45 PM • Last activity: Aug 8, 2024, 11:43 PM
0 votes
1 answers
131 views
Custom initrd script failing to init "Attempted to kill init"
I am trying to create a custom ramdisk, but it keeps failing right before launching init. Here is the script: https://gist.github.com/amanuel2/f3e8bb9399f3b3bd36a90cd925ecf63d Logs: [![enter image description here][1]][1] Edit 2: Logs: https://pastebin.com/FUxUtiSE Script: https://gist.github.com/am...
I am trying to create a custom ramdisk, but it keeps failing right before launching init. Here is the script: https://gist.github.com/amanuel2/f3e8bb9399f3b3bd36a90cd925ecf63d Logs: enter image description here Edit 2: Logs: https://pastebin.com/FUxUtiSE Script: https://gist.github.com/amanuel2/f3e8bb9399f3b3bd36a90cd925ecf63d
amanuel2 (101 rep)
Jul 8, 2024, 03:05 AM • Last activity: Jul 9, 2024, 02:07 AM
0 votes
3 answers
4615 views
Startup script needs root permissions
I have a script that I need to run at startup. I have it in init.d. I need to execute one of the commands within the script with root permissions. How do I go about doing this? Edit 1: For reference, this is a ClearCase/ClearQuest RHEL 6.7 server. There looks to be an issue relating to CC starting b...
I have a script that I need to run at startup. I have it in init.d. I need to execute one of the commands within the script with root permissions. How do I go about doing this? Edit 1: For reference, this is a ClearCase/ClearQuest RHEL 6.7 server. There looks to be an issue relating to CC starting before the license manager. So, I want to run the following (all requiring root permissions): /path/to/atria_start stop # stop CC /path/to/start_lmgrd start # start license manager (flexlm) /path/to/atria_start start # restart CC These don't happend. I have them in a simple script "cc_startup.sh" in /etc/init.d
basil (153 rep)
Jan 27, 2016, 07:47 PM • Last activity: Jun 11, 2024, 10:17 AM
Showing page 1 of 20 total questions