Shrink an LVM volume

First, boot your machine up using a SystemRescueCD.  Then follow the command sequence below.

# Make any logical volume available to Linux
vgchange -a y
# Force a filesystem check for the target volume
e2fsck -f /dev/mapper/vg_server1-lv_root
# Resize the filesystem (a safer measure is to resize it to 10% less than your target size)
resize2fs /dev/mapper/vg_server1-lv_root 90G
# Reduce the LV size (to your target size)
lvreduce -L 100G /dev/mapper/vg_server1-lv_root
# Resize the inner filesystem to fit the LV
resize2fs /dev/mapper/vg_server1-lv_root
# If you have a few LVs and you do the above for all, chances are you are left with a PV having a few fragmented LVs
# The command below sees how the LVs are arranged
pvs -v --segments /dev/sda2
# Move the fragmented LVs back to the front
pvmove --alloc anywhere /dev/sda2:<src-from>-<src-to> /dev/sda2:<dest-from>-<dest-to>
# Shrink the PV
pvresize --setphysicalvolumesize 64G /dev/sda2
# Then use GPartEd in X-windows to resize the partition
startx

References: [1] [2]

Advertisements
Posted in Technical, Technology | Tagged , , | Leave a comment

Install PHPMyAdmin using yum in CentOS


sudo rpm -ivh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
sudo yum install mysql-server
sudo service mysqld start
sudo mysql_install_db
sudo mysql_secure_installation
sudo yum install phpmyadmin
sudo service httpd restart

Posted in Technical | Tagged , , , | Leave a comment

每天4句話,改變孩子的一生

【每天4句話,改變孩子的一生】

孩子每天從學校回來,作為家長的你是否立刻就和孩子大聊特聊增進親子溝通呢?
這樣既會很累教育效果也不一定好。
一位聰明的爸爸教教你,每天只問孩子4個問題!

那麼,家長們一起來學習這位爸爸的高效教育法吧!

有位父親他對女兒的教育方式比較獨特,他從來沒有輔導過女兒做功課什麼的,就是每天回來跟女兒聊十分鐘,只聊四個問題,就完成了他的家庭教育。這四個問題是:

1,學校有什麼好事發生嗎?
2,今天你有什麼好的表現?
3,今天有什麼好收穫嗎?
4,有什麼需要爸爸媽媽的幫助嗎?

看似簡單的問題背後其實蘊涵著豐富的含義:

第一個問題其實是在調查女兒的價值觀,了解她心裡面覺得哪些是好的,哪些是不好的;

第二個問題實際上是在激勵女兒,增加她的自信心;

第三個問題是讓她確認一下具體學到了什麼;

第四個問題則有兩層意思,一是我很關心你,二是學習是你自己的事。

就是這簡簡單單的四個問題,包含了很多關愛關懷在裡面,事實上也證明很有效。

在教育理念中,要把孩子教育好,最關鍵的就是親子關係要處理好。如果家長在孩子心中建立起絕對的責任,孩子相信家長無條件地愛著自己,相信家長所有批評、表揚的出發是為了自己好,如果孩子在潛意識裡對此達到完全相信,那麼這種關係是良性的,是相互關愛、相互支持、相互理解的穩定關係。在這種情況下,所有教育孩子的最簡單的事情,用蘇聯大教育家蘇霍姆林斯基的話說就是“伴隨孩子成長”。

但是,現實生活大部分人的親子關係是不穩定的,或者說是扭曲的,孩子並不能真正信任家長。

誰家的父母都是愛自己的子女的,但許多家長錯把愛的方式當成了愛。

比如給孩子最好的東西吃,最好的衣服穿,這只是一種愛的方式,並不是愛本身。而家長們的愛也經常是有條件的,比如會出現只要這次考試得了前三名,就帶你去哪裡玩等等。

愛是一個生命喜歡另一個生命的感情,是一種平等的關係,是無條件的,是一種整體接納的,是要讓對方接收到的,要真正做一個好家長並不難,要教育好孩子一定要注意下面幾句話:

1,絕對禁止高壓/打罵孩子的做法,建立平等的關係。

2,真正地無條件愛孩子,給予孩子精神意義上的愛。

3,一定要尊重孩子的獨立人格。

4,用正面的方法教育孩子,時常對其鼓勵表揚。

5,調正親子關係,這是最重要的一點。

6,要注意孩子的人格精神。

如果真正理解了以上的六句話,教育好孩子就是易如反掌的事情了。

小編說說:其實影響孩子最大的因素就是各位爸爸媽媽了!所以好好對孩子說說話,他的轉變絕對會讓你對他刮目相看的!

