Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

pivot_root

Change the root filesystem.

Synopsis

pivot_root new_root put_old

Operation

Calls the pivot_root(2) syscall to move the current root filesystem to put_old and make new_root the new root filesystem.

Typically used in boot scripts and container setup:

cd new_root
pivot_root . put_old
exec chroot . command

Inputs

  • new_root — path to the new root filesystem (must be a mount point)
  • put_old — path where the old root will be moved (must be under new_root)

Outputs

None. The syscall modifies the process’s mount namespace.

Syscalls

SyscallDescription
pivot_root(2)Move root filesystem

Command-line options

OptionDescription
new_rootNew root filesystem path
put_oldWhere to move the old root
-h, --helpDisplay help
-V, --versionDisplay version

Exit codes

CodeMeaning
0Success
1Failure (syscall error)

Permissions

Requires CAP_SYS_ADMIN.