<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki2025.debian.org/index.php?action=history&amp;feed=atom&amp;title=Chroot</id>
	<title>Chroot - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki2025.debian.org/index.php?action=history&amp;feed=atom&amp;title=Chroot"/>
	<link rel="alternate" type="text/html" href="https://wiki2025.debian.org/index.php?title=Chroot&amp;action=history"/>
	<updated>2026-11-01T18:10:13Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.9</generator>
	<entry>
		<id>https://wiki2025.debian.org/index.php?title=Chroot&amp;diff=1649&amp;oldid=prev</id>
		<title>Mok0 at 16:31, 28 September 2026</title>
		<link rel="alternate" type="text/html" href="https://wiki2025.debian.org/index.php?title=Chroot&amp;diff=1649&amp;oldid=prev"/>
		<updated>2026-09-28T16:31:18Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;a href=&quot;https://wiki2025.debian.org/index.php?title=Chroot&amp;amp;diff=1649&amp;amp;oldid=1648&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>Mok0</name></author>
	</entry>
	<entry>
		<id>https://wiki2025.debian.org/index.php?title=Chroot&amp;diff=1648&amp;oldid=prev</id>
		<title>Mok0: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://wiki2025.debian.org/index.php?title=Chroot&amp;diff=1648&amp;oldid=prev"/>
		<updated>2026-09-28T16:29:17Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 16:29, 28 September 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;4&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key mediawiki-mediawiki-:diff:1.41:old-1638:rev-1648 --&gt;
&lt;/table&gt;</summary>
		<author><name>Mok0</name></author>
	</entry>
	<entry>
		<id>https://wiki2025.debian.org/index.php?title=Chroot&amp;diff=1638&amp;oldid=prev</id>
		<title>Mok0: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://wiki2025.debian.org/index.php?title=Chroot&amp;diff=1638&amp;oldid=prev"/>
		<updated>2026-09-28T16:28:31Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;a href=&quot;https://wiki2025.debian.org/index.php?title=Chroot&amp;amp;diff=1638&amp;amp;oldid=1647&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>Mok0</name></author>
	</entry>
	<entry>
		<id>https://wiki2025.debian.org/index.php?title=Chroot&amp;diff=1647&amp;oldid=prev</id>
		<title>mok0&gt;Morten Kjeldgaard: Not currently under git control</title>
		<link rel="alternate" type="text/html" href="https://wiki2025.debian.org/index.php?title=Chroot&amp;diff=1647&amp;oldid=prev"/>
		<updated>2026-09-28T16:18:39Z</updated>

		<summary type="html">&lt;p&gt;Not currently under git control&lt;/p&gt;
&lt;a href=&quot;https://wiki2025.debian.org/index.php?title=Chroot&amp;amp;diff=1647&amp;amp;oldid=1637&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>mok0&gt;Morten Kjeldgaard</name></author>
	</entry>
	<entry>
		<id>https://wiki2025.debian.org/index.php?title=Chroot&amp;diff=1637&amp;oldid=prev</id>
		<title>mok0&gt;Morten Kjeldgaard: Not currently under git control</title>
		<link rel="alternate" type="text/html" href="https://wiki2025.debian.org/index.php?title=Chroot&amp;diff=1637&amp;oldid=prev"/>
		<updated>2026-09-28T08:02:48Z</updated>

		<summary type="html">&lt;p&gt;Not currently under git control&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;!-- language en --&amp;gt;&lt;br /&gt;
