{"id":2759,"date":"2022-12-20T15:17:13","date_gmt":"2022-12-20T18:17:13","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/pivot_root-man8\/"},"modified":"2022-12-20T15:17:13","modified_gmt":"2022-12-20T18:17:13","slug":"pivot_root-man8","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/pivot_root-man8\/","title":{"rendered":"PIVOT_ROOT (man8)"},"content":{"rendered":"<h1 align=\"center\">PIVOT_ROOT<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#OPTIONS\">OPTIONS<\/a><br \/> <a href=\"#EXAMPLE\">EXAMPLE<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#AVAILABILITY\">AVAILABILITY<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">pivot_root \u2212 change the root filesystem<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>pivot_root<\/b> <i>new_root put_old<\/i><\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><i><b>pivot_root<\/b><\/i> moves the root file system of the current process to the directory <i>put_old<\/i> and makes <i>new_root<\/i> the new root file system. Since <b>pivot_root<\/b>(8) simply calls <b>pivot_root<\/b>(2), we refer to the man page of the latter for further details.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Note that, depending on the implementation of <b>pivot_root<\/b>, root and cwd of the caller may or may not change. The following is a sequence for invoking <b>pivot_root<\/b> that works in either case, assuming that <b>pivot_root<\/b> and <b>chroot<\/b> are in the current <b>PATH<\/b>:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">cd <i>new_root<\/i> <br \/> pivot_root . <i>put_old<\/i> <br \/> exec chroot . <i>command<\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Note that <b>chroot<\/b> must be available under the old root and under the new root, because <b>pivot_root<\/b> may or may not have implicitly changed the root directory of the shell.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Note that <b>exec chroot<\/b> changes the running executable, which is necessary if the old root directory should be unmounted afterwards. Also note that standard input, output, and error may still point to a device on the old root file system, keeping it busy. They can easily be changed when invoking <b>chroot<\/b> (see below; note the absence of leading slashes to make it work whether <b>pivot_root<\/b> has changed the shell\u2019s root or not).<\/p>\n<h2>OPTIONS <a name=\"OPTIONS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>\u2212V<\/b>, <b>\u2212\u2212version<\/b><\/p>\n<p style=\"margin-left:22%;\">Display version information and exit.<\/p>\n<p style=\"margin-left:11%;\"><b>\u2212h<\/b>, <b>\u2212\u2212help<\/b><\/p>\n<p style=\"margin-left:22%;\">Display help text and exit.<\/p>\n<h2>EXAMPLE <a name=\"EXAMPLE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Change the root file system to \/dev\/hda1 from an interactive shell:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">mount \/dev\/hda1 \/new-root <br \/> cd \/new-root <br \/> pivot_root . old-root <br \/> exec chroot . sh <dev\/console >dev\/console 2>&#038;1 <br \/> umount \/old-root<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Mount the new root file system over NFS from 10.0.0.1:\/my_root and run <b>init<\/b>:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">ifconfig lo 127.0.0.1 up # for portmap <br \/> # configure Ethernet or such <br \/> portmap # for lockd (implicitly started by mount) <br \/> mount \u2212o ro 10.0.0.1:\/my_root \/mnt <br \/> killall portmap # portmap keeps old root busy <br \/> cd \/mnt <br \/> pivot_root . old_root <br \/> exec chroot . sh \u2212c \u2019umount \/old_root; exec \/sbin\/init\u2019  <br \/> <dev\/console >dev\/console 2>&#038;1<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>chroot<\/b>(1), <b>pivot_root<\/b>(2), <b>mount<\/b>(8), <b>switch_root<\/b>(8), <b>umount<\/b>(8)<\/p>\n<h2>AVAILABILITY <a name=\"AVAILABILITY\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The pivot_root command is part of the util-linux package and is available from https:\/\/www.kernel.org\/pub\/linux\/utils\/util-linux\/.<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  pivot_root \u2212 change the root filesystem <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[5,52,4,113],"class_list":["post-2759","post","type-post","status-publish","format-standard","hentry","category-8-administracion-del-sistema","tag-5","tag-administracion","tag-man8","tag-pivot_root"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/2759","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=2759"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/2759\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=2759"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=2759"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=2759"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}