[systemd-devel] Antw: Re: Antw: [EXT] Re: Q: Start network in chroot?

2022-06-13 Thread Ulrich Windl
>>> Colin Guthrie  schrieb am 13.06.2022 um 16:34 in
Nachricht :

> Ulrich Windl wrote on 13/06/2022 14:42:
> Colin Guthrie  schrieb am 13.06.2022 um 14:58 in
>> Nachricht :
>>> Ulrich Windl wrote on 13/06/2022 09:09:
 Hi!

 Two questions:
 1) Why can't I use "systemctl start network" in a chroot environment (e.g.
>>> mounting the system from a rescue medium to fix a defective kernel)? When I
>>> try I get: "Running in chroot, ignoring command 'start'"
 2) How can I start the network using systemd?
>>>
>>> You may wish to consider "booting" the container rather than just chrooting.
>> 
>> No container involved; an unbootable system instead, and I'd like to have 
> networking available for repair.
>> So obviously I cannot boot. Without systemd it wouldn't be a problem.
> 
> So you're not running an init system but you want the (not-running) init 
> system to run something for you?

I don't understand:
The rescue system I'm using (SLES 14 SP3) uses systemd, and the system that 
woon't boo is also using systemd (SLES15 SP3).

> 
> If you're wanting to repair a system, and you need networking then bring 
> up the network in the repair image before chrooting surely? (i.e. what 
> Mantas said)

Well the configuration files are not in the generic rescue system, but in the 
system that won't boot (I think I had explained that).
Also things became much more complicated with systemd and wickedd and all that 
stuff.

> 
> If you want to run the network inside the (broken) system you're trying 
> to repair, then just run the networking scripts or program manually. 
> i.e. run whatever /etc/init.d/network says or whatever ExecStart= says 
> in /usr/lib/systemd/network.service says (paths may vary).

There are no files inside /etc/init.d/.

> 
> There will be loads of other stuff that the init system does that won't 
> be in place (e.g. tmpfiles, etc.) which you may or may not need to setup 
> manually too, but you can likely get it running.
> 
>  > Without systemd it wouldn't be a problem.
> 
> Sure when "init" was just a bundle of scripts, you could run one of the 
> scripts it runs and hope for the best. You can generally still do that, 
> but just don't expect asking a non-running program to do it for you to work!

Still I don't understand: systemd is running.

Regards,
Ulrich

> 
> Col






Re: [systemd-devel] Q: Start network in chroot?

2022-06-13 Thread Topi Miettinen

On 13.6.2022 11.09, Ulrich Windl wrote:

Hi!

Two questions:
1) Why can't I use "systemctl start network" in a chroot environment (e.g. mounting the 
system from a rescue medium to fix a defective kernel)? When I try I get: "Running in chroot, 
ignoring command 'start'"


From docs/ENVIRONMENT.md:
* `$SYSTEMD_IGNORE_CHROOT=1` — if set, don't check whether being invoked 
in a
  `chroot()` environment. This is particularly relevant for systemctl, 
as it
  will not alter its behaviour for `chroot()` environments if set. 
Normally it
  refrains from talking to PID 1 in such a case; turning most 
operations such

  as `start` into no-ops.  If that's what's explicitly desired, you might
  consider setting `$SYSTEMD_OFFLINE=1`.

-Topi


Re: [systemd-devel] Antw: [EXT] Re: Q: Start network in chroot?

2022-06-13 Thread Michał Zegan


W dniu 13.06.2022 o 16:34, Colin Guthrie pisze:


Ulrich Windl wrote on 13/06/2022 14:42:
Colin Guthrie  schrieb am 13.06.2022 um 
14:58 in

Nachricht :

Ulrich Windl wrote on 13/06/2022 09:09:

Hi!

Two questions:
1) Why can't I use "systemctl start network" in a chroot 
environment (e.g.
mounting the system from a rescue medium to fix a defective kernel)? 
When I

try I get: "Running in chroot, ignoring command 'start'"

2) How can I start the network using systemd?


You may wish to consider "booting" the container rather than just 
chrooting.


No container involved; an unbootable system instead, and I'd like to 
have networking available for repair.

So obviously I cannot boot. Without systemd it wouldn't be a problem.


in theory you have unshare in mos environments. you might not have 
access to nspawn, but you can unshare. I have used raw namespaces 
previously, although mostly mount ns, not network ns.


also this is uncommon that you cannot configure the network before 
chrooting, as in at host side, then just copy or bindmount resolv.conf 
and have it working in chroot.




So you're not running an init system but you want the (not-running) 
init system to run something for you?


If you're wanting to repair a system, and you need networking then 
bring up the network in the repair image before chrooting surely? 
(i.e. what Mantas said)


If you want to run the network inside the (broken) system you're 
trying to repair, then just run the networking scripts or program 
manually. i.e. run whatever /etc/init.d/network says or whatever 
ExecStart= says in /usr/lib/systemd/network.service says (paths may 
vary).


There will be loads of other stuff that the init system does that 
won't be in place (e.g. tmpfiles, etc.) which you may or may not need 
to setup manually too, but you can likely get it running.


> Without systemd it wouldn't be a problem.

Sure when "init" was just a bundle of scripts, you could run one of 
the scripts it runs and hope for the best. You can generally still do 
that, but just don't expect asking a non-running program to do it for 
you to work!


Col



OpenPGP_0xE6516A8A8E25955D.asc
Description: OpenPGP public key


OpenPGP_signature
Description: OpenPGP digital signature


Re: [systemd-devel] Antw: [EXT] Re: Q: Start network in chroot?