&amp;lt;!-- pragma supplementation-page on --&amp;gt;&lt;br /&gt;
&amp;lt;!-- #For Translators - to have a constantly up to date translation header in you page, you can just add a line like the following (with the comment&amp;#039;s character at the start of the line removed) --&amp;gt;&lt;br /&gt;
&amp;lt;!-- #&amp;lt;&amp;lt;Include(chroot, ,from=&amp;quot;^##TAG:TRANSLATION-HEADER-START&amp;quot;,to=&amp;quot;^##TAG:TRANSLATION-HEADER-END&amp;quot;)&amp;gt;&amp;gt; --&amp;gt;&lt;br /&gt;
&amp;lt;!-- #TAG:TRANSLATION-HEADER-START --&amp;gt;&lt;br /&gt;
&amp;lt;small&amp;gt;[[DebianWiki/EditorGuide#translation|Translation(s)]]: [[de/chroot|Deutsch]]&amp;lt;nowiki&amp;gt; &amp;lt;/nowiki&amp;gt;- [[chroot|English]]&amp;lt;nowiki&amp;gt; &amp;lt;/nowiki&amp;gt;- [[es/chroot|Español]]&amp;lt;nowiki&amp;gt; &amp;lt;/nowiki&amp;gt;- [[fr/Chroot|Français]]&amp;lt;nowiki&amp;gt; &amp;lt;/nowiki&amp;gt;- [[it/chroot|Italiano]]&amp;lt;/small&amp;gt;&lt;br /&gt;
&amp;lt;!-- #TAG:TRANSLATION-HEADER-END --&amp;gt;&lt;br /&gt;
-----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[DebianMan:chroot]] is an utility that changes which folder is considered the root of the filesystem hierarchy by its child processes, so that it is impossible for them to access the parent folder of the new root, even though it physically exists on the disk.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
-------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Common use-cases =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div&amp;gt;&amp;#039;&amp;#039;&amp;#039;&amp;lt;code&amp;gt;chroot&amp;lt;/code&amp;gt;&amp;lt;nowiki&amp;gt; &amp;lt;/nowiki&amp;gt;utility is intended mostly for an occasional, ad-hoc usage.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
If you regularly need different environments, then consider a container runtime like &amp;lt;code&amp;gt;podman&amp;lt;/code&amp;gt; instead.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Fast switching to another environment (distro, version, flavor, package mix etc) for the purposes of testing, building, debugging etc.&lt;br /&gt;
* Repairing a broken Linux installation by connecting its primary drive as an external device (for example using an USB enclosure) to some other working system and performing operations from within the system being repaired.&lt;br /&gt;
* Historically &amp;lt;code&amp;gt;chroot&amp;lt;/code&amp;gt; was also used to increase the security of network services running on a given machine: if an attacker managed to trick a service to an [https://en.wikipedia.org/wiki/Arbitrary_code_execution arbitrary code execution], he would still not have access to the whole filesystem of the machine (he would remain in a so called &amp;#039;&amp;#039;chroot jail&amp;#039;&amp;#039;). This however does not prevent the attacker from using the machine&amp;#039;s network interfaces to further penetrate the internal network, moreover on Linux and some other UNIXes, escaping a &amp;quot;chroot jail&amp;quot; is relatively easy. As a result, for security-related purposes &amp;lt;code&amp;gt;chroot&amp;lt;/code&amp;gt; was replaced by virtual machines and containers.&lt;br /&gt;
&lt;br /&gt;
-------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Basic setup and usage =&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Unless explicitly stated otherwise, all commands in the below subsections require &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt;&amp;lt;nowiki&amp;gt; &amp;lt;/nowiki&amp;gt;privileges.&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create or provide a file hierarchy of a Linux system ==&lt;br /&gt;
&lt;br /&gt;
In the subsequent sections, &amp;#039;&amp;#039;&amp;#039;&amp;lt;code&amp;gt;${chrootFolder}&amp;lt;/code&amp;gt;&amp;#039;&amp;#039;&amp;#039; will refer to the root folder of a file hierarchy created or provided as described below.&lt;br /&gt;
&lt;br /&gt;
* In case of switching to existing installations, it boils down to mounting their root filesystem at a target folder of your choice.&lt;br /&gt;
* In case you want to create a fresh Debian image, you can use utilities such as [[DebianMan:mmdebstrap]], for example to create a clean environment to build deb packages:&amp;lt;pre&amp;gt;&lt;br /&gt;
mmdebstrap --skip=output/dev,output/mknod --variant=buildd \&lt;br /&gt;
    trixie &amp;quot;${chrootFolder}&amp;quot; http://deb.debian.org/debian&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Mount virtual filesystems ==&lt;br /&gt;
&lt;br /&gt;
As of 2026 these are &amp;lt;code&amp;gt;proc&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sysfs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;udev&amp;lt;/code&amp;gt; and &amp;quot;children&amp;quot; of the latter 2 of which there are too many and which also tend to die off or spawn way too often. Fortunately, [[DebianMan:mount]] has &amp;lt;code&amp;gt;--rbind&amp;lt;/code&amp;gt; option that allows to bind an already mounted filesystem together with all its children to an additional target folder. You need to use either &amp;lt;code&amp;gt;--make-rslave&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;--make-rprivate&amp;lt;/code&amp;gt; flag too (see [[DebianMan:mount_namespaces]] for details).&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mount -t proc proc &amp;quot;${chrootFolder}/proc&amp;quot;&lt;br /&gt;
mount --rbind --make-rslave /sys &amp;quot;${chrootFolder}/sys&amp;quot;&lt;br /&gt;
mount --rbind --make-rslave /dev &amp;quot;${chrootFolder}/dev&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In case you are wondering: &amp;lt;code&amp;gt;proc&amp;lt;/code&amp;gt; has 1 child also: &amp;lt;code&amp;gt;binfmt_misc&amp;lt;/code&amp;gt;, which is used for registering binary executable handlers/interpreters, which does not make sense in a &amp;lt;code&amp;gt;chroot&amp;lt;/code&amp;gt; (the absolute path of a given interpreter needs to be provided, which is inaccessible from a &amp;lt;code&amp;gt;chroot&amp;lt;/code&amp;gt;-ed context), therefore no point in binding it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Copy the DNS resolver config ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cp /etc/resolv.conf &amp;quot;${chrootFolder}/etc/&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Perform a chroot switch ==&lt;br /&gt;
&lt;br /&gt;
This usually boils down to&amp;lt;pre&amp;gt;&lt;br /&gt;
chroot &amp;quot;${chrootFolder}&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
...which will start an interactive login shell of &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt; user inside the &amp;lt;code&amp;gt;chroot&amp;lt;/code&amp;gt;-ed environment, so that you can interactively perform whatever tasks you need.&lt;br /&gt;
&lt;br /&gt;
For non-interactive tasks, you can instead provide an alternative command and its args:&amp;lt;pre&amp;gt;&lt;br /&gt;
chroot &amp;quot;${chrootFolder}&amp;quot; /root/myScriptToBeExecutedInChroot.sh myArg1 myArg2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;/root/myScriptToBeExecutedInChroot.sh&amp;lt;/code&amp;gt; is a path inside the &amp;lt;code&amp;gt;chroot&amp;lt;/code&amp;gt;-ed hierarchy.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Cleanup ==&lt;br /&gt;
&lt;br /&gt;
After the &amp;lt;code&amp;gt;chroot&amp;lt;/code&amp;gt; process exits, you need to unbind / &amp;lt;code&amp;gt;umount&amp;lt;/code&amp;gt; all the virtual filesystems bound / mounted previously. Fortunately &amp;lt;code&amp;gt;umount&amp;lt;/code&amp;gt; also has &amp;lt;code&amp;gt;--recursive&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;-R&amp;lt;/code&amp;gt; flag to help with this:&amp;lt;pre&amp;gt;&lt;br /&gt;
umount -R &amp;quot;${chrootFolder}/dev&amp;quot;&lt;br /&gt;
umount -R &amp;quot;${chrootFolder}/sys&amp;quot;&lt;br /&gt;
umount -R &amp;quot;${chrootFolder}/proc&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If &amp;lt;code&amp;gt;${chrootFolder}&amp;lt;/code&amp;gt; is a mount point of an external drive and you want to &amp;lt;code&amp;gt;umount&amp;lt;/code&amp;gt; it also, you can replace all the above commands with the below single one:&amp;lt;pre&amp;gt;&lt;br /&gt;
umount -R &amp;quot;${chrootFolder}&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Additional notes and scenarios =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Running X11 GUI apps ==&lt;br /&gt;
&lt;br /&gt;
Running X11 GUI apps from within a &amp;lt;code&amp;gt;chroot&amp;lt;/code&amp;gt;-ed environment and displaying them on host&amp;#039;s X11 server works using standard mechanisms: just export the value of &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; env var from the host in the &amp;lt;code&amp;gt;chroot&amp;lt;/code&amp;gt; and make sure the host X server will allow connections (for example using [[DebianMan:xhost]] utility).&lt;br /&gt;
&lt;br /&gt;
-----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Running Systemd services ==&lt;br /&gt;
&lt;br /&gt;
Systemd services will generally refuse to run in a &amp;lt;code&amp;gt;chroot&amp;lt;/code&amp;gt;-ed environment. Use [[nspawn|systemd-nspawn]] instead of &amp;lt;code&amp;gt;chroot&amp;lt;/code&amp;gt; if you need to run Systemd services.&lt;br /&gt;
&lt;br /&gt;
-----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Foreign architectures ==&lt;br /&gt;
&lt;br /&gt;
If [[DebianPkg:qemu-user-binfmt]] is installed, it is possible to &amp;lt;code&amp;gt;chroot&amp;lt;/code&amp;gt; to a filesystem for any foreign arch it supports.&lt;br /&gt;
&lt;br /&gt;
-----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Modifying boot data ==&lt;br /&gt;
&lt;br /&gt;
If you want to modify the boot data of another system whose drive you &amp;lt;code&amp;gt;chroot&amp;lt;/code&amp;gt;-ed into (this includes for example running &amp;lt;code&amp;gt;update-grub&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;update-initramfs&amp;lt;/code&amp;gt;, installing a new kernel or firmware + kernel modules for boot-critical devices etc), you need to mount its &amp;lt;code&amp;gt;/boot&amp;lt;/code&amp;gt; hierarchy. This may include the following:&lt;br /&gt;
* &amp;lt;code&amp;gt;/boot&amp;lt;/code&amp;gt; itself is sometimes a separate partition, most commonly on systems using some disk encryption scheme.&lt;br /&gt;
* On UEFI systems (which includes most of modern x86 and ARM hardware), their ESP partitions are mounted at &amp;lt;code&amp;gt;/boot/efi&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It is usually most convenient to mount these filesystems right after performing a &amp;lt;code&amp;gt;chroot&amp;lt;/code&amp;gt; switch.&lt;br /&gt;
&lt;br /&gt;
After performing a &amp;lt;code&amp;gt;chroot&amp;lt;/code&amp;gt; switch, check which filesystem are present by running &amp;lt;code&amp;gt;grep /boot /etc/fstab&amp;lt;/code&amp;gt;. Below is an example output from a system with both &amp;lt;code&amp;gt;/boot&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/boot/efi&amp;lt;/code&amp;gt; entries:&amp;lt;pre&amp;gt;&lt;br /&gt;
UUID=7a307683-255a-4bac-937f-95aa2af2ca17  /boot      ext4  defaults    0  2&lt;br /&gt;
UUID=4D18-6163                             /boot/efi  vfat  umask=0077  0  1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If &amp;lt;code&amp;gt;/etc/fstab&amp;lt;/code&amp;gt; entries use UUIDs as in the example above (which is the default on most modern distros) or unique &amp;lt;code&amp;gt;PARTLABEL&amp;lt;/code&amp;gt;s or &amp;lt;code&amp;gt;LABEL&amp;lt;/code&amp;gt;s, then all you need to do is to point &amp;lt;code&amp;gt;mount&amp;lt;/code&amp;gt; to their corresponding mount-points:&amp;lt;pre&amp;gt;&lt;br /&gt;
mount /boot&lt;br /&gt;
mount /boot/efi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On some older systems, instead of UUIDs or labels, device nodes may be used in &amp;lt;code&amp;gt;/etc/fstab&amp;lt;/code&amp;gt;, like for example &amp;lt;code&amp;gt;/dev/sdaX&amp;lt;/code&amp;gt; etc. In such case you need to figure out what device node currently corresponds to a given filesystem. Most commonly, it will be another partition on the same physical drive as the root filesystem of that external system.&lt;br /&gt;
&lt;br /&gt;
After you are done with your &amp;lt;code&amp;gt;chroot&amp;lt;/code&amp;gt; work, these filesystems may be &amp;lt;code&amp;gt;umount&amp;lt;/code&amp;gt;-ed either from within the &amp;lt;code&amp;gt;chroot&amp;lt;/code&amp;gt; or after exiting.&lt;br /&gt;
&lt;br /&gt;
-----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[:Category:System]] | [[:Category:Virtualization]]&lt;br /&gt;
&lt;/div&gt;</summary>
		<author><name>mok0&gt;Morten Kjeldgaard</name></author>
	</entry>
</feed>