PIVOT_ROOT(8)

๐Ÿ‘‘ pivot_root โ€” the manual, but make it make sense

okay bestie, so this is pivot_root from section 8 of the manual (System Administration), and it's literally the glow-up your filesystem has been waiting for ๐Ÿ’…


โœจ NAME โœจ

pivot_root โ€” change the root filesystem ๐ŸŒฑ


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

pivot_root new_root put_old

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

so here's the tea: pivot_root moves the root file system of the current process into the directory put_old, and then makes new_root the brand new root file system. main character energy, fr fr. and because pivot_root(8) is literally just calling pivot_root(2), we're pointing you at the man page for the latter if you want the deeper lore ๐Ÿ“–

heads up bestie: depending on how pivot_root is implemented, the root directory and the current working directory of whoever's calling it may or may not change. so yeah, it's giving it depends ๐Ÿ™ˆ

here's a sequence for invoking pivot_root that works either way, assuming pivot_root and chroot are in the current PATH:

cd new_root
pivot_root . put_old
exec chroot . command

note that chroot must be available under the old root and under the new root, because pivot_root may or may not have implicitly changed the root directory of the shell. no cap.

also note that exec chroot changes the running executable โ€” and that's necessary if you want the old root directory to be unmounted afterwards. periodt. and one more thing: standard input, output, and error may still point to a device on the old root file system, which keeps it busy ๐Ÿ‘€ they can easily be changed when invoking chroot (see below; and notice the absence of leading slashes, which is what makes it work whether pivot_root has changed the shell's root or not ๐Ÿงš)


๐Ÿ’– OPTIONS ๐Ÿ’–

  • -h, --help โ€” shows you the help text and dips out โœŒ๏ธ
  • -V, --version โ€” shows you the version and dips out โœŒ๏ธ

๐ŸŒธ EXAMPLE ๐ŸŒธ

want to change the root file system to /dev/hda1 from an interactive shell? say less:

mount /dev/hda1 /new-root
cd /new-root
pivot_root . old-root
exec chroot . sh <dev/console >dev/console 2>&1
umount /old-root

and if you want to mount the new root file system over NFS from 10.0.0.1:/my_root and run init? we love a networked slay ๐Ÿ”ฅ

ifconfig lo 127.0.0.1 up   # for portmap
# configure Ethernet or such
portmap   # for lockd (implicitly started by mount)
mount -o ro 10.0.0.1:/my_root /mnt
killall portmap   # portmap keeps old root busy
cd /mnt
pivot_root . old_root
exec chroot . sh -c 'umount /old_root; exec /sbin/init' \
  <dev/console >dev/console 2>&1

โญ SEE ALSO โญ

chroot(1), pivot_root(2), mount(8), switch_root(8), umount(8) โ€” go read those too, iykyk ๐Ÿซถ


๐Ÿ’€ REPORTING BUGS ๐Ÿ’€

found a bug? not me manifesting that ๐Ÿ˜ญ for bug reports, use the issue tracker here: <https://github.com/util-linux/util-linux/issues>.


๐ŸŒˆ AVAILABILITY ๐ŸŒˆ

the pivot_root command is part of the util-linux package, which you can download from the Linux Kernel Archive: <https://www.kernel.org/pub/linux/utils/util-linux/>.


and that's the whole page bestie, you ate ๐Ÿ’… this was util-linux 2.42.4, dated 2026-09-21, and it was iconic. go pivot something. mwah ๐ŸŽ€โœจ

๐Ÿ“ฆ where this page comes from
  • arch rolling: util-linux 2.42.4-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause-UC AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND ISC AND LGPL-2.1-or-later AND LicenseRef-PublicDomain
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms