Re: [Libguestfs] libguestfs question - multiple partitions in the guest
On Wed, Aug 01, 2012 at 11:47:14AM -0500, Shawn Kennedy wrote:
Problem: When trying to inspect the guest using a command like 'virt-ls', we get back:
~]# virt-ls -d guest /path virt-ls: multi-boot operating systems are not supported by the -i option
What does virt-inspector2 [this is RHEL 6] display for this guest? virt-inspector2 -d guest virt-ls fundamentally doesn't work with multi-boot guests. However that doesn't mean to say you can't use libguestfs, you just need to use some lower level tools or write a Perl/Python/whatever script against the API. Have a look at the second example in the guestfs-perl(3) / guestfs-python(3) man pages to give you some ideas how to go about this. By the way it's probably better to use the RHEL 6.3 package, libguestfs 1.16.19, since it has more bugs fixed.
Question: We know it's because we have 2 filesystems in the guest and we have no problem using the '-m' option on the lower-level tools, but how do we know which filesystem is mounted?? A simple 'mount' command could tell us that, but how to run it if I don't know which -m mount point to use??
If I understand your question correctly, then the 'mountpoints' command lists what is mounted, eg: $ guestfish -c qemu:///system -d F16x64 -i --ro 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 Operating system: Fedora release 16 (Verne) /dev/mapper/vg_f16x64-lv_root mounted on / /dev/vda2 mounted on /boot
<fs> mountpoints /dev/vg_f16x64/lv_root: / /dev/vda2: /boot
(or 'mounts' which does the same but only lists the devices). Please send replies to the mailing list. I hopefully deleted any specifics of your environment in this reply. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into Xen guests. http://et.redhat.com/~rjones/virt-p2v
Hi Richard, Because I have 2 filesystems (one in a mounted LV and one in a unmounted LV), I get 2 sets of mountpoints in virt-inspector2 .... <mountpoints> <mountpoint dev="/dev/VG1/LV0001.root">/</mountpoint> <mountpoint dev="/dev/VG1/LV0001.var">/var</mountpoint> <mountpoint dev="/dev/VG1/LV0001.app1">/app1</mountpoint> <mountpoint dev="/dev/sda1">/boot</mountpoint> <mountpoint dev="/dev/VG1/home">/home</mountpoint> <mountpoint dev="/dev/VG1/logs">/logs</mountpoint> <mountpoint dev="/dev/VG1/cores">/cores</mountpoint> <mountpoint dev="/dev/VG1/storage">/storage</mountpoint> </mountpoints> <mountpoints> <mountpoint dev="/dev/VG1/LV0002.root">/</mountpoint> <mountpoint dev="/dev/VG1/LV0002.var">/var</mountpoint> <mountpoint dev="/dev/VG1/LV0002.app1">/app1</mountpoint> <mountpoint dev="/dev/sda1">/boot</mountpoint> <mountpoint dev="/dev/VG1/home">/home</mountpoint> <mountpoint dev="/dev/VG1/logs">/logs</mountpoint> <mountpoint dev="/dev/VG1/cores">/cores</mountpoint> <mountpoint dev="/dev/VG1/storage">/storage</mountpoint> </mountpoints> So, which one is the real one?? If I log into the guest directly, I know the /dev/VG1/LV0002* is the mounted partition (by using 'mount' command or by examining /etc/fstab). (from the guest) # mount | grep root /dev/mapper/VG1-LV0002.root on / type ext3 (rw) As much as I would like to, we cannot move the RHEL release to the next release. Project restrictions and all ... :-) Lastly, where is 'guestfish' installed on the system?? It's not installed on my system, even though I have installed the RHEL6.2 RPMs. # rpm -qa | grep libguest python-libguestfs-1.7.17-26.el6.x86_64 libguestfs-1.7.17-26.el6.x86_64 libguestfs-tools-c-1.7.17-26.el6.x86_64 libguestfs-mount-1.7.17-26.el6.x86_64 libguestfs-tools-1.7.17-26.el6.x86_64 # guestfish -bash: guestfish: command not found
-----Original Message----- From: Richard W.M. Jones [mailto:rjones@redhat.com] On Wed, Aug 01, 2012 at 11:47:14AM -0500, Shawn Kennedy wrote:
Problem: When trying to inspect the guest using a command like 'virt-ls', we get back:
~]# virt-ls -d guest /path virt-ls: multi-boot operating systems are not supported by the -i option
What does virt-inspector2 [this is RHEL 6] display for this guest?
virt-inspector2 -d guest
virt-ls fundamentally doesn't work with multi-boot guests. However that doesn't mean to say you can't use libguestfs, you just need to use some lower level tools or write a Perl/Python/whatever script against the API. Have a look at the second example in the guestfs-perl(3) / guestfs-python(3) man pages to give you some ideas how to go about this.
By the way it's probably better to use the RHEL 6.3 package, libguestfs 1.16.19, since it has more bugs fixed.
Question: We know it's because we have 2 filesystems in the guest and we have no problem using the '-m' option on the lower-level tools, but how do we know which filesystem is mounted?? A simple 'mount' command could tell us that, but how to run it if I don't know which -m mount point to use??
If I understand your question correctly, then the 'mountpoints' command lists what is mounted, eg:
$ guestfish -c qemu:///system -d F16x64 -i --ro
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
Operating system: Fedora release 16 (Verne) /dev/mapper/vg_f16x64-lv_root mounted on / /dev/vda2 mounted on /boot
<fs> mountpoints /dev/vg_f16x64/lv_root: / /dev/vda2: /boot
(or 'mounts' which does the same but only lists the devices).
On Wed, Aug 01, 2012 at 01:19:45PM -0500, Shawn Kennedy wrote:
Hi Richard,
Because I have 2 filesystems (one in a mounted LV and one in a unmounted LV), I get 2 sets of mountpoints in virt-inspector2 ....
<mountpoints> <mountpoint dev="/dev/VG1/LV0001.root">/</mountpoint> <mountpoint dev="/dev/VG1/LV0001.var">/var</mountpoint> <mountpoint dev="/dev/VG1/LV0001.app1">/app1</mountpoint> <mountpoint dev="/dev/sda1">/boot</mountpoint> <mountpoint dev="/dev/VG1/home">/home</mountpoint> <mountpoint dev="/dev/VG1/logs">/logs</mountpoint> <mountpoint dev="/dev/VG1/cores">/cores</mountpoint> <mountpoint dev="/dev/VG1/storage">/storage</mountpoint> </mountpoints>
<mountpoints> <mountpoint dev="/dev/VG1/LV0002.root">/</mountpoint> <mountpoint dev="/dev/VG1/LV0002.var">/var</mountpoint> <mountpoint dev="/dev/VG1/LV0002.app1">/app1</mountpoint> <mountpoint dev="/dev/sda1">/boot</mountpoint> <mountpoint dev="/dev/VG1/home">/home</mountpoint> <mountpoint dev="/dev/VG1/logs">/logs</mountpoint> <mountpoint dev="/dev/VG1/cores">/cores</mountpoint> <mountpoint dev="/dev/VG1/storage">/storage</mountpoint> </mountpoints>
virt-inspector is hopefully seeing two separate <operatingsystem>'s here.
So, which one is the real one?? If I log into the guest directly, I know the /dev/VG1/LV0002* is the mounted partition (by using 'mount' command or by examining /etc/fstab).
So I think what you're asking is, what root device is currently mounted in the running guest, when you're inspecting the guest from outside (hopefully read-only) using libguestfs. This isn't something that libguestfs can know since all it can see is what is in the disks, not the state of the running guest itself. But there are some heuristics you could use instead: (1) You could look at tell-tale signs to see which root device has most recently been mounted. Probably the simplest thing is to look at the date of /var/log/messages in each potential root, and choose the most recent one (since /var/log/messages is reliably and frequently updated when a guest boots and runs). (2) You could try doing what virt-v2v does, which is to parse the grub configuration to find out what root parameter is being passed to the kernel at boot time. I believe this is the code ... http://git.fedorahosted.org/git/?p=virt-v2v.git;a=blob;f=lib/Sys/VirtConvert...
(from the guest) # mount | grep root /dev/mapper/VG1-LV0002.root on / type ext3 (rw)
As much as I would like to, we cannot move the RHEL release to the next release. Project restrictions and all ... :-)
Lastly, where is 'guestfish' installed on the system?? It's not installed on my system, even though I have installed the RHEL6.2 RPMs.
# rpm -qa | grep libguest python-libguestfs-1.7.17-26.el6.x86_64 libguestfs-1.7.17-26.el6.x86_64 libguestfs-tools-c-1.7.17-26.el6.x86_64 libguestfs-mount-1.7.17-26.el6.x86_64 libguestfs-tools-1.7.17-26.el6.x86_64
# guestfish -bash: guestfish: command not found
That's odd. It should be in libguestfs-tools-c. Try: rpm -ql libguestfs-tools-c | grep guestfish and check that your $PATH is set correctly. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top
On Wed, Aug 01, 2012 at 08:54:01PM +0100, Richard W.M. Jones wrote:
(1) You could look at tell-tale signs to see which root device has most recently been mounted. Probably the simplest thing is to look at the date of /var/log/messages in each potential root, and choose the most recent one (since /var/log/messages is reliably and frequently updated when a guest boots and runs).
As in the attached program. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into Xen guests. http://et.redhat.com/~rjones/virt-p2v
On Wed, Aug 01, 2012 at 08:54:01PM +0100, Richard W.M. Jones wrote:
(1) You could look at tell-tale signs to see which root device has most recently been mounted. Probably the simplest thing is to look at the date of /var/log/messages in each potential root, and choose the most recent one (since /var/log/messages is reliably and frequently updated when a guest boots and runs).
As in the attached program.
Neat!! I just looked at it - very nice!! We will give it a try and report our findings! If it does work, we will have to convert it to Python (preferred). Thanks! Shawn
-----Original Message----- From: libguestfs-bounces@redhat.com [mailto:libguestfs-bounces@redhat.com] On Behalf Of Shawn Kennedy Sent: Wednesday, August 01, 2012 3:34 PM To: libguestfs@redhat.com Cc: 'Smudde, Mark Alan (Mark)'; 'Tockstein, James E (Jim)' Subject: Re: [Libguestfs] libguestfs question - multiple partitions in the guest
On Wed, Aug 01, 2012 at 08:54:01PM +0100, Richard W.M. Jones wrote:
(1) You could look at tell-tale signs to see which root device has most recently been mounted. Probably the simplest thing is to look at the date of /var/log/messages in each potential root, and choose the most recent one (since /var/log/messages is reliably and frequently updated when a guest boots and runs).
As in the attached program.
Neat!! I just looked at it - very nice!! We will give it a try and report our findings! If it does work, we will have to convert it to Python (preferred).
Success!! # ./mostrecent.pl /storage/images/guest.img Youngest root filesystem is: /dev/VG1/LV0002.root With that knowledge, we can then mount (ro) the right mount point and inspect further! Thank you again! Shawn
Hi Rich, Let's handle the easy one first: # rpm -qa | grep libguestfs-tools-c libguestfs-tools-c-1.7.17-26.el6.x86_64 # rpm -ql libguestfs-tools-c /usr/bin/virt-cat /usr/bin/virt-df /usr/bin/virt-filesystems /usr/bin/virt-inspector2 /usr/bin/virt-ls /usr/bin/virt-rescue /usr/share/man/man1/virt-cat.1.gz /usr/share/man/man1/virt-df.1.gz /usr/share/man/man1/virt-filesystems.1.gz /usr/share/man/man1/virt-inspector2.1.gz /usr/share/man/man1/virt-ls.1.gz /usr/share/man/man1/virt-rescue.1.gz It's not in that package according to my distro (RHEL6.2). Thanks, Shawn
-----Original Message----- From: Richard W.M. Jones [mailto:rjones@redhat.com] Sent: Wednesday, August 01, 2012 2:54 PM To: Shawn Kennedy Cc: libguestfs@redhat.com; 'Smudde, Mark Alan (Mark)'; 'Tockstein, James E (Jim)' Subject: Re: [Libguestfs] libguestfs question - multiple partitions in the guest
On Wed, Aug 01, 2012 at 01:19:45PM -0500, Shawn Kennedy wrote:
Lastly, where is 'guestfish' installed on the system?? It's not installed on my system, even though I have installed the RHEL6.2 RPMs.
# rpm -qa | grep libguest python-libguestfs-1.7.17-26.el6.x86_64 libguestfs-1.7.17-26.el6.x86_64 libguestfs-tools-c-1.7.17-26.el6.x86_64 libguestfs-mount-1.7.17-26.el6.x86_64 libguestfs-tools-1.7.17-26.el6.x86_64
# guestfish -bash: guestfish: command not found
That's odd. It should be in libguestfs-tools-c. Try:
rpm -ql libguestfs-tools-c | grep guestfish
and check that your $PATH is set correctly.
On Wed, Aug 01, 2012 at 03:23:24PM -0500, Shawn Kennedy wrote:
Hi Rich,
Let's handle the easy one first:
# rpm -qa | grep libguestfs-tools-c libguestfs-tools-c-1.7.17-26.el6.x86_64
# rpm -ql libguestfs-tools-c /usr/bin/virt-cat /usr/bin/virt-df /usr/bin/virt-filesystems /usr/bin/virt-inspector2 /usr/bin/virt-ls /usr/bin/virt-rescue /usr/share/man/man1/virt-cat.1.gz /usr/share/man/man1/virt-df.1.gz /usr/share/man/man1/virt-filesystems.1.gz /usr/share/man/man1/virt-inspector2.1.gz /usr/share/man/man1/virt-ls.1.gz /usr/share/man/man1/virt-rescue.1.gz
It's not in that package according to my distro (RHEL6.2).
Sorry .. it's RHEL 6.2 so the package is called 'guestfish'. # yum install guestfish Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones New in Fedora 11: Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 70 libraries supprt'd http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
-----Original Message----- From: Richard W.M. Jones [mailto:rjones@redhat.com] Sent: Wednesday, August 01, 2012 3:53 PM To: Shawn Kennedy Cc: libguestfs@redhat.com; 'Smudde, Mark Alan (Mark)'; 'Tockstein, James E (Jim)' Subject: Re: [Libguestfs] libguestfs question - multiple partitions in the guest
On Wed, Aug 01, 2012 at 03:23:24PM -0500, Shawn Kennedy wrote:
Hi Rich,
Let's handle the easy one first:
# rpm -qa | grep libguestfs-tools-c libguestfs-tools-c-1.7.17-26.el6.x86_64
# rpm -ql libguestfs-tools-c /usr/bin/virt-cat /usr/bin/virt-df /usr/bin/virt-filesystems /usr/bin/virt-inspector2 /usr/bin/virt-ls /usr/bin/virt-rescue /usr/share/man/man1/virt-cat.1.gz /usr/share/man/man1/virt-df.1.gz /usr/share/man/man1/virt-filesystems.1.gz /usr/share/man/man1/virt-inspector2.1.gz /usr/share/man/man1/virt-ls.1.gz /usr/share/man/man1/virt-rescue.1.gz
It's not in that package according to my distro (RHEL6.2).
Sorry .. it's RHEL 6.2 so the package is called 'guestfish'.
# yum install guestfish
Ah nuts! Looks like I missed a package when I pulled everything together!! Thanks, I will add accordingly! Shawn
-----Original Message----- From: Richard W.M. Jones [mailto:rjones@redhat.com] Sent: Wednesday, August 01, 2012 2:54 PM To: Shawn Kennedy Cc: libguestfs@redhat.com; 'Smudde, Mark Alan (Mark)'; 'Tockstein, James E (Jim)' Subject: Re: [Libguestfs] libguestfs question - multiple partitions in the guest
On Wed, Aug 01, 2012 at 01:19:45PM -0500, Shawn Kennedy wrote:
Hi Richard,
Because I have 2 filesystems (one in a mounted LV and one in a unmounted LV), I get 2 sets of mountpoints in virt-inspector2 ....
<mountpoints> <mountpoint dev="/dev/VG1/LV0001.root">/</mountpoint> <mountpoint dev="/dev/VG1/LV0001.var">/var</mountpoint> <mountpoint dev="/dev/VG1/LV0001.app1">/app1</mountpoint> <mountpoint dev="/dev/sda1">/boot</mountpoint> <mountpoint dev="/dev/VG1/home">/home</mountpoint> <mountpoint dev="/dev/VG1/logs">/logs</mountpoint> <mountpoint dev="/dev/VG1/cores">/cores</mountpoint> <mountpoint dev="/dev/VG1/storage">/storage</mountpoint> </mountpoints>
<mountpoints> <mountpoint dev="/dev/VG1/LV0002.root">/</mountpoint> <mountpoint dev="/dev/VG1/LV0002.var">/var</mountpoint> <mountpoint dev="/dev/VG1/LV0002.app1">/app1</mountpoint> <mountpoint dev="/dev/sda1">/boot</mountpoint> <mountpoint dev="/dev/VG1/home">/home</mountpoint> <mountpoint dev="/dev/VG1/logs">/logs</mountpoint> <mountpoint dev="/dev/VG1/cores">/cores</mountpoint> <mountpoint dev="/dev/VG1/storage">/storage</mountpoint> </mountpoints>
virt-inspector is hopefully seeing two separate <operatingsystem>'s here.
Hi Rich, It is. I took the liberty of snipping the output quite a bit. I can send more, but I don't think that's worth the effort knowing it does see two OSs.
So, which one is the real one?? If I log into the guest directly, I know the /dev/VG1/LV0002* is the mounted partition (by using 'mount' command or by examining /etc/fstab).
So I think what you're asking is, what root device is currently mounted in the running guest, when you're inspecting the guest from outside (hopefully read-only) using libguestfs.
Oh yes - Read only, especially since it's a live running guest! :-)
This isn't something that libguestfs can know since all it can see is what is in the disks, not the state of the running guest itself. But there are some heuristics you could use instead:
(1) You could look at tell-tale signs to see which root device has most recently been mounted. Probably the simplest thing is to look at the date of /var/log/messages in each potential root, and choose the most recent one (since /var/log/messages is reliably and frequently updated when a guest boots and runs).
That's a good idea - inspecting deeper into the guests' LV to see which one is live by looking for data that could tell you that. /var/log/messages is one way to know (timestamp of the file).
(2) You could try doing what virt-v2v does, which is to parse the grub configuration to find out what root parameter is being passed to the kernel at boot time. I believe this is the code ...
http://git.fedorahosted.org/git/?p=virt- v2v.git;a=blob;f=lib/Sys/VirtConvert/Converter/RedHat.pm;h=6bda68bffad6fc959dbadadee89447df71245491;hb=H EAD#l549
We will look into seeing what this is doing. looking at the grub config will be the most correct way. I wonder - maybe an new tool (virt-grub) to dump out the grub content of the guest image (if linux)!! :-) :-) :-) As always, Thanks! Shawn
-----Original Message----- From: libguestfs-bounces@redhat.com [mailto:libguestfs-bounces@redhat.com] On Behalf Of Shawn Kennedy
From: Richard W.M. Jones [mailto:rjones@redhat.com] (2) You could try doing what virt-v2v does, which is to parse the grub configuration to find out what root parameter is being passed to the kernel at boot time. I believe this is the code ...
v2v.git;a=blob;f=lib/Sys/VirtConvert/Converter/RedHat.pm;h=6bda68bffad6fc959dbadadee89447df71245491;hb=H
EAD#l549
We will look into seeing what this is doing. looking at the grub config will be the most correct way.
That URL doesn't work. Do you have a working link?? Thanks! Shawn
On Wed, Aug 01, 2012 at 04:02:27PM -0500, Shawn Kennedy wrote:
-----Original Message----- From: libguestfs-bounces@redhat.com [mailto:libguestfs-bounces@redhat.com] On Behalf Of Shawn Kennedy
From: Richard W.M. Jones [mailto:rjones@redhat.com] (2) You could try doing what virt-v2v does, which is to parse the grub configuration to find out what root parameter is being passed to the kernel at boot time. I believe this is the code ...
v2v.git;a=blob;f=lib/Sys/VirtConvert/Converter/RedHat.pm;h=6bda68bffad6fc959dbadadee89447df71245491;hb=H
EAD#l549
We will look into seeing what this is doing. looking at the grub config will be the most correct way.
That URL doesn't work. Do you have a working link??
That's strange, did fedorahosted just switch from gitweb to cgit? http://git.fedorahosted.org/cgit/virt-v2v.git/tree/lib/Sys/VirtConvert/Conve... or: http://bit.ly/Mk4XAg Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming blog: http://rwmj.wordpress.com Fedora now supports 80 OCaml packages (the OPEN alternative to F#) http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora
-----Original Message----- From: Richard W.M. Jones [mailto:rjones@redhat.com] On Wed, Aug 01, 2012 at 04:02:27PM -0500, Shawn Kennedy wrote:
-----Original Message----- From: libguestfs-bounces@redhat.com [mailto:libguestfs-bounces@redhat.com] On Behalf Of Shawn Kennedy
From: Richard W.M. Jones [mailto:rjones@redhat.com] (2) You could try doing what virt-v2v does, which is to parse the grub configuration to find out what root parameter is being passed to the kernel at boot time. I believe this is the code ...
v2v.git;a=blob;f=lib/Sys/VirtConvert/Converter/RedHat.pm;h=6bda68bffad6fc959dbadadee89447df71245491;hb=H
EAD#l549
We will look into seeing what this is doing. looking at the grub config will be the most correct way.
That URL doesn't work. Do you have a working link??
That's strange, did fedorahosted just switch from gitweb to cgit?
http://git.fedorahosted.org/cgit/virt-v2v.git/tree/lib/Sys/VirtConvert/Conve...
Success! I can view it now. Thanks! Shawn
On Wed, Aug 01, 2012 at 03:31:19PM -0500, Shawn Kennedy wrote:
I wonder - maybe an new tool (virt-grub) to dump out the grub content of the guest image (if linux)!! :-) :-) :-)
It's actually pretty simple to script this. See attached (requires a grub1 guest). Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into Xen guests. http://et.redhat.com/~rjones/virt-p2v
-----Original Message----- From: Richard W.M. Jones [mailto:rjones@redhat.com] Sent: Wednesday, August 01, 2012 4:22 PM To: Shawn Kennedy Cc: libguestfs@redhat.com; 'Smudde, Mark Alan (Mark)'; 'Tockstein, James E (Jim)' Subject: Re: [Libguestfs] libguestfs question - multiple partitions in the guest
On Wed, Aug 01, 2012 at 03:31:19PM -0500, Shawn Kennedy wrote:
I wonder - maybe an new tool (virt-grub) to dump out the grub content of the guest image (if linux)!! :-) :-) :-)
It's actually pretty simple to script this. See attached (requires a grub1 guest).
Luckily, we still are grub1 ..... # grub --version grub (GNU GRUB 0.97) So I ran it and it tells me I have 2 OSs ... root: /dev/VG1/LV0001.root root: /dev/VG1/LV0002.root I thought it might dump the running grub, but then again, it doesn't know what "running" is it looks like using /var/log/messages file to determine what is (likely) mounted in the guest. Thanks! Shawn
virt-filesystems -d guest | grep root gave me that same output On 8/1/2012 5:02 PM, Shawn Kennedy wrote:
-----Original Message----- From: Richard W.M. Jones [mailto:rjones@redhat.com] Sent: Wednesday, August 01, 2012 4:22 PM To: Shawn Kennedy Cc: libguestfs@redhat.com; 'Smudde, Mark Alan (Mark)'; 'Tockstein, James E (Jim)' Subject: Re: [Libguestfs] libguestfs question - multiple partitions in the guest
On Wed, Aug 01, 2012 at 03:31:19PM -0500, Shawn Kennedy wrote:
I wonder - maybe an new tool (virt-grub) to dump out the grub content of the guest image (if linux)!! :-) :-) :-)
It's actually pretty simple to script this. See attached (requires a grub1 guest).
Luckily, we still are grub1 .....
# grub --version grub (GNU GRUB 0.97)
So I ran it and it tells me I have 2 OSs ...
root: /dev/VG1/LV0001.root root: /dev/VG1/LV0002.root
I thought it might dump the running grub, but then again, it doesn't know what "running" is it looks like using /var/log/messages file to determine what is (likely) mounted in the guest.
Thanks! Shawn
On Wed, Aug 01, 2012 at 05:02:28PM -0500, Shawn Kennedy wrote:
-----Original Message----- From: Richard W.M. Jones [mailto:rjones@redhat.com] Sent: Wednesday, August 01, 2012 4:22 PM To: Shawn Kennedy Cc: libguestfs@redhat.com; 'Smudde, Mark Alan (Mark)'; 'Tockstein, James E (Jim)' Subject: Re: [Libguestfs] libguestfs question - multiple partitions in the guest
On Wed, Aug 01, 2012 at 03:31:19PM -0500, Shawn Kennedy wrote:
I wonder - maybe an new tool (virt-grub) to dump out the grub content of the guest image (if linux)!! :-) :-) :-)
It's actually pretty simple to script this. See attached (requires a grub1 guest).
Luckily, we still are grub1 .....
# grub --version grub (GNU GRUB 0.97)
So I ran it and it tells me I have 2 OSs ...
root: /dev/VG1/LV0001.root root: /dev/VG1/LV0002.root
I thought it might dump the running grub, [...]
I thought it would do too. One problem with Augeas is that it relies on the exact location of the configuration file. You can try changing: display ("/files/etc/grub.conf") to: display ("/files") and see if the grub config shows up anywhere in the (likely to be huge) output. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming blog: http://rwmj.wordpress.com Fedora now supports 80 OCaml packages (the OPEN alternative to F#) http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora
-----Original Message----- From: Richard W.M. Jones [mailto:rjones@redhat.com] Sent: Wednesday, August 01, 2012 5:09 PM To: Shawn Kennedy Cc: libguestfs@redhat.com; 'Smudde, Mark Alan (Mark)'; 'Tockstein, James E (Jim)' Subject: Re: [Libguestfs] libguestfs question - multiple partitions in the guest
On Wed, Aug 01, 2012 at 05:02:28PM -0500, Shawn Kennedy wrote:
-----Original Message----- From: Richard W.M. Jones [mailto:rjones@redhat.com] Sent: Wednesday, August 01, 2012 4:22 PM To: Shawn Kennedy Cc: libguestfs@redhat.com; 'Smudde, Mark Alan (Mark)'; 'Tockstein, James E (Jim)' Subject: Re: [Libguestfs] libguestfs question - multiple partitions in the guest
On Wed, Aug 01, 2012 at 03:31:19PM -0500, Shawn Kennedy wrote:
I wonder - maybe an new tool (virt-grub) to dump out the grub content of the guest image (if linux)!! :-) :-) :-)
It's actually pretty simple to script this. See attached (requires a grub1 guest).
Luckily, we still are grub1 .....
# grub --version grub (GNU GRUB 0.97)
So I ran it and it tells me I have 2 OSs ...
root: /dev/VG1/LV0001.root root: /dev/VG1/LV0002.root
I thought it might dump the running grub, [...]
I thought it would do too. One problem with Augeas is that it relies on the exact location of the configuration file.
You can try changing:
display ("/files/etc/grub.conf")
to:
display ("/files")
and see if the grub config shows up anywhere in the (likely to be huge) output.
You are right /files is a very big list and after 10+ minutes of running, it wasn't done. I narrowed it down (/files/boot) to see if I could find the files in /boot (after all, /boot/grub/grub.com is where it really is) and alas, it doesn't find it, just found this: root: /dev/VG1/LV0001.root /files/boot/grub/device.map/hd0 /dev/vda root: /dev/VG1/LV0002.root /files/boot/grub/device.map/hd0 /dev/vda Thanks, Shawn
On Wed, Aug 01, 2012 at 05:36:12PM -0500, Shawn Kennedy wrote:
You are right /files is a very big list and after 10+ minutes of running, it wasn't done. I narrowed it down (/files/boot) to see if I could find the files in /boot (after all, /boot/grub/grub.com is where it really is) and alas, it doesn't find it, just found this:
root: /dev/VG1/LV0001.root /files/boot/grub/device.map/hd0 /dev/vda root: /dev/VG1/LV0002.root /files/boot/grub/device.map/hd0 /dev/vda
Augeas isn't required. You can just download and parse the grub configuration yourself if you know where it is located, ie: lines = g.read_lines ("/boot/grub/grub.conf") for line in lines: <your parser here> Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top
participants (3)
-
Jim Tockstein -
Richard W.M. Jones -
Shawn Kennedy