[systemd-devel] How to execute Shell before rootfs mount on centos7

Kevin Kuehler kevin.kuehler at gmail.com
Sat Nov 30 09:21:02 UTC 2019


On Sat Nov 30, 2019 at 4:13 PM, Ankele zhang wrote:
> --00000000000017910e05988beecb
> Content-Type: text/plain; charset="UTF-8"
>
>
> Hello All:
> How to execute shell before rootfs mounted on CentOS7.
> On CentOS6, we can modify init shell in initramfs.img to do something
> we need. But on CentOS7 my beloved init has be changed to systemd and
> systemd has no shell script.
>
>
> --00000000000017910e05988beecb
> Content-Type: text/html; charset="UTF-8"
> Content-Transfer-Encoding: quoted-printable
>
>
> <div dir=3D"ltr">Hello All:<div>=C2=A0 =C2=A0 How to execute shell
> before r=
> ootfs mounted on CentOS7.<br></div><div>=C2=A0 =C2=A0 On CentOS6, we can
> mo=
> dify init shell in initramfs.img to do something we need. But on CentOS7
> my=
> beloved init has be changed to systemd and systemd has no shell
> script.</d=
> iv></div>
>
>
> --00000000000017910e05988beecb--
>

On the kernel command line you can set systemd.unit=emergency.target, which
will drop you into an emergency shell before the root filesystem is mounted.
This is documented in systemd.special(7).

Your bootloader should allow you to set the kernel command line ephemerally. On
systemd-boot and grub this is 'e'.


Best,
Kevin


More information about the systemd-devel mailing list