<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://dikapediav2.com/wiki/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://dikapediav2.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Chroot"/>
	<link rel="alternate" type="text/html" href="https://dikapediav2.com/wiki/index.php?title=Chroot&amp;action=history"/>
	<updated>2026-05-15T09:11:13Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://dikapediav2.com/wiki/index.php?title=Chroot&amp;diff=40&amp;oldid=prev</id>
		<title>Ardika Sulistija: Created page with &quot;* Very important to bind /dev since the passwd command makes use of /dev/random which needs to actually exist  Robert&#039;s way (This example shows how to change a password while chrooted):  (all sudo)      mount /dev/xvdf1 /mnt  mount -o bind /proc /mnt/proc  mount -o bind /sys /mnt/sys  mount -o bind /dev /mnt/dev  mount -o bind /run /mnt/run  #This one was recommended but I didn&#039;t end up using it    chroot /mnt    passwd [username]  exit    umount /mnt/{dev,sys,proc}  umo...&quot;</title>
		<link rel="alternate" type="text/html" href="https://dikapediav2.com/wiki/index.php?title=Chroot&amp;diff=40&amp;oldid=prev"/>
		<updated>2024-08-21T14:43:04Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;* Very important to bind /dev since the passwd command makes use of /dev/random which needs to actually exist  Robert&amp;#039;s way (This example shows how to change a password while chrooted):  (all sudo)      mount /dev/xvdf1 /mnt  mount -o bind /proc /mnt/proc  mount -o bind /sys /mnt/sys  mount -o bind /dev /mnt/dev  mount -o bind /run /mnt/run  #This one was recommended but I didn&amp;#039;t end up using it    chroot /mnt    passwd [username]  exit    umount /mnt/{dev,sys,proc}  umo...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;* Very important to bind /dev since the passwd command makes use of /dev/random which needs to actually exist&lt;br /&gt;
&lt;br /&gt;
Robert&amp;#039;s way (This example shows how to change a password while chrooted):&lt;br /&gt;
 (all sudo)  &lt;br /&gt;
 &lt;br /&gt;
 mount /dev/xvdf1 /mnt&lt;br /&gt;
 mount -o bind /proc /mnt/proc&lt;br /&gt;
 mount -o bind /sys /mnt/sys&lt;br /&gt;
 mount -o bind /dev /mnt/dev&lt;br /&gt;
 mount -o bind /run /mnt/run  #This one was recommended but I didn&amp;#039;t end up using it&lt;br /&gt;
 &lt;br /&gt;
 chroot /mnt&lt;br /&gt;
 &lt;br /&gt;
 passwd [username]&lt;br /&gt;
 exit&lt;br /&gt;
 &lt;br /&gt;
 umount /mnt/{dev,sys,proc}&lt;br /&gt;
 umount /mnt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Other way:&lt;br /&gt;
 $ mount /dev/xvdf1 /mnt&lt;br /&gt;
 $ for i in dev proc sys run; do mount -o bind /$i /mnt/$i; done&lt;br /&gt;
 $ chroot /mnt&lt;br /&gt;
 $ for i in dev proc sys run; do sudo umount /mnt/$i; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Neshons way:&lt;br /&gt;
 $ cd /tmp/rescueroot&lt;br /&gt;
 $ sudo mount -t proc /proc proc/&lt;br /&gt;
 $ sudo mount --rbind /sys sys/&lt;br /&gt;
 $ sudo mount --rbind /dev dev/&lt;br /&gt;
 $ sudo mount --rbind /run run/&lt;br /&gt;
 $ sudo chroot /tmp/rescueroot  #This one was recommended but I didn&amp;#039;t end up using it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Resetting Root Password====&lt;br /&gt;
----&lt;br /&gt;
You will have to reset the password manually by interrupting grub by using the kernel parameter &amp;lt;b&amp;gt;rd.break&amp;lt;/b&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
1. Boot the system and interrupt the booting process when you&amp;#039;re at the GRUB menu by pressing &amp;#039;e&amp;#039;.&amp;lt;/br&amp;gt;&lt;br /&gt;
2. Add the kernel parameter &amp;lt;b&amp;gt;rd.break&amp;lt;/b&amp;gt; to the Linux kernel line.&amp;lt;/br&amp;gt;&lt;br /&gt;
3. Press &amp;#039;ctrl+x&amp;#039; to boot.&amp;lt;/br&amp;gt;&lt;br /&gt;
4. You will enter the emergency mode prompt (or preboot screen, per Joe) to authenticate to unlock the drive.&amp;lt;/br&amp;gt;&lt;br /&gt;
5. Then run the following commands:&lt;br /&gt;
 # mount -o remount,rw /sysroot&lt;br /&gt;
 # chroot /sysroot&lt;br /&gt;
 # passwd &lt;br /&gt;
 # touch /.autorelabel&lt;br /&gt;
 # exit&lt;br /&gt;
 # logout&lt;br /&gt;
6. A couple of minutes and once done, the system will reboot upon which you can log in as the root user with the new password.&amp;lt;/br&amp;gt;&lt;br /&gt;
	&lt;br /&gt;
Notes:&lt;br /&gt;
* The rd.break parameter interrupts the boot process before the control is passed over to the kernel. At this point, when you run the passwd command to do the password reset, the associated shadow file (&amp;lt;b&amp;gt;/etc/shadow&amp;lt;/b&amp;gt;) is modified with an incorrect SELinux context. The touch &amp;lt;b&amp;gt;/.autorelabel&amp;lt;/b&amp;gt; command creates a hidden file named &amp;lt;b&amp;gt;.autorelabel&amp;lt;/b&amp;gt; under the root directory. On the next boot, the SELinux subsystem will detect this file, and then relabel all of the files on that system with the correct SELinux contexts. On large disks, this process can take a good amount of time.&lt;br /&gt;
	&lt;br /&gt;
Reference: &amp;lt;/br&amp;gt;&lt;br /&gt;
[+] https://www.tecmint.com/reset-forgotten-root-password-in-rhel-8/ &amp;lt;/br&amp;gt;&lt;br /&gt;
[+] https://learn.redhat.com/t5/Platform-Linux/Unable-to-reset-the-root-password-when-disabling-SELinux/td-p/21082&amp;lt;/br&amp;gt;&lt;br /&gt;
[+] https://unix.stackexchange.com/questions/509798/what-does-touch-autorelabel-do-when-we-reset-the-root-password-in-red-hat-en/509801#509801&amp;lt;/br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ardika Sulistija</name></author>
	</entry>
</feed>