The problem:
There is a CentOS 5 or RedHat 4 (perhaps versions below or above also) installation with a root password I don't know. I forgot or I simply don't know it, and there are no other accounts on this machine.
Theoretical solution:
I have to write the /etc/shadow file, but I have to write my new password somehow hashed into this file without having any other CentOS like system installed for encoding passwords. I have to boot from some other linux dist and write the file from that environment.
Solution:
echo "mypassword" | makepasswd --clearfrom=- --crypt-md5 |awk '{ print $2 }'
fdisk -l
mount /dev/sda1 /mnt
gedit /mnt/etc/shadow
root:$1$...