[Libguestfs] libguestfs question - multiple partitions in the guest
Shawn Kennedy
Shawn.Kennedy at alcatel-lucent.com
Wed Aug 1 20:31:19 UTC 2012
> -----Original Message-----
> From: Richard W.M. Jones [mailto:rjones at redhat.com]
> Sent: Wednesday, August 01, 2012 2:54 PM
> To: Shawn Kennedy
> Cc: libguestfs at 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
More information about the Libguestfs
mailing list