chroot
An excellent guide from Bart Simons
Classics
Support and Help
Password Recovery
[CentOS] Reset Root Password (single user mode)
If you don’t remember the root password, or you just want to boot in the most minimal way, you can add init=/bin/bash
to your linux line to bypass the regular init sequence and just drop to a shell. The line should look like
linux /vmlinuz-xxx root=xxx ro init=/bin/bash
Whatever is after vmlinuz and root (where the xxxs are) leave as-is. You can remove everything else on that line except for the leading word linux
, vmlinuz
, root
and ro
. Add init=/bin/bash
The system ought to boot and present a bash shell running as user root. If your system has full-disk encryption, you will need to enter the encryption password.
At this command line, run the following commands:
mount -o remount,rw / mount /proc
Then you can view and modify the user database. The main user database file is /etc/passwd
. It contains user names (for both physical users and system accounts), but passwords are in a different file /etc/shadow
. If you’ve forgotten a password, you can’t recover it, all you can do is change it.
If you want to change the password for an account, run
passwd root
to change user root’s password.
If you see a token manipulation error
then make sure you booted into an environment that supports read/write (use rw
in linux
line or remount as rw
).
Once you’re finished, you can reboot.
umount / reboot
[CentOS] Reset Root Password (live CD chroot mode)
- Boot into your live environment
- Make directory on which to mount your partition
mkdir ./mnt || /bin/true
- Identify your disks using
fdisk
fdisk -l
- Look for the bootable partition of type Linux
- If your partition is a standard Linux partition:
mount /dev/sda1 ./mnt
- If your partition is a Linux LVM:
pvscan vgscan vgchange -a y lvscan mount /dev/sda1 ./mnt mount --bind /dev ./mnt/dev< mount --bind /proc ./mnt/proc mount --bind /sys ./mnt/sys
- Change root into your mounted directory
chroot ./mnt /bin/bash
- Type
passwd
and enter a new password - Type
reboot
to reboot your system
Provisioning
Foreman – PXEless Bare Metal & Virtual Machine Provisioning
Volume Management
[LVM] Working With LVM Volumes