2021-07-26 10:39:47 +02:00
|
|
|
= Fedora Infrastructure Kpartx Notes
|
|
|
|
|
|
|
|
== How to mount virtual partitions
|
|
|
|
|
|
|
|
There can be multiple reasons you need to work with the contents of a
|
|
|
|
virtual machine without that machine running.
|
|
|
|
|
|
|
|
[arabic]
|
2021-09-10 16:06:32 +02:00
|
|
|
. You have decommisioned the system and found you need to get something
|
2021-07-26 10:39:47 +02:00
|
|
|
that was not backed up.
|
2021-09-10 16:06:32 +02:00
|
|
|
. The system is for some reason unbootable and you need to change some
|
2021-07-26 10:39:47 +02:00
|
|
|
file to make it work.
|
|
|
|
. Forensics work of some sort.
|
|
|
|
|
|
|
|
In the case of 1 and 2 the following commands and tools are invaluable.
|
|
|
|
In the case of 3, you should work with the Fedora Security Team and
|
|
|
|
follow their instructions completely.
|
|
|
|
|
|
|
|
== Steps to Work With Virtual System
|
|
|
|
|
|
|
|
[arabic]
|
|
|
|
. Find out what physical server the virtual machine image is on.
|
|
|
|
+
|
|
|
|
____
|
|
|
|
[upperalpha]
|
2025-07-04 11:55:02 +02:00
|
|
|
.. Log into _batcave01.rdu3.fedoraproject.org_
|
2021-09-10 16:06:32 +02:00
|
|
|
.. search for the hostname in the file `/var/log/virthost-lists.out`:
|
2021-07-26 10:39:47 +02:00
|
|
|
+
|
|
|
|
....
|
|
|
|
$ grep proxy01.phx2.fedoraproject.org /var/log/virthost-lists.out
|
|
|
|
virthost05.phx2.fedoraproject.org:proxy01.phx2.fedoraproject.org:running:1
|
|
|
|
....
|
|
|
|
.. If the image does not show up in the list then most likely it is an
|
|
|
|
image which has been decommissioned. You will need to search the virtual
|
|
|
|
hosts more directly:
|
|
|
|
+
|
|
|
|
....
|
|
|
|
# for i in `awk -F: '{print $1}' /var/log/virthost-lists.out |
|
|
|
|
sort -u`; do
|
|
|
|
ansible $i -m shell -a 'lvs | grep proxy01.phx2'
|
|
|
|
done
|
|
|
|
....
|
|
|
|
____
|
2021-09-10 16:06:32 +02:00
|
|
|
|
2021-07-26 10:39:47 +02:00
|
|
|
. Log into the virtual server and make sure the image is shutdown. Even
|
|
|
|
in cases where the system is not working correctly it may have still
|
|
|
|
have a running qemu on the physical server. It is best to confirm that
|
|
|
|
the box is dead.
|
|
|
|
+
|
2021-09-10 16:06:32 +02:00
|
|
|
....
|
2021-07-26 10:39:47 +02:00
|
|
|
# virsh destroy <hostname>
|
2021-09-10 16:06:32 +02:00
|
|
|
....
|
2021-07-26 10:39:47 +02:00
|
|
|
. We will be using the kpartx command to make the guest image ready for
|
|
|
|
mounting.
|
|
|
|
+
|
2021-09-10 16:06:32 +02:00
|
|
|
....
|
|
|
|
# lvs | grep <hostname>
|
|
|
|
# kpartx -l /dev/mapper/<volume>-<hostname>
|
|
|
|
# kpartx -a /dev/mapper/<volume>-<hostname>
|
|
|
|
# vgscan
|
|
|
|
# vgchange -ay /dev/mapper/<new volume-name>
|
|
|
|
# mount /dev/mapper/<partition we want> /mnt
|
|
|
|
....
|
2021-07-26 10:39:47 +02:00
|
|
|
. Edit the files as needed.
|
|
|
|
. Tear down the tree.
|
|
|
|
+
|
2021-09-10 16:06:32 +02:00
|
|
|
....
|
|
|
|
# umount /mnt
|
|
|
|
# vgchange -an <volume-name>
|
|
|
|
# vgscan
|
|
|
|
# kpartx -d /dev/mapper/<volume>-<hostname>
|
|
|
|
....
|