Pokazywanie postów oznaczonych etykietą kvm. Pokaż wszystkie posty
Pokazywanie postów oznaczonych etykietą kvm. Pokaż wszystkie posty

czwartek, 15 listopada 2012

KVM windows guest on Ubuntu 12.10 - no sound

Recently I faced a problem that I could play sound from the KVM windows based guest machine (even though the virtual sound card AC'97 was properly detected and installed). I went through several article recommending to change the type of the card, configure qemu.conf to grant access to the audio. Unfortunately none of these really helped. Then after doing all the previously described things I tried disabling the apparmor and... Now it works...

Below I enclose more detailed procedure on what was needed in my case to make the audio from the guest kvm machine working.

1. Change the type of the card (might not be necessary). In my case the es1370 was chosen

2. Configure qemu.conf - please ensure that the following entries are present in the qemu.conf configuration file. The username and groupname shall be adapted to your system configuration


#  vim /etc/libvirt/qemu.conf 
...

#
vnc_allow_host_audio = 1
...
# The user ID for QEMU processes run by the system instance.
user = "krychu"

# The group ID for QEMU processes run by the system instance.
group = "krychu"
...


3. Disable apparmor. Disabling armor really made the sound working on my box. Actually I completely removed the apparmor from my system (I think it is not necessary, you might try only disabling it).

First I stopped the service:
#  service apparmor stop

Next I removed it from the startup scripts
#  update-rc.d -f apparmor remove

Since I do not use apparmor at the moment I eventually decided to remove it completely (if it happens that you installed apparmor-utils as well you should remove it as well)
#  apt-get remove apparmor apparmor-utils 


Reboot...

sobota, 12 listopada 2011

Resizing root filesystem: KVM, LVM and EXT4

Ever faced a problem that you run out of the root filesystem space? I recently faced that problem on my KVM CentOS 6.0 box (a lot of experiments done on it) and wanted to solve it without reinstallation of the system. It seems to be possible without losing any data and not that difficult on all levels:

  • KVM virtual disk size
  • LVM volume group size
  • EXT4 filesystem size
Below you can find the instruction on how to do that:


1. Resize the KVM virtio disk image. First one need to resize the virtual disk for the KVM. In order to do that you shoudl create a new add on raw disk and append it to the existing disk image. I recommend to first move the original disk for the backup purposes. The steps to be done are shown below:


root@krystianek:/var/lib/libvirt/images# qemu-img create -f raw addon.raw 4G
Formatting 'addon.raw', fmt=raw size=4294967296


root@krystianek:/var/lib/libvirt/images# mv centos6.img centos6.img.backup
root@krystianek:/var/lib/libvirt/images# cat centos6.img.backup addon.raw > centos6
centos6.img.backup    centos6-oracle-1.img  centos6-oracle-2.img  centos6-oracle.img    
root@krystianek:/var/lib/libvirt/images# cat centos6.img.backup addon.raw > centos6.img

2. Boot from  LiveCD. It is required since you will be modyfing the root filesystem's volume group if you plan to modify another volume group/filesystem it may not be required. I used the CentOS LiveCD in order to do that.

3. Create a new partition. Create a new partition from the free disk space (4G). In my case I created a /dev/vda3 partition using the CentOS graphical disk utility.

4. Extend the LVM volume group. Add the newly /dev/vda3 device to the volume group

[root@livecd ~]# vgdisplay 
  --- Volume group ---
  VG Name               vg_centos6hosta
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               7.51 GiB
  PE Size               4.00 MiB
  Total PE              1922
  Alloc PE / Size       1922 / 7.51 GiB
  Free  PE / Size       0 / 0   
  VG UUID               DIeDAo-5Y1O-GEC0-JCb6-keUy-8Yc1-MhRBdN
   
[root@livecd ~]# vgextend vg_centos6hosta /dev/vda3 
  No physical volume label read from /dev/vda3
  Physical volume "/dev/vda3" successfully created
  Volume group "vg_centos6hosta" successfully extended
[root@livecd ~]# vgdisplay 
  --- Volume group ---
  VG Name               vg_centos6hosta
  System ID             
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               1
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               11.50 GiB
  PE Size               4.00 MiB
  Total PE              2945
  Alloc PE / Size       1922 / 7.51 GiB
  Free  PE / Size       1023 / 4.00 GiB
  VG UUID               DIeDAo-5Y1O-GEC0-JCb6-keUy-8Yc1-MhRBdN
   
[root@livecd ~]# lvresize -L+3995M /dev/mapper/vg_centos6hosta-lv_root 
  Rounding up size to full physical extent 3.90 GiB
  Extending logical volume lv_root to 8.50 GiB
  Logical volume lv_root successfully resized
[root@livecd ~]# 

5. Resize the filesystem residing on the LVM volume. Last but not least you have to resize the filesystem residing on the LVM volume group. For ext4 you can do it as follows (where vg_centos6hosta-lv_root is the root fs volume group):

[root@livecd ~]# e2fsck -f /dev/mapper/vg_centos6hosta-lv_root 
e2fsck 1.41.12 (17-May-2010)
_CentOS-6.0-x86_: recovering journal
Clearing orphaned inode 131145 (uid=27, gid=27, mode=0100600, size=0)
Clearing orphaned inode 131144 (uid=27, gid=27, mode=0100600, size=0)
Clearing orphaned inode 131140 (uid=27, gid=27, mode=0100600, size=0)
Clearing orphaned inode 131136 (uid=27, gid=27, mode=0100600, size=0)
Clearing orphaned inode 131130 (uid=27, gid=27, mode=0100600, size=0)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information

_CentOS-6.0-x86_: ***** FILE SYSTEM WAS MODIFIED *****
_CentOS-6.0-x86_: 139003/303104 files (0.1% non-contiguous), 1195597/1206272 blocks
[root@livecd ~]# resize2fs /dev/mapper/vg_centos6hosta-lv_root 
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mapper/vg_centos6hosta-lv_root to 2229248 (4k) blocks.
The filesystem on /dev/mapper/vg_centos6hosta-lv_root is now 2229248 blocks lo