Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • The pid of the shell is somewhere in the upper 100s. why isn't the shell 1? How can I fix that? Commented Apr 29, 2016 at 20:30
  • This means that something just spawns a dedicated shell to you, but continues running. Please see ps output to find out who is running with pid 1. Commented Apr 30, 2016 at 2:51
  • Echo $$ is 175 which is sh in ps and 1 is /bin/sh /init in ps. Is that because when you exit the shell the kernel doesn't panic and just goes back into another shell? Is the switch root method impossible because of this? Commented May 2, 2016 at 0:50
  • Yes, you need to make your shell be pid 1 (if you exit it, kernel will panic). Otherwise it's not possible to repace pid 1 with init which is to be executed from switched root. Although switch_root just remove everything from current / within borders of one file system (usually temporary memory storage, like initrd), it then moves / to switched root and replaces itself with init from there. If this init gets pid other than 1, it become useless. Commented May 2, 2016 at 1:13