Change root password in linux

Boot from a live cd / USB drive, then in the terminal:

mount / -n -o remount.rw
passwd
mount / -n -o remount.ro
/sbin/reboot
Batch resize images in linux terminal