Quickly searching in bookmarks and history using address bar in Chrome

  1. Access the Chrome address bar and type chrome://settings/searchEngines.
  2. Locate the “Other search engines” section and hit the “Add” button to the right.
  3. Fill
    1. Bookmarks” into the field “Search engine“.
    2. b” into the field “Keyword“.
    3. chrome://bookmarks?q=%s” into the field “URL with %s in place of query“.
  4. Hit the “Add” button and now you get a quick bookmarks search shortcut in the address bar.
  5. To search bookmarks, access the Chrome address bar and type “b <search keyword>” and you will invoke the bookmarks search feature.
  6. Repeat steps 2 to 4 for history by filling:
    1. History” into the field “Search engine“.
    2. h” into the field “Keyword“.
    3. chrome://history?q=%s” into the field “URL with %s in place of query“.
  7. To search history, access the Chrome address bar and type “h <search keyword>” and you will invoke the history search feature.

Shrink an LVM volume

Technical, Technology

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

References: [1] [2]

Setting savedefault option for grub in Ubuntu 13.04

Technical, Technology

Thank to kstevens.

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


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 {
        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.

Un-revoke certificate in OpenVPN

Technical, Technology

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!

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

Technical, Technology
#! /bin/sh
# /etc/init.d/StartVM

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


Check if async I/O is enabled in CentOS

Technical, Technology

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/).