guestfish
I'm trying to figure out the proper way to use guestfish in host down scenario. Say, we have a RHEV VM that won't boot and the possible fix is to modify a config file (i.e. lvm.conf). How do I go about using guetfish to mount that file system so I can make a change to the configuration files? Basically, I want to know how to use guestfish in RHEV similar to using a rescue disk.
In the past, I tried by activating the VM's logical volume, then mounting it with guestfish. Doing this actually caused more issues that I was never able to resolve. Unfortunately, it was long enough ago, that I don't remember the exact issues.
Thank you,
Responses
Hi Douglas,
It is more easy as you might think ... all you need to do is : sudo yum install libguestfs-tools
Here are some examples how to use the tools (the virtual guest system gets mounted automatically) :
Show the content of the /etc/fstab file of the guest system ->sudo virt-cat -d domain-name (e.g.redhat-server) /etc/fstab
Copy a file from the host /home directory into the /home directory of the guest system ->sudo virt-copy-in -d domain-name (e.g.redhat-server) /home/user/file /home/user
Copy a file from the guest /home directory into the /home directory of the host system ->sudo virt-copy-out -d domain-name (e.g.redhat-server) /home/user/file /home/user
Delete a file from the /home directory of the guest system ->sudo virt-customize -d domain-name (e.g.redhat-server) --delete /home/user/file
Edit the content of the /etc/fstab file of the guest system ->sudo virt-edit -d domain-name (e.g.redhat-server) /etc/fstab
Show the content of the /etc directory of the guest system ->sudo virt-ls -d domain-name (e.g.redhat-server) /etc
It is recommended to execute all of these virt-* commands when the virtual machine is not running !
Hope the information is useful for you, learn more about libguestfs-tools on the libguestfs.org website. :)
Regards,
Christian
Hi Douglas,
When the virtual machines are properly created and configured, the domains should be shown.
You have to execute virsh list --all with root privileges though - example and proof :
$ virsh list --all
Id Name State
----------------------------------------------------
$ sudo virsh list --all
Id Name State
----------------------------------------------------
- centos-server shut off
- fedora-server shut off
- redhat-beta-1 shut off
- redhat-beta-2 shut off
- redhat-server shut off
$ sudo virt-cat -d redhat-server /etc/fstab
#
# /etc/fstab
# Created by anaconda on Sat Aug 5 15:08:16 2017
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=33EE-B80C /boot/efi vfat umask=0077,shortname=winnt 0 0
UUID=8e897966-fa62-4558-89bd-3267563cc8bf swap swap defaults 0 0
UUID=dcb98465-2dd8-47b9-b456-30980cc3c088 / ext4 defaults 1 1
Regards,
Christian
Hi Douglas,
Unfortunately I have no idea why, both should be listed, the running and the shutoff ones - look here :
$ sudo virsh start redhat-server
Domain redhat-server started
$ sudo virsh list --all
Id Name State
----------------------------------------------------
2 redhat-server running
- centos-server shut off
- fedora-server shut off
- redhat-beta-1 shut off
- redhat-beta-2 shut off
The only reason I can imagine is, that your virtual machine is damaged or in 'unsafe' or unusable state.
Regards,
Christian
Probably not. I noticed that "virsh --readonly list --all" only displayed VM's that are running on the hypervisor on which the command is issued. Then I read https://access.redhat.com/discussions/672423
"When VDSM is managing a node libvirt is set to allow readonly mode (eg virsh --readonly list) any commands that require write access are locked down."
Is VDSM managing your VM's?
Hi Siem,
I checked the command you've provided and in my case the "powered off" virtual machines are listed :
$ sudo virsh --readonly list --all
Id Name State
----------------------------------------------------
- centos-server shut off
- fedora-server shut off
- redhat-beta-1 shut off
- redhat-beta-2 shut off
- redhat-server shut off
Regards,
Christian
Hi Douglas,
Yes - this is most probably the cause and might be the right explanation ... quote from Dan Yasny :
"Since RHEV hosts are managed by VDSM, that in turn uses some parts of the libvirt functionality, you should be using VDSM's command line tool, vdsClient. virsh will not be able to power a VM on anyway, because the hosts do not hold VM XML definitions."
Regards,
Christian
Hi Siem,
That is true - so I think there is something wrong with the configuration of the VM generally or with the domain name of the VM which Douglas is talking about. Means, when he cannot list or start this very VM, then he of course cannot access the VM with the libguestfs-tools. That's why I asked him if he can start any other VM. If he can't, it is more likely that the problem is the virtualization setup. :)
Regards,
Christian
Hi Douglas,
Thanks for clarification. As you told us in one of your responses above a few minutes ago, you are working with RHEV in this case and at home the virsh list --all command works fine. So, I suggest that you use a virtual machine guest on your host system at home to check out the libguestfs-tools there. :)
Regards,
Christian
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
