0

I have a Debian server with an encrypted luks partition and I would like to run the following command before switch_Root

shutdown -H +5

I tried to put a script in/etc/initramfs-tools/scripts/init-top but the shutdown command is not working in initramfs. It says "command not found".

So I tried the halt command but it does not support scheduling. Is it possible to execute halt command with 5 minutes delay like I can with the shutdown command?

How can I automatically shutdown my server if the luks partition is not unlocked in 5 minutes?

George
  • 21
  • 1
  • `shutdown` is only in super user PATH, so it will not work directly: you should probably specify full PATH. And probably it will requires root permissions (but this may be configurable). – Giacomo Catenazzi Oct 17 '22 at 10:05
  • @GiacomoCatenazzi You are write about the PATH. So I tried to hook `shutdown` script in initramfs and now I get the following errror: `System has not been booted with systemd as init system (PID 1). Can't operate.` `Failed to connect to bus: Host is down` I already have root permissions. – George Oct 17 '22 at 10:24
  • Because you are not using the correct `shutdown` command. It must not be in initramfs. It should be in the path of root, so probably in one of the `sbin` directories (with initial `s`). And this site is about programming. For Unix and Linux discussion there is an appropriate sister site (see the link in the top right icon). – Giacomo Catenazzi Oct 17 '22 at 11:48
  • @GiacomoCatenazzi I use `copy_exec` to copy the `/usr/sbin/shutdown` to `/sbin` but still is not working. Is it possible to use the shutdown command in initramfs? Thanks, I will repost my questing to the appropriate site. – George Oct 17 '22 at 12:27
  • No. No. No. Do no copy things. The operating system part of filesystem is not to be touched, but if you known very well your distribution). It is an API/ABI and other part may rely on precise behaviour, so you will get cases impossible to debug. Either it is already installed on your system (somewhere) or do not use it. But what I meant originally: use `/usr/sbin/shutdown` as a command (so with full path). – Giacomo Catenazzi Oct 17 '22 at 12:32
  • @GiacomoCatenazzi It says `/usr/sbin/shutdown not found`. I think that's because my hard drive is encrypted. – George Oct 17 '22 at 12:38

0 Answers0