2022-06-13 Thread Colin Guthrie



Ulrich Windl wrote on 13/06/2022 14:42:

Colin Guthrie  schrieb am 13.06.2022 um 14:58 in

Nachricht :

Ulrich Windl wrote on 13/06/2022 09:09:

Hi!

Two questions:
1) Why can't I use "systemctl start network" in a chroot environment (e.g.

mounting the system from a rescue medium to fix a defective kernel)? When I
try I get: "Running in chroot, ignoring command 'start'"

2) How can I start the network using systemd?


You may wish to consider "booting" the container rather than just chrooting.


No container involved; an unbootable system instead, and I'd like to have 
networking available for repair.
So obviously I cannot boot. Without systemd it wouldn't be a problem.


So you're not running an init system but you want the (not-running) init 
system to run something for you?


If you're wanting to repair a system, and you need networking then bring 
up the network in the repair image before chrooting surely? (i.e. what 
Mantas said)


If you want to run the network inside the (broken) system you're trying 
to repair, then just run the networking scripts or program manually. 
i.e. run whatever /etc/init.d/network says or whatever ExecStart= says 
in /usr/lib/systemd/network.service says (paths may vary).


There will be loads of other stuff that the init system does that won't 
be in place (e.g. tmpfiles, etc.) which you may or may not need to setup 
manually too, but you can likely get it running.


> Without systemd it wouldn't be a problem.

Sure when "init" was just a bundle of scripts, you could run one of the 
scripts it runs and hope for the best. You can generally still do that, 
but just don't expect asking a non-running program to do it for you to work!


Col



[systemd-devel] Antw: [EXT] Re: Q: Start network in chroot?

2022-06-13 Thread Ulrich Windl
>>> Colin Guthrie  schrieb am 13.06.2022 um 14:58 in
Nachricht :
> Ulrich Windl wrote on 13/06/2022 09:09:
>> Hi!
>> 
>> Two questions:
>> 1) Why can't I use "systemctl start network" in a chroot environment (e.g. 
> mounting the system from a rescue medium to fix a defective kernel)? When I 
> try I get: "Running in chroot, ignoring command 'start'"
>> 2) How can I start the network using systemd?
> 
> You may wish to consider "booting" the container rather than just chrooting.

No container involved; an unbootable system instead, and I'd like to have 
networking available for repair.
So obviously I cannot boot. Without systemd it wouldn't be a problem.

Regards,
Ulrich

> 
> Combined with IPVLAN or similar (which systemd-nspawn makes easy) you 
> can bring up a namespaced network interface inside the container 
> completely isolated from the host.
> 
> I do this for various setups and it works pretty well.
> 
> Col






Re: [systemd-devel] Q: Start network in chroot?

2022-06-13 Thread Colin Guthrie

Ulrich Windl wrote on 13/06/2022 09:09:

Hi!

Two questions:
1) Why can't I use "systemctl start network" in a chroot environment (e.g. mounting the 
system from a rescue medium to fix a defective kernel)? When I try I get: "Running in chroot, 
ignoring command 'start'"
2) How can I start the network using systemd?


You may wish to consider "booting" the container rather than just chrooting.

Combined with IPVLAN or similar (which systemd-nspawn makes easy) you 
can bring up a namespaced network interface inside the container 
completely isolated from the host.


I do this for various setups and it works pretty well.

Col




[systemd-devel] Wtrlt: Antw: [EXT] Re: Q: Start network in chroot?

2022-06-13 Thread Ulrich Windl
Forgot the list when replying...

>>> Ulrich Windl  schrieb am 13.06.2022 um
10:44
in Nachricht <62a7152a.ed38.00a...@rz.uni-regensburg.de>:
 Mantas Mikulenas  schrieb am 13.06.2022 um 10:13 in
> Nachricht
> :
> > On Mon, Jun 13, 2022 at 11:09 AM Ulrich Windl <
> > ulrich.wi...@rz.uni-regensburg.de> wrote:
> > 
> >> Hi!
> >>
> >> Two questions:
> >> 1) Why can't I use "systemctl start network" in a chroot environment
(e.g.
> >> mounting the system from a rescue medium to fix a defective kernel)?
> > 
> > 
> > Because you don't have systemd as init while inside a chroot.
> > 
> > 2) How can I start the network using systemd?
> >>
> > 
> > Start it outside the chroot.
> 
> That'll be tricky when the configuration (bonding/bridge setup) is stored 
> inside the chroot.
> 
> > 
> > -- 
> > Mantas Mikulėnas
> 
> 
> 
> 





Re: [systemd-devel] Q: Start network in chroot?

2022-06-13 Thread Mantas Mikulėnas
On Mon, Jun 13, 2022 at 11:09 AM Ulrich Windl <
ulrich.wi...@rz.uni-regensburg.de> wrote:

> Hi!
>
> Two questions:
> 1) Why can't I use "systemctl start network" in a chroot environment (e.g.
> mounting the system from a rescue medium to fix a defective kernel)?


Because you don't have systemd as init while inside a chroot.

2) How can I start the network using systemd?
>

Start it outside the chroot.

-- 
Mantas Mikulėnas


[systemd-devel] Q: Start network in chroot?

2022-06-13 Thread Ulrich Windl
Hi!

Two questions:
1) Why can't I use "systemctl start network" in a chroot environment (e.g. 
mounting the system from a rescue medium to fix a defective kernel)? When I try 
I get: "Running in chroot, ignoring command 'start'"
2) How can I start the network using systemd?

(systemd-246-16 of SLES15 SP3)

Regards,
Ulrich