Saturday, June 16, 2012

Lupa Password Root pada server Virtual Machine

Kegiatan ini sebenarnya sudah selesai saya lakukan pada tanggal 28 Februari 2012. Tetapi, baru sekarang sempat saya tuliskan lagi. Mudah-mudahan berguna 


1. Forget / lost  root password at Ubuntu OS.
2. The OS is Virtual Machine. So using physical CD is not possible to recover it.
3. Using GRUB bootloader trick (press ESC or SHIFT) was failed.


1. Login as user who has sudo to root at Host Server (physical server)

2. Instal Kpartx
   sudo apt-get install kpartx

3. Stop the VM
   virsh shutdownd VM_name

4. Go to folder where VM_name.img image file is kept
   cd /folder_location/VM/images

5. Look at loop partition which to be mounted
   kpartx -l VM_name.img
6. Create folder /mnt/another_folder
   mkdir -p /mnt/another_folder

7. Mount loop partition of VM_name.img   mount /dev/mapper/loop0p2 /mnt/another_folder

9. Go to /mnt/another_folder
   cd /mnt/iec_prod

9. Copy hash password from another Linux file. For this case, I used my password hash from Host Server (physical server)
   a. less /etc/shadow
   b. Copy entry hash password of my user from it.

10. Paste it into /mnt/another_folder/etc/shadow file
   a. cd /mnt/another_folder/etc/shadow
   b. vi /mnt/another_folder/etc/shadow
   c. Change root hash password from the hash which copied before
   d. Save it

11. Unmount /mnt/another_folder and make sure it really unmount
    a. umount /mnt/another_folder
    b. ls /mnt/another_folder  -->  Should be empty !!

12. Start the VM
    virsh start VM_name

13. Try to login with root password. Now you can login !!

References :
Post a Comment