PrettyPrint

samedi 13 septembre 2014

Install KVM in 5 steps

The distribution use for this tutorial is Fedora 18, and can be applied on Centos/Rhel 6+

Step 1: Check if your processor have hardware virtualization extension

[root@localhost ~]# egrep -q "(vmx|svm)" /proc/cpuinfo && echo OK || NOK
If "OK" you can continue, else "sorry try another virtualization solution".

Step 2: Install KVM itself with it's tools

[root@localhost ~]# yum groupinstall virtualization


Step 3: Check if all the required modules are loaded

[root@localhost ~]# lsmod | grep kvm
kvm_intel 138567 0
kvm 429349 1 kvm_intel


if you have no results, manually load:
[root@localhost ~]# modprobe kvm

If at this step, kvm_intel not appear, this means that you have to enable the CPU virtualization extension in the BIOS (Intel VT-x or AMD-V).
You can see this on kernel messages:
[root@localhost ~]# grep kvm /var/log/messages
kernel: [ 15.331262] kvm: disabled by bios


Step 4: Start and enable the libvirtd daemon

[root@localhost ~]# systemctl start libvirtd.service
[root@localhost ~]# service libvirtd start      #on Centos/Rhel6

[root@localhost ~]# systemctl enable libvirtd.service
[root@localhost ~]# chkconfig libvirtd on      #on Centos/Rhel6

Step 5: Play with GUI virtual manager

[root@localhost ~]# virt-manager


jeudi 11 septembre 2014

Mount a LVM snapshot of a XFS filesystem

Lors de mes tests, j'ai été confronté a un problème de montage d'un instantané (snapshot) d'un LV en XFS; le problème, les snapshots ayant le meme uuid que leur LV d'origine et XFS empechant, par defaut, le double montage d'un fs (se basant sur l'uuid), il refusera de le monter.

Je vous donne ici une solution, en reproduisant l'erreur.

Creation d'un LV
[root@tnjulius ~]# vgcreate vg_test /dev/md0
[root@tnjulius ~]# lvcreate -n lv_test -l50%FREE vg_test
[root@tnjulius ~]# mkfs.xfs /dev/vg_test/lv_test
[root@tnjulius ~]# mkdir /test
[root@tnjulius ~]# mount /dev/vg_test/lv_test /test/

Création du snapshot
[root@tnjulius ~]# lvcreate -s -n lv_test_snap01 -l1%ORIGIN /dev/vg_test/lv_test

montage du snapshot
[root@tnjulius ~]# mkdir /test_snap
[root@tnjulius ~]# mount /dev/vg_test/lv_test_snap01 /test_snap/
mount: wrong fs type, bad option, bad superblock on /dev/mapper/vg_test-lv_test_snap01,
       missing codepage or helper program, or other error
       In some cases useful info is found in syslog - try
       dmesg | tail or so

Verification dans les logs
[root@tnjulius ~]# tail -1 /var/log/messages
Sep 11 14:30:58 tnjulius kernel: [11175.220536] XFS (dm-14): Filesystem has duplicate UUID ed8f9114-8471-4d87-8a51-4a4f27eeb239 - can't mount

Solution: en cherchant dans man mount
Mount options for xfs
(...)
nouuid Don't check for double mounted filesystems using the filesystem uuid.  This is useful to mount LVM snapshot volumes.
(...)

[root@tnjulius ~]# mount -o nouuid /dev/vg_test/lv_test_snap01 /test_snap/
[root@tnjulius ~]# tail -3 /var/log/messages
Sep 11 14:37:18 tnjulius kernel: [11555.401702] XFS (dm-14): Mounting Filesystem
Sep 11 14:37:18 tnjulius kernel: [11555.928120] XFS (dm-14): Starting recovery (logdev: internal)
Sep 11 14:37:18 tnjulius kernel: [11556.068293] XFS (dm-14): Ending recovery (logdev: internal)