April 26, 2013

Text to ASCII Art

Under Linux, use the program "figlet" to turn regular text info a ASCII art text.

Example:


 figlet hello
 _          _ _
| |__   ___| | | ___
| '_ \ / _ \ | |/ _ \
| | | |  __/ | | (_) |
|_| |_|\___|_|_|\___/


figlet -W hello (wide version)
  _              _   _
 | |__     ___  | | | |   ___
 | '_ \   / _ \ | | | |  / _ \
 | | | | |  __/ | | | | | (_) |
 |_| |_|  \___| |_| |_|  \___/


You can choose different style too:


figlet -f banner -W hello

 #    #  ######  #       #        ####
 #    #  #       #       #       #    #
 ######  #####   #       #       #    #
 #    #  #       #       #       #    #
 #    #  #       #       #       #    #
 #    #  ######  ######  ######   ####

figlet -f bubble -W hello
   _     _     _     _     _
  / \   / \   / \   / \   / \
 ( h ) ( e ) ( l ) ( l ) ( o )
  \_/   \_/   \_/   \_/   \_/

Use "figlist" to list all the styles.




April 10, 2013

Fix: vim indent not working

If you loaded a new indent file or syntax file under ~/.vim/ and it is not taking effect, make sure you have the following line in your ~/.vimrc file:


filetype plugin indent on


This turns on filetype detection, filetype plugin, and filetype-indent. 

April 1, 2013

how to mount vdi

First install lvm2, ndb and qemu-common packages:

Code

yum install lvm2 nbd qemu-common

Then run this to load the nbd module:

Code

modprobe nbd max_part=16

And connect the device:

Code

qemu-nbd -c /dev/nbd0 "/home/USER/VirtualBox VMs/CentOS6/CentOS6.vdi"

Load the dm-mod module:

Code

modprobe dm-mod

Run this command to scan for volume groups:

Code

vgscan

This will output something like this:
  Reading all physical volumes.  This may take a while...
  Found volume group "vg_centos" using metadata type lvm2

In the next step we want to use what is in the quotes above. Run this command but replace vg_centos with whatever shows in the quotes.

Code

vgchange -ay vg_centos

Then show which partitions there are:

Code

lvs

This will output something like this:
  LV      VG        Attr   LSize  Origin Snap%  Move Log Copy%  Convert
  lv_root vg_centos -wi-a- 18.12g
  lv_swap vg_centos -wi-a-  1.97g

In this case we want the logical volume named lv_root so run this command:

Code

mount /dev/vg_centos/lv_root /mnt/vdi -o ro,user

Now you should be able to find your disk in the /mnt/vdi folder. Note that you must have created the /mnt/vdi folder first but you can mount it wherever you like into an empty folder.

Some more useful tips.

You can unmount the disk:

Code

umount /mnt/vdi

This command will disconnect the nbd:

Code

qemu-nbd -d /dev/nbd0

After you disconnect the nbd you can unload the module: