In Qemu, I'm starting a linux VM where init process (PID 1) is bash. It is working : I can use bash after boot. But when I quit bash with a exit or CTRL+D I got a kernel panic.

Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000000

I'd like the system to halt properly and ideally, I'd like it to sync disk before when quitting bash.

Is it possible, knowing that I can modify kernel behavior only by passing options at boot ?


I don't think you can do that directly, but you can run, e.g.

# bash; sync; halt

from the first (PID 1) shell to run another one, and to run sync and halt when that second shell exits.

If you can edit the files on the system, you could probably automate that by putting a script doing the same in /sbin/init:

/bin/bash; /bin/sync; /sbin/halt

(I say "probably", because I'm not sure if Linux likes a script as init.)

In both cases, the shell you'd actually use would not be PID 1, but that probably doesn't matter much.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.