LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-28-2021, 02:48 PM   #1
tuxuser1
Member
 
Registered: Nov 2021
Posts: 165

Rep: Reputation: Disabled
A question about init system


Hi all,
i'm writing a simple init program only for study purpose. Now, how can i fastly test it? I tried to use systemd container but even if I replace the init symlink making it point to my init program, it is ignored, starts systemd anyway.
What is the best and fastest way to do that?
Regards
 
Old 11-28-2021, 03:46 PM   #2
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,627

Rep: Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695
Are you writing an init script to start a service under initd, runit, s6, or systemd? Or are you writing an init service to start the system services REPLACING systemd, init.d, runit, or s6? This is unclear form your statement of the question, and critical to answering it.

There are a couple of dozen distributions out there that do not use SystemD. Seek one out and use it to create a virtual machine or full guest container. Then you can play with the system init features all you want without having systemd start behind your back. No matter what the answer to the question I asked, this is far safer than trying things in your native install.
 
Old 11-28-2021, 05:34 PM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
Strongly agree with wpeckham ... grab a distro that still uses 'init,' put it in a virtual machine, and hack away to your heart's content.
 
Old 11-28-2021, 08:09 PM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Everybody still uses init - just ask the kernel.

But I agree light-weight containers ain't the environment to test in.
 
Old 11-29-2021, 02:58 AM   #5
tuxuser1
Member
 
Registered: Nov 2021
Posts: 165

Original Poster
Rep: Reputation: Disabled
Thanks all for the answers.
I know that i can put all in a virtual machine but that means that i have to transfer the compiled code from host to guest.
Or I should to develop it directly in virtual machine. That means that for each modification (even a simple printf), I'll have to make a reboot machine passing init on the command line as parameter.
This solution doesn't looks like fast imo.
For this reason I wanted to understand if a lightweight container offered by systemd can help me.
A probably solution could be this
 
Old 11-29-2021, 03:24 AM   #6
tuxuser1
Member
 
Registered: Nov 2021
Posts: 165

Original Poster
Rep: Reputation: Disabled
It works!
systemd-nspawn -D /path/my/cont myinit
it runs myinit program as PID 1.
Mark as solved.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
init: execv(“/system/bin/init”) failed / No such file or directory / cyclic reboots while trying to virtualize android on my jetson nano marietto Linux - Virtualization and Cloud 3 04-05-2021 11:59 AM
Ubutnu won't boot. Error: Target file system doesn't have /sbin/init. No init found. Zeljka_Lin Linux - Newbie 9 05-02-2011 06:56 AM
What is the exact diff between init 1,init S and init s challavijay Linux - Newbie 1 08-05-2010 06:51 AM
System hangs,if gives init 3 or init 4 Sailaja Reddy Red Hat 1 09-20-2004 01:31 AM
Redhat linux9.0:System hangs,if gives init 3 or init 4 Sailaja Reddy Linux - Newbie 4 09-16-2004 03:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:28 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