Showing posts with label guestfish. Show all posts
Showing posts with label guestfish. Show all posts

Monday, November 3, 2014

How to change root password in a qcow2 image using guestfish?

[root@templates]# guestfish --rw -a LoadBalancer-MN.qcow2

Welcome to guestfish, the libguestfs filesystem interactive shell for
editing virtual machine filesystems.

Type: 'help' for help on commands
      'man' to read the manual
      'quit' to quit the shell

><fs> run
><fs> mount /dev/sda1 /
><fs> cp /etc/passwd /etc/passwd-bkup
><fs> vi /etc/passwd

#in the file change the root line second parameter from x to blank "":
#from: root:x:0:0:root:/root:/bin/bash to root::0:0:root:/root:/bin/bash

><fs>
><fs>
><fs> umount /
><fs> exit


How to edit an Image using guestfish?

[root@s4-50 ready_for]# guestfish --rw -a tinyCentosRouter.qcow2

Welcome to guestfish, the libguestfs filesystem interactive shell for
editing virtual machine filesystems.

Type: 'help' for help on commands
      'man' to read the manual
      'quit' to quit the shell

><fs> run
><fs> list-filesystems
/dev/sda1: ext4
/dev/VolGroup/lv_root: ext4
/dev/VolGroup/lv_swap: swap
><fs> mount /dev/VolGroup/lv_root /
><fs> ls /
.autofsck
.autorelabel
bin
boot
dev
etc
home
lib
lib64
lost+found
media
mnt
opt
proc
root
sbin
selinux
srv
sys
tmp
usr
var
><fs> vi /etc/sysctl.conf
><fs> umount /
><fs> exit

another option is to ru this command:
# guestmount -a template_a.qcow2 -w -m /dev/sda1 /mnt/image/