The chroot command modifies the root directory for a process, limiting its access to the rest of the filesystem. This is useful for security, containerization, or testing purposes. The process running under chroot has no knowledge of anything outside its jail, making it appear as if it is running on the root filesystem. pivot_root vs chroot vs switch_root 1 2 3 In Linux, pivot_root, chroot, and switch_root are commands used to change the root filesystem of a process. Each has its specific use cases and functionalities. pivot_root The pivot_root command is used to change the root filesystem of the current process and its children. It swaps the current root filesystem with a new one, making the old root accessible at a specified location. This command is typically used during the boot process when the system transitions from an initial ramdisk (initrd) to the real root filesystem 1 . Example: mount /dev/hda1 /new-root cd /new-root pivot_root . old-root exec chroot . sh ...
Ask Madhukar about Technology, Software or Gadgets !!