Problem:
In RedHat, how do you mount a KVM image with an LVM partition? Some of the files in the image, like "/etc/sysconfig/ifcfg-eth0" & "/etc/sysconfig/network" need to be edited before use.
Solution:
From the KVM host, use a combination of "kpartx" & "lvchange" command line tools.
Procedure:
1. Install kpartx rpm through yum.
yum install kpartx
2. Install lvm2 rpm through yum.
yum install lvm2
3. Use "kpartx" to read partition tables & create device maps of your image.
kpartx -av <image path>.img
Example:
[root@test1-server ~]# kpartx -av /home/images/test1.img
add map loop0p1 (253:6): 0 1024000 linear /dev/loop0 2048
add map loop0p2 (253:7): 0 30428928 linear /dev/loop0 1026048
4. Use "pvscan" to see your LVM block devices for physical volume.
Example:
[root@test1-server ~]# pvscan
PV /dev/mapper/loop0p2 VG vg_or2svmqawmgr1 lvm2 [14.51 GiB / 0 free]
5. Use "vgscan" to see your LVM physical volumes & volume groups.
Example:
[root@test1-server ~]# vgscan
Reading all physical volumes. This may take a while...
Found volume group "vg_test1" using metadata type lvm2
6. Use "lvscan" to see your LVM block devices for logical volumes.
Example:
[root@test1-server ~]# lvscan
inactive '/dev/vg_test1/lv_root' [10.75 GiB] inherit
inactive '/dev/vg_test1/lv_swap' [3.75 GiB] inherit
7. Use "lvchange" to activate the logical volume, to make it useable.
lvchange -ay <volume group name>
Example:
[root@or14svm-rsvr3 vm_xml_files]# lvchange -ay vg_test1
[root@test1-server ~]# lvscan
ACTIVE '/dev/vg_test1/lv_root' [10.75 GiB] inherit
ACTIVE '/dev/vg_test1/lv_swap' [3.75 GiB] inherit
8. Create the directory for mounting the logical volume, then mount it, and start editing your files.
Example:
mkdir /mnt/partition
mount /dev/vg_test1/lv_root /mnt/partition
cd /mnt/partition
ls
Reverse Procedure:
1. Unmount the logical volume.
Example:
cd $HOME
umount /mnt/partition
2. Use "lvchange" to deactivate the logical volume.
lvchange -an <volume group name>
Example:
[root@or14svm-rsvr3 vm_xml_files]# lvchange -an vg_test1
[root@test1-server ~]# lvscan
inactive '/dev/vg_test1/lv_root' [10.75 GiB] inherit
inactive '/dev/vg_test1/lv_swap' [3.75 GiB] inherit
3. Use "vgchange" to deactivate the volume group.
lvchange -an <volume group name>
Example:
[root@test1-server ~]# vgchange -an vg_test1
0 logical volume(s) in volume group "vg_test1" now active
4. Use "kpartx" to delete device maps of your image.
kpartx -dv <image path>.img
Example:
[root@test1-server ~]# kpartx -dv /home/images/test1.img
del devmap : loop0p2
del devmap : loop0p1
loop deleted : /dev/loop0
Reference:
http://support.citrix.com/article/CTX117791/
Fix My OS
Monday, August 6, 2012
Friday, February 10, 2012
Finding out the KVM client IP address, without running virt-manager
Problem:
In RedHat, how do you find out the IP address of KVM client from the hypervisor it's running on, without starting virt-manager?
Solution:
From the kvm host or hypervisor, use "virsh dumpxml [servername]" to get the kvm client MAC address & the network interface its using. Then use "arp" or "tcpdump" to get its IP address.
Procedure:
1. Login to the kvm host/hypervisor and issue the command: virsh dumpxml [server name].
Example: virsh dumpxml test1-server
2. From the xml output, look for the MAC address & interface entry, which looks something like this:
3. Use "arp -a" to query for the IP address.
[testuser@test1-server ~]$ arp -a
test-client1.apollo.com (192.168.1.120) at 63:54:00:3f:46:5a [ether] on br0
test-client2.apollo.com (192.168.1.125) at 63:54:00:bb:e7:90 [ether] on br0
test-client3.apollo.com (192.168.1.9) at 01:25:45:b3:6d:84 [ether] on br0
4. If "arp -a" does not match the xml MAC address you're looking for, use the old reliable "tcpdump".
[testuser@test1-server ~]$ sudo tcpdump -vv -i br0 | grep 63:54:00:49:f4:87
tcpdump: listening on br0, link-type EN10MB (Ethernet), capture size 65535 bytes
12:31:08.887230 ARP, Ethernet (len 6), IPv4 (len 4), Reply 192.168.1.118 is-at 63:54:00:49:f4:87 (oui Unknown), length 28
12:32:08.000218 ARP, Ethernet (len 6), IPv4 (len 4), Reply 192.168.1.118 is-at 63:54:00:49:f4:87 (oui Unknown), length 28
12:32:32.121785 ARP, Ethernet (len 6), IPv4 (len 4), Reply 192.168.1.118 is-at 63:54:00:49:f4:87 (oui Unknown), length 28
Reference:
http://rwmj.wordpress.com/2010/10/26/tip-find-the-ip-address-of-a-virtual-machine/
In RedHat, how do you find out the IP address of KVM client from the hypervisor it's running on, without starting virt-manager?
Solution:
From the kvm host or hypervisor, use "virsh dumpxml [servername]" to get the kvm client MAC address & the network interface its using. Then use "arp" or "tcpdump" to get its IP address.
Procedure:
1. Login to the kvm host/hypervisor and issue the command: virsh dumpxml [server name].
Example: virsh dumpxml test1-server
2. From the xml output, look for the MAC address & interface entry, which looks something like this:
3. Use "arp -a" to query for the IP address.
[testuser@test1-server ~]$ arp -a
test-client1.apollo.com (192.168.1.120) at 63:54:00:3f:46:5a [ether] on br0
test-client2.apollo.com (192.168.1.125) at 63:54:00:bb:e7:90 [ether] on br0
test-client3.apollo.com (192.168.1.9) at 01:25:45:b3:6d:84 [ether] on br0
4. If "arp -a" does not match the xml MAC address you're looking for, use the old reliable "tcpdump".
[testuser@test1-server ~]$ sudo tcpdump -vv -i br0 | grep 63:54:00:49:f4:87
tcpdump: listening on br0, link-type EN10MB (Ethernet), capture size 65535 bytes
12:31:08.887230 ARP, Ethernet (len 6), IPv4 (len 4), Reply 192.168.1.118 is-at 63:54:00:49:f4:87 (oui Unknown), length 28
12:32:08.000218 ARP, Ethernet (len 6), IPv4 (len 4), Reply 192.168.1.118 is-at 63:54:00:49:f4:87 (oui Unknown), length 28
12:32:32.121785 ARP, Ethernet (len 6), IPv4 (len 4), Reply 192.168.1.118 is-at 63:54:00:49:f4:87 (oui Unknown), length 28
Reference:
http://rwmj.wordpress.com/2010/10/26/tip-find-the-ip-address-of-a-virtual-machine/
Wednesday, October 26, 2011
Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
Problem:
X windows does not start on runlevel 5.
In RedHat RHEL 6.1, you get this message in system log (in /var/log/messages, by default):
Oct 26 15:41:15 testserver1 kernel: readahead-collector: sorting
Oct 26 15:41:15 testserver1 kernel: readahead-collector: finished
Oct 26 15:54:05 testserver1 abrtd: Error requesting DBus name com.redhat.abrt, possible reasons: abrt run by non-root; dbus config is incorrect; or dbus daemon needs to be restarted to reload dbus config
Oct 26 15:54:06 testserver1 init: start-ttys main process (4086) terminated with status 1
Oct 26 15:55:20 testserver1 ck-xinit-session: error connecting to console-kit
Oct 26 15:55:21 testserver1 gnome-session[4164]: devkit-power-gobject-WARNING: Couldn't connect to system bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
Oct 26 15:55:21 testserver1 gnome-session[4164]: WARNING: Could not connect to ConsoleKit: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
Oct 26 15:55:21 testserver1 gnome-session[4164]: WARNING: Could not connect to ConsoleKit: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
Oct 26 15:55:22 testserver1 kernel: fuse init (API version 7.13)
Oct 26 15:55:22 testserver1 pulseaudio[4213]: core-util.c: Failed to connect to system bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
Oct 26 15:55:22 testserver1 pulseaudio[4213]: core-util.c: Failed to connect to system bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
Solution:
Check if messagebus service is turned on:
chkconfig --list messagebus
If messagebus is turned off, turn it on:
chkconfig messagebus on
Now it should look something like this:
chkconfig --list messagebus
messagebus 0:off 1:off 2:on 3:on 4:on 5:on 6:off
Then just reboot your server:
shutdown -r now
Reference:
http://fixunix.com/mandriva/397862-dbus-error.html
X windows does not start on runlevel 5.
In RedHat RHEL 6.1, you get this message in system log (in /var/log/messages, by default):
Oct 26 15:41:15 testserver1 kernel: readahead-collector: sorting
Oct 26 15:41:15 testserver1 kernel: readahead-collector: finished
Oct 26 15:54:05 testserver1 abrtd: Error requesting DBus name com.redhat.abrt, possible reasons: abrt run by non-root; dbus config is incorrect; or dbus daemon needs to be restarted to reload dbus config
Oct 26 15:54:06 testserver1 init: start-ttys main process (4086) terminated with status 1
Oct 26 15:55:20 testserver1 ck-xinit-session: error connecting to console-kit
Oct 26 15:55:21 testserver1 gnome-session[4164]: devkit-power-gobject-WARNING: Couldn't connect to system bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
Oct 26 15:55:21 testserver1 gnome-session[4164]: WARNING: Could not connect to ConsoleKit: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
Oct 26 15:55:21 testserver1 gnome-session[4164]: WARNING: Could not connect to ConsoleKit: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
Oct 26 15:55:22 testserver1 kernel: fuse init (API version 7.13)
Oct 26 15:55:22 testserver1 pulseaudio[4213]: core-util.c: Failed to connect to system bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
Oct 26 15:55:22 testserver1 pulseaudio[4213]: core-util.c: Failed to connect to system bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
Solution:
Check if messagebus service is turned on:
chkconfig --list messagebus
If messagebus is turned off, turn it on:
chkconfig messagebus on
Now it should look something like this:
chkconfig --list messagebus
messagebus 0:off 1:off 2:on 3:on 4:on 5:on 6:off
Then just reboot your server:
shutdown -r now
Reference:
http://fixunix.com/mandriva/397862-dbus-error.html
Tuesday, October 18, 2011
Warning: RPMDB altered outside of yum
Problem:
On RedHat you get this message:
Warning: RPMDB altered outside of yum.
Example:
[root@test ~]# yum install screen
Loaded plugins: product-id, refresh-packagekit, rhnplugin, subscription-manager
Updating Red Hat repositories.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package screen.x86_64 0:4.0.3-16.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
screen x86_64 4.0.3-16.el6 rhel-x86_64-server-6 494 k
Transaction Summary
================================================================================
Install 1 Package(s)
Total download size: 494 k
Installed size: 0
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
Installing : screen-4.0.3-16.el6.x86_64 1/1
duration: 182(ms)
Installed products updated.
Installed:
screen.x86_64 0:4.0.3-16.el6
Complete!
Solution:
Run "yum clean all"
On RedHat you get this message:
Warning: RPMDB altered outside of yum.
Example:
[root@test ~]# yum install screen
Loaded plugins: product-id, refresh-packagekit, rhnplugin, subscription-manager
Updating Red Hat repositories.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package screen.x86_64 0:4.0.3-16.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
screen x86_64 4.0.3-16.el6 rhel-x86_64-server-6 494 k
Transaction Summary
================================================================================
Install 1 Package(s)
Total download size: 494 k
Installed size: 0
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
Installing : screen-4.0.3-16.el6.x86_64 1/1
duration: 182(ms)
Installed products updated.
Installed:
screen.x86_64 0:4.0.3-16.el6
Complete!
Solution:
Run "yum clean all"
Subscribe to:
Posts (Atom)