From man 2 pivot_root
pivot_root()moves the root file system of the current process to the directory _put_old_ and makes _new_root_ the new root file system of the current process.
int pivot_root(const char *new_root, const char *put_old);
While reading this I got following doubts
- What is the use of _put_old_? Is it is used only by kernal for its internal purpose or do we have any use with this?
- Why current filesystem should move to _put_old_ directory?
- Why _put_old_ directory should be under the _new_root_ directory?
Official doc clearly explains what we wanted to do if we wanted to utilize pivot_root syscall but I feel doc not clearly explained why it is enforcing these many rules and what it is doing behind the scene.
Someone who knows this kindly help me to solve this.
pivot_root(2)is a special purpose, one use only interface; it's not something generally useful. Think of it as of achroot(2)which let you discard the old root (and all the resources it kept hold of). If the old root weren't put somewhere inside the new root tree, you would not be able to ever unmount it and get rid of it for good.pivot_root(2)manpage: "Some of the more obscure uses ofpivot_root()may quickly lead to insanity".