Wow, just like in Mr Robot when he chroot to pass his mint to rkhunter I feel all-powerful on the system.
Setting the scene:
Oh no… noo? NOOOOOOOO !!!!!!!!!
It’s all broken, there’s no way to access the system, there are three scenarios that come to mind (recently happened):
- update cut in the middle (at a crucial moment)
- root pass disappeared (magic ! woohoo)
- fstab at openbsd boot to an unmounted nfs without soft option ( the misery)
There are probably a lot of other cases but we will cut the article in 2 (linux and openbsd)
Either we want to save another Linux which is all wrong, in which case, we have to mount the hard drive in say (very original)… /mnt:
mount /dev/sdx /mnt
mount --bind /dev /mnt/dev
mount -t proc /proc /mnt/proc
mount -t sysfs /sys /mnt/sys
Another Linuxian case (thanks to the roasting disks or mouldy kernels updates (I can only blame myself (argh I parenthesis all in lisp mode (long agony in perspective 😉 )))
When booting in grub, I edit with ‘e’, at the end of the linux line you have to add rd.break then ctrl+x to boot.
This gives a shell, that’s where the magic appears, the sysroot is read-only, it must be remountered in rw:
mount -o remount,rw /sysroot chroot /sysroot
And there we can work to save the world, #exit to get out
on OpenBSD, as always… or almost everything is indicated in the FAQ, but to paraphrase:
boot> boot -s
Then you have to go back up / and /usr in writable:
fsck -p / && mount -uw / fsck -p /usr && mount /usr
Finally, it is possible to launch passwd or do the admin trick to save the world…