Posted in Education | Tagged , , | Leave a comment

Setting savedefault option for grub in Ubuntu 13.04

Thank to kstevens.

You need to have both of these lines in /etc/default/grub:

GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true

Then run sudo update-grub.

Check the entries in /boot/grub/grub.cfg and they should look something like:

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Ubuntu, with Linux 2.6.32-22-generic' --class ubuntu --class gnu-linux --class gnu --class os {
        recordfail
        savedefault
        insmod ext2
        set root='(hd0,5)'
        search --no-floppy --fs-uuid --set c23bb931-2d60-4f48-9086-c8dbdc7fdca6
        linux   /boot/vmlinuz-2.6.32-22-generic root=UUID=c23bb931-2d60-4f48-9086-c8dbdc7fdca6 ro splash vga=786  quiet splash
        initrd  /boot/initrd.img-2.6.32-22-generic
}

The most important line to note is savedefault.  It indicates that this menu entry will save itself as the default when selected.  Verify that this line appears under each menu entry.

Posted in Technical, Technology | Tagged , , | 2 Comments

Un-revoke certificate in OpenVPN

First of all, “un-revoking” is not an official term. And in PKI practice, a certificate should never be un-revoked.

However, there are cases that things get wrong and you do not want to complicate things by creating new certs.  You may consider this method.

  1. cd <whatever directory your openvpn configs are in, e.g. /etc/openvpn>/easy-rsa/keys
  2. Backup the files crl.pem and index.txt.
  3. There should be an index.txt, with certificate IDs in it. The ones starting with “V” are valid, and ones with “R” are revoked. You can edit that file, and fix the first char to “V”, and delete the third column (the revocation date). If you have more then one certificate, you should see the pattern (sequential number comes in the third column now, etc).
  4. Delete crl.pem
  5. cd ..
  6. . ./vars
  7. openssl ca -gencrl -out "crl.pem" -config "$KEY_CONFIG"
  8. You should find a new crl.pem generated in the current directory. Copy this file to the sub-folder keys.  Done!
Posted in Technical, Technology | Tagged , | 1 Comment

Quick script – start VirtualBox VM in headless mode at boot time

#! /bin/sh
# /etc/init.d/StartVM
#

#Edit these variables!
VMUSER=ico
VMNAMES='browserkiosk01 browserkiosk02 browserkiosk03 browserkiosk04'
POWEROFF=acpipowerbutton
case "$1" in
 start)
 echo "Starting VirtualBox VM..."
 for vmname in $VMNAMES
 do
 sudo -H -b -u $VMUSER /usr/bin/VBoxVRDP -s "$vmname"
 sleep 30
 done
 ;;
 stop)
 echo "Saving state of Virtualbox VM..."
 for vmname in $VMNAMES
 do
 sudo -H -u $VMUSER /usr/bin/VBoxManage controlvm "$vmname" $POWEROFF
 sleep 10
 done
 ;;
 *)
 echo "Usage: /etc/init.d/StartVM {start|stop}"
 exit 1
 ;;
esac
exit 0

http://askubuntu.com/questions/57220/start-vboxheadless-vm-at-startup

Posted in Technical, Technology | Tagged , , | Leave a comment

Check if async I/O is enabled in CentOS

First, the command:

grep kio /proc/slabinfo

It gives output similar to this:

kioctx 24 60 384 10 1 : tunables 54 27 8 : slabdata 6 6 0
kiocb 7 15 256 15 1 : tunables 120 60 8 : slabdata 1 1 0

Look at the column header in the first line of /proc/slabinfo:

# name <active_objs> <num_objs> <objsize> <objperslab> <pagesperslab> : tunables <limit> <batchcount> <sharedfactor> : slabdata <active_slabs> <num_slabs> <sharedavail>

To distinguish if async I/O is enabled, check first and second columns.  If they are non-zero, that means async I/O is enabled (disabled if all zeros).

To drill a little bit more:

  • Slab allocation is a kernel memory management mechanism to kernel memory usage more efficient, hence improving performance (http://en.wikipedia.org/wiki/Slab_allocation);
  • /proc/slabinfo stores statistics about the Slab allocation;
  • There are many data structures in /proc/slabinfo storing different statistics;
  • Among them, kioctx and kiocb are 2 data structures used to store statistics for async I/O.  Hence, if they are non-zero number of objects for <active_objs> and <num_objs>, async I/O is being used (http://chenguangblog.wordpress.com/2011/03/09/async-io/).
Posted in Technical, Technology | Tagged , , , , , | Leave a comment