LinuxCommandLibrary

switch_root

Switch to new root filesystem during boot

TLDR

Switch to a new root filesystem and start init

$ switch_root [new_root] [/sbin/init]
copy

SYNOPSIS

switch_root [options] newroot init [arguments]

DESCRIPTION

switch_root moves special filesystems (/proc, /dev, /sys, /run) to a new root directory and makes it the new root of the mount tree. It then executes the specified init program.
This command is primarily used in initramfs to transition from the initial RAM filesystem to the real root filesystem. The old root is deleted to free memory before the switch occurs.

PARAMETERS

newroot

Path to the new root filesystem
init
Path to the init program to execute (relative to new root)
-h, --help
Display help information
-V, --version
Display version information

CAVEATS

The new root must be the root of a mount; the command will fail otherwise. Use bind-mounting as a workaround if needed. Must be run as root. Should only be used during early boot from initramfs. Part of the util-linux package.

SEE ALSO

chroot(1), pivot_root(8), mount(8), init(8)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community