Installation guide

Warning
Guests must be offline before their files can be read. Editing or reading files of an active guest
is not possible and may cause data loss or damage.
Pro ced u re 33.1. Accessin g g u est imag e d at a
1. Install the kpartx package.
# yum install kpartx
2. Use kpartx to list partition device mappings attached to a file-based storage image. This
example uses a image file named guest1.img.
# kpartx -l /var/lib/libvirt/images/guest1.img
loop0p1 : 0 409600 /dev/loop0 63
loop0p2 : 0 10064717 /dev/loop0 409663
guest1 is a Linux guest. The first partition is the boot partition and the second partition is an
EXT3 containing the root partition.
3. Add the partition mappings to the recognized devices in /dev/mapper/.
# kpartx -a /var/lib/libvirt/images/guest1.img
a. Test that the partition mapping worked. There should be new devices in the
/dev/mapper/ directory
# ls /dev/mapper/
loop0p1
loop0p2
The mappings for the image are named in the format loopXpY.
4. Mount the loop device which to a directory. If required, create the directory. This example uses
/mnt/guest1 for mounting the partition.
# mkdir /mnt/guest1
# mount /dev/mapper/loop0p1 /mnt/guest1 -o loop,ro
5. The files are now available for reading in the /mnt/guest1 directory. Read or copy the files.
6. Unmount the device so the guest image can be reused by the guest. If the device is mounted
the guest cannot access the image and therefore cannot start.
# umount /mnt/tmp
7. Disconnect the image file from the partition mappings.
# kpartx -d /var/lib/libvirt/images/guest1.img
The guest can now be started again.
Accessin g d at a f ro m g u est LVM volu mes
Red Hat En t erp rise Lin ux 5 Virt ualizat ion Guid e
316