Linux command
switch_root 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Switch
switch_root [new_root] [/sbin/init]
说明
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.
参数
- 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
FAQ
What is the switch_root command used for?
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.
How do I run a basic switch_root example?
Run `switch_root [new_root] [/sbin/init]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does newroot do in switch_root?
Path to the new root filesystem