{"id":3037,"date":"2024-11-13T18:02:31","date_gmt":"2024-11-13T17:02:31","guid":{"rendered":"https:\/\/digitalia.culturanuova.net\/blog\/?p=3037"},"modified":"2024-11-14T15:20:25","modified_gmt":"2024-11-14T14:20:25","slug":"chroot-in-linux","status":"publish","type":"post","link":"https:\/\/digitalia.culturanuova.net\/blog\/?p=3037","title":{"rendered":"chroot in linux"},"content":{"rendered":"\n<p>Chroot is a <strong>very useful feature<\/strong> in Linux systems: you can update a Linux installation on your PC not within that installation, as usually we can do, but from another installation.<\/p>\n\n\n\n<p>I.g. if you have Linux1 on \/dev\/sda2 and Linux2 on \/dev\/sda3 and you cannot login into Linux2, you can try to solve the problem by doing an update of Linux2 from Linux1. Using chroot.<\/p>\n\n\n\n<p>There are very good guides on the web, but, let us repeat the essential steps<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>first of all be sure of the correct name of the partition you want chroot in (i.g. \/dev\/sda3, or \/dev\/sdb2)<\/li>\n\n\n\n<li>create a \/mnt where you will mount that installation, i.g. \/mnt\/chroot<\/li>\n\n\n\n<li>mount that installation in \/mnt\/chroot: <code>sudo mount -t ext4 \/dev\/sda3 \/mnt\/chroot <\/code>(note that <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">etx4<\/mark> is if that is the filesystem, but it could be <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">btrfs<\/mark> as well or another filesystem)<\/li>\n\n\n\n<li>mount efi partion (if you have efi): <code>sudo mount -t vfat \/dev\/sda1 \/mnt\/chroot\/boot\/efi\/<\/code><\/li>\n\n\n\n<li>mount virtual folders of that installation: <code>for i in dev proc sys run; do sudo mount --bind \/$i \/mnt\/chroot\/$i; done<\/code><\/li>\n\n\n\n<li>Do the chroot: <code>sudo chroot \/mnt\/chroot<\/code><\/li>\n<\/ul>\n\n\n\n<p>What you do now, within the terminal where you did the chroot is what you could do if you were in that installation (Linux2).<br>Typically you should do these commands<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>apt update<\/code> (<strong>without <code>sudo<\/code><\/strong> before apt: you are <em>already<\/em> acting as superuser)<\/li>\n\n\n\n<li>apt upgrade (or apt full-upgrade)<\/li>\n\n\n\n<li>update-grub<\/li>\n<\/ul>\n\n\n\n<p>Afterwards you can exit with:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>for i in \/dev \/proc \/sys \/run \/; do sudo umount -l \/mnt\/chroot\/$i; done<\/code> <\/li>\n\n\n\n<li>and: <code>sudo umount \/dev\/sda2 \/mnt\/chroot\/boot\/efi\/<\/code> <\/li>\n\n\n\n<li>and:  <code>sudo umount \/dev\/sda3 \/mnt(chroot<\/code>  <\/li>\n<\/ul>\n\n\n\n<p>Note that these last two commands could be not necessary.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Chroot is a very useful feature in Linux systems: you can update a Linux installation on your PC not within that installation, as usually we can do, but from another installation. I.g. if you have Linux1 on \/dev\/sda2 and Linux2 on \/dev\/sda3 and you cannot login into Linux2, you can try to solve the problem &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/digitalia.culturanuova.net\/blog\/?p=3037\" class=\"more-link\">Leggi tutto<span class=\"screen-reader-text\"> &#8220;chroot in linux&#8221;<\/span><\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[716,647,573],"tags":[889],"class_list":["post-3037","post","type-post","status-publish","format-standard","hentry","category-boot","category-linux","category-sistema-operativo","tag-chroot"],"_links":{"self":[{"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3037","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3037"}],"version-history":[{"count":10,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3037\/revisions"}],"predecessor-version":[{"id":3047,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3037\/revisions\/3047"}],"wp:attachment":[{"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3037"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3037"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3037"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}