{
    "mode": "man",
    "parameter": "pivot_root",
    "section": "8",
    "url": "https://www.chedong.com/phpMan.php/man/pivot_root/8/json",
    "generated": "2026-05-30T07:08:30Z",
    "synopsis": "pivotroot newroot putold",
    "sections": {
        "NAME": {
            "content": "pivotroot - change the root filesystem\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "pivotroot newroot putold\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "pivotroot moves the root file system of the current process to the directory putold and\nmakes newroot the new root file system. Since pivotroot(8) simply calls pivotroot(2), we\nrefer to the man page of the latter for further details.\n\nNote that, depending on the implementation of pivotroot, root and current working directory\nof the caller may or may not change. The following is a sequence for invoking pivotroot that\nworks in either case, assuming that pivotroot and chroot are in the current PATH:\n\ncd newroot\npivotroot . putold\nexec chroot . command\n\nNote that chroot must be available under the old root and under the new root, because\npivotroot may or may not have implicitly changed the root directory of the shell.\n\nNote that exec chroot changes the running executable, which is necessary if the old root\ndirectory should be unmounted afterwards. Also note that standard input, output, and error\nmay still point to a device on the old root file system, keeping it busy. They can easily be\nchanged when invoking chroot (see below; note the absence of leading slashes to make it work\nwhether pivotroot has changed the shell’s root or not).\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "-V --version",
                    "content": "Display version information and exit.\n",
                    "flag": "-V",
                    "long": "--version"
                },
                {
                    "name": "-h --help",
                    "content": "Display help text and exit.\n",
                    "flag": "-h",
                    "long": "--help"
                }
            ]
        },
        "EXAMPLE": {
            "content": "Change the root file system to /dev/hda1 from an interactive shell:\n\nmount /dev/hda1 /new-root\ncd /new-root\npivotroot . old-root\nexec chroot . sh <dev/console >dev/console 2>&1\numount /old-root\n\nMount the new root file system over NFS from 10.0.0.1:/myroot and run init:\n\nifconfig lo 127.0.0.1 up   # for portmap\n# configure Ethernet or such\nportmap   # for lockd (implicitly started by mount)\nmount -o ro 10.0.0.1:/myroot /mnt\nkillall portmap   # portmap keeps old root busy\ncd /mnt\npivotroot . oldroot\nexec chroot . sh -c 'umount /oldroot; exec /sbin/init' \\\n<dev/console >dev/console 2>&1\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "chroot(1), pivotroot(2), mount(8), switchroot(8), umount(8)\n",
            "subsections": []
        },
        "REPORTING BUGS": {
            "content": "For bug reports, use the issue tracker at https://github.com/karelzak/util-linux/issues.\n",
            "subsections": []
        },
        "AVAILABILITY": {
            "content": "The pivotroot command is part of the util-linux package which can be downloaded from Linux\nKernel Archive <https://www.kernel.org/pub/linux/utils/util-linux/>.\n\n\n\nutil-linux 2.37.2                            2021-06-02                                PIVOTROOT(8)",
            "subsections": []
        }
    },
    "summary": "pivotroot - change the root filesystem",
    "flags": [
        {
            "flag": "-V",
            "long": "--version",
            "arg": null,
            "description": "Display version information and exit."
        },
        {
            "flag": "-h",
            "long": "--help",
            "arg": null,
            "description": "Display help text and exit."
        }
    ],
    "examples": [
        "Change the root file system to /dev/hda1 from an interactive shell:",
        "mount /dev/hda1 /new-root",
        "cd /new-root",
        "pivotroot . old-root",
        "exec chroot . sh <dev/console >dev/console 2>&1",
        "umount /old-root",
        "Mount the new root file system over NFS from 10.0.0.1:/myroot and run init:",
        "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:/myroot /mnt",
        "killall portmap   # portmap keeps old root busy",
        "cd /mnt",
        "pivotroot . oldroot",
        "exec chroot . sh -c 'umount /oldroot; exec /sbin/init' \\",
        "<dev/console >dev/console 2>&1"
    ],
    "see_also": [
        {
            "name": "chroot",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/chroot/1/json"
        },
        {
            "name": "pivotroot",
            "section": "2",
            "url": "https://www.chedong.com/phpMan.php/man/pivotroot/2/json"
        },
        {
            "name": "mount",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/mount/8/json"
        },
        {
            "name": "switchroot",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/switchroot/8/json"
        },
        {
            "name": "umount",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/umount/8/json"
        }
    ]
}