Skip to content
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions pages/linux/pivot_root.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# pivot_root

> Change the root filesystem to a new directory and move the current root to another location.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
> Change the root filesystem to a new directory and move the current root to another location.
> Change the root filesystem to a new directory and move the current root to a subdirectory of the new root.

> Commonly used during system initialization (e.g., in initramfs) to switch from a temporary root to the real root filesystem.
> More information: <https://manned.org/pivot_root>.

- Move the current root to `/old_root` and make `/new_root` the new root:
Copy link
Member

@Managor Managor Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Move the current root to `/old_root` and make `/new_root` the new root:
- Make `/new_root` the new root (`/`) and move current root to a subdirectory of it:


`sudo pivot_root /new_root /new_root/old_root`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you give me an example on how this should look like in a real world scenario?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you give me an example on how this should look like in a real world scenario?

This usage can all be found online, and there are many detailed cases explaining its application
mkdir -p /mnt/newroot/old_root

cd /mnt/newroot

pivot_root . old_root

umount -l /old_root

Copy link
Member

@Managor Managor Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`sudo pivot_root /new_root /new_root/old_root`
`sudo pivot_root {{path/to/new_root}} {{path/to/new_root/old_root}}`

Thanks, I just needed an example before I suggest any changes.


- Display help:

`sudo pivot_root --help`
Loading