LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-16-2022, 09:05 PM   #1
finalturismo
Member
 
Registered: May 2019
Posts: 120

Rep: Reputation: Disabled
question about PID 1 and busybox


So i have a custom init that seems to work pretty good but i wanted to add the fish shell to it and make it and interactive place for ZFS based recovery and nfs mounting etc....

i am running into a problem with losing pid 1. I got the fire on my back for getting multiple wiper units deployed with server monitoring to ensure happy clients and iam behind so any help would greatly be appreciated. It seems this issue has been a stepping stone for me for a while.

Anyway i was wondering whats the best way of maintaining PID 1, TTY 1 and environment when jumping from an interactive prompt with /bin/busybox sh to the interactive shell and back to exec switch_root
I didn't post the entire init but i think its obvious what i am doi



Code:

#!/bin/sh
#Rescue Shell
/bin/busybox sleep 1
/bin/busybox mount -t proc nonexec setsid in busybox and keep pid 1 after script execution /proc
/bin/busybox mount -t sysfs none /sys
/bin/busybox mount -t devtmpfs none /dev
/bin/busybox --install -s
/bin/busybox sleep 3
source /etc/profile
hostname Ultimate
ldconfig


if [ $(cat /proc/cmdline | grep -i -o -m1 "breaknow" ) = "breaknow" ]
then
rescue_break
else
echo "$yellow attempting to import pool $nocolor"
fi


exec setsid cttyhack sh (how i get pid 1 now but after but i keep needing to resource the environment in /etc/profile)
Also i was wondering if it might be better to use inittab for this is i was thinking it might but it iam not really sure where to put the init file for init tab.

udev
importpool



example of environment / profile file
Code:

#!/bin/busybox sh
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
SHELL=/bin/busybox sh
HOME=/
red="\e[1;31m"
yellow="\e[1;33m"
orange="\e[0;33m"
green="\e[1;32m"
nocolor="\e[1;m"
LANG="en_US.UTF-8"
LANGUAGE="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
TERM="linux"
root=rpool
showcommands() (
echo -e "$green ZFS COMMAND LIST $nocolor"
echo -e "$green export root=zfs:rpool $nocolor sets desired pool to be rootfs note: boo
tfs is dicated by the what the pools bootfs is"
echo -e "$green importpool $nocolor imports pool by looking at the root= kernel command
line"
echo -e "$green mountpool $nocolor mounts imported pool"
echo -e "$green boot $nocolor - boots into primary OS requires pool to be imported and
udev() (
udevd --daemon --resolve-names=never
udevadm trigger --action=add
udevadm settle
)

boot() (
echo -e "$yellow Attempting Boot......:"$nocolor" "
udevadm control --exit
cd root
mount --move /dev /root/dev
mount --move /sys /root/sys
mount --move /proc /root/proc
nuke /dev
exec switch_root /root /sbin/init
)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bind pid to number of cpus and lock these to only this pid khuongdp Linux - Server 7 07-25-2012 04:16 AM
pls tell difference between waitpid(pid,&status,0) and waitpid(pid,&status,WNOHANG) nagendrar Linux - Newbie 3 07-08-2009 08:51 PM
What is the more easier way to check the pid and kill the pid cmx08 Linux - General 5 09-09-2008 10:57 PM
rm cannot remove /var/run/atd.pid and /var/run/xdm.pid danishmr Linux - Software 1 05-04-2004 08:01 AM
ERROR: Couldn't write pid to pid file lawrencegoodman Linux - Newbie 2 02-13-2004 08:05 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration