SwitchInit?

How to switch inits

this is a crash course on how to switch inits on Artix Linux. grab an Artix live iso, or any other distro that permits you to chroot into a linux system. it is suggested the former due the presence of artix-chroot.


build the list of currently installed init scripts

run the following command:

 _MY_LIST=$(pacman -Q | cut -d " "  -f1 | grep $_CURRENT_INIT)

explanation of the command: Pacman -Q lists all installed software, that list is piped to cut, which given field one and a space as a delimiter it will display only the name, excluding the version; all of this is piped to a grep, which will only outputs lines with a certain pattern, in our case, the current init. e.g. if you are using runit and want to switch to openrc CURRENT_INIT should be runit. you could use variables, like this:

 export _CURRENT_INIT=runit _NEW_INIT=openrc  

note for s6 users: packages `s6-base` `s6-linux-init` `s6-rc` `s6-scripts` are exclusive to s6, so those are gonna get removed.

 _MY_LIST=$(pacman -Q | cut -d " "  -f1 | grep s6 | sed "/s6-base/d; /s6-rc/d; /s6-scripts/d; /s6-linux-init/d)

this will do the job.


Removal

now, that we have that list, we can use `xargs` to pass that list to pacman to be removed.

 echo $_MY_LIST | xargs pacman -Rdd 

add sudo/doas if privilege excalation is needed.


Build a list for the target init

now that everything is nice and removed, we're gonna geCustomnerate a new list:

 _NEW_LIST=$(echo $_MYLIST |  sed "s/\w*$//" | sed 's/$/$_NEW_INIT/')

explanation of the command: this will echo the old list, with package-oldinit, use sed to remove oldinit and replace it with the new init. all of this saved in a new variable, named _NEW_LIST`

installation

what's left now is echo $_NEW_LIST | xargs pacman -S and add the various services to the adapted runlevels. please make sure to refer to the new init's wiki page to know how the to.
lastly, tweak the init= kernel parameter if you have any to match the new init scheme.

for openrc the init is located at /sbin/init

for runit the init is located at /usr/bin/runit-init

for s6 the init is located at /usr/bin/s6-init

for suite66 the init is located at /usr/bin/s6-init

for dinit the init is located at /sbin/init

This page may have a more recent version on pmwiki.org: PmWiki:MyNewPage-deleted-1637049098, and a talk page: PmWiki:MyNewPage-deleted-1637049098-Talk.