Search This Blog

Tuesday, November 12, 2013

pic


Friday, October 25, 2013

Snake's magic

Simple example:

!#/usr/bin/env python

x = 'abcdef'

if x.find('z'):
    print 'True'
else:
    print 'False'

What result will you get after run this python code ? False ?, are you sure  ?

Wednesday, July 17, 2013

Linux CentOS 6 KVM hot add device

First of all, you should avoid using virsh attach-disk with its limited amount of options. Instead, I suggest to specify the exact disk format you prefer in a separate, temporary XML file, like this: 

<disk type='file' device='disk'>
  <driver name='qemu' type='qcow2' cache='writeback'/>
  <source file='/home/gert/kvm/testdomain-vdb.img'/>
  <target dev='vdb' bus='virtio'/>
</disk>


Before adding it, make sure the hotplug kernel modules are loaded in the guest: 

modprobe acpiphp
modprobe pci_hotplug


Some distributions, including recent CentOS/RHEL/Fedora have this built-in in the kernel. In this case, check for CONFIG_HOTPLUG_PCI_ACPI. If it's y, then you're all set.

Finally, add it to the running VM using 

virsh # attach-device [domain] /path/to/disk.xml
(optionally, add the --persistent option to let Libvirt update the domain XML definition 'persistent'.)

In the guest, the kernel should now be triggered, as can be checked with dmesg:
[  321.946440] virtio-pci 0000:00:06.0: using default PCI settings
[...]
[  321.952782]  vdb: vdb1 vdb2

This also works perfectly using the GUI-enabled virt-manager application.

source

How to clear memory (caches) on Linux

Since 2.6.16 you need only echo to clear cached memory on Linux box.

This will clear all cached memory.


echo 3 > /proc/sys/vm/drop_caches
You can clear only part of it by using 1 or 2. All options:
  • 1 to clear cached pages.
  • 2 to clear dentries and inodes. 
  • 3 to clear all cached memory.

Thursday, February 14, 2013

Copy LVM volume over network to another LVM pool

We need to copy huge LVM volume from HOST_A to LVM on HOST_B. It can be virtual machine disk for example.
On HOST_B create LVM_HOST_B volume and after that dd over ssh with gzip. And do not use /dev/mapper

#> dd bs=1M if=LVM_HOST_A | gzip --fast -c | ssh HOST_B "gzip -d -c | dd bs=1M of=LVM_HOST_B"

Awesome!

pv utility can show progress bar for dd. pv - monitor the progress of data through a pipe.
pv -ptrb

Sunday, January 20, 2013

About Centos and default kernel boot options

 We use Centos and KVM virtualization on my work place. After some time new kernel was released and the question arose "How do I set the default kernel parameters in CentOS for all existing and future kernels?"

 We found a solution for CentOS! yum uses grubby itself! (strace, thank you!) grubby has the option "--copy-default" and I think yum runs grubby with it. So only thing you should do is to add in grub.conf all kernel options you need to current default kernel and reboot. After reboot you can install new kernel!

serverfault

Wednesday, January 16, 2013

My Debian and USB memory stick

 Few days ago i bought Silicon Power USB memory stick 16Gb size.
Memory was formated to ntfs file system (mkfs.ntfs) for MS Windows compatability.
 I was very surprised when i try copy some big files (3.3 GB ) to it and my PC totaly freezed on 70-80%.

After some search in google i found solution: ehci_hcd module

#> modprobe ehci_hcd

#> rsync -av --progress /home/***/Downloads/xxx-720p.mkv /mnt/usb/
sending incremental file list
xxx-720p.mkv
  3519709784 100%   29.22MB/s    0:01:54 (xfer#1, to-check=0/1)

sent 3520139543 bytes  received 31 bytes  30477398.91 bytes/sec
total size is 3519709784  speedup is 1.00


awesome!