Category Archives: Uncategorized

Source address route with multiple IPv6 addresses

I always had ipv6 tunneling enabled on my server. One with and one with 6to4. I never had any problems with them with either as a default route. Recently my server provider start supporting native IPv6, but I found out other IP addresses are not route-able through native interface. Linux is only smart enough to pick which source address to use for outgoing connection, but not so much about return path.

The solution is policy based routing with IPv6. There are two related options in kernel configure, so make sure they are enabled. If not, you will encounter an error.

First install iproute2 and add a new route table.

echo "200 to4" >> /etc/iproute2/rt_tables

Then you can add source based rules and routes to this table.

ip -6 rule add from 2002::/16 table to4
ip -6 route add 2002::/16 dev 6to4 table to4
ip -6 route add default via :: dev 6to4 table to4

One thing I am still not sure is whether to delete the 2002::/16 from main route table.

ip -6 route del 2002::/16

I think this can solve some stateful firewall problem, but not necessary.

Boot grub2 stage2 directly from windows bootmgr with grub4dos stage1

There is problem which has been puzzled me for long time. When the grub2 root is on 2nd disk, the stage2 is not directly bootable from grub4dos stage1, but can be chain loaded from grub4dos as a linux kernel. The same problem happens to burg as well.

It turns out the stage2 file only has the relative path from root if you use grub-install script. So all you have to do is to embed a absolute path in prefix. Here is the brief step to make a direct bootable stage2.

grub-mkimage --output=/boot/grub/core.img --prefix=(hd1,2)/boot/grub 
         biosdisk part_msdos ext2
cat /boot/grub/lnxboot.img /boot/grub/core.img > g2ldr

Now copy g2ldr to your windows’ partition. Make a grub4dos stage1 file

grubinst.exe -o -b=g2ldr g2ldr.mbr

You can find grubinst.exe from grub4dos website.

Add it to windows bootmgr with bcdedit

bcdedit /create /d Linux /application BOOTSECTOR
bcdedit /set {ID} device partition=c:
bcdedit /set {ID}  path g2ldr.mbr
bcdedit /displayorder {ID} /addlast

Linux file copy benchmark cp vs cpio vs tar vs rsync

There are many commands to copy a directory in Linux. The difference between them in current Linux distribution are very small. All of them support link, time, ownership and sparse.

I tested them to copy a Linux kernel source tree. Each command I tested twice and keep the lower result.
The original directory size is 639660032 bytes. All methods generate exact same size of 675446784 bytes without sparse option.

Non Sparse Sparse
rsync rsync -a src /tmp rsync -a -S src /tmp
cpio find src -depth|cpio -pdm /tmp find src -depth|cpio -pdm –sparse /tmp
cp cp -a –sparse=never src /tmp cp -a –sparse=always src /tmp
tar tar -c src|tar -x -C /tmp tar -c -S src|tar -x -C /tmp

Time used and destination size:

For non sparse copy, rsync is the fastest. For sparse copy, rsync and cpio have the best space efficiency, but slow.

Java in Cloud

This time it is real. Google just announced java for app engine.

Updates: And cron job in app engine as well.

Two differences I noticed from python gae. It deploys byte code (war file) instead of source code to cloud. Using xml instead of yaml.

Cloud Server

I just ordered a new cloud server from mosso.

From the server IP address 67-23-8-*, apparently it is a rebranded slicehost.

To fully utilize my vps, I also build a home-grow GeoDNS server. So if you visit my blog from different locations, you could possibly get 4 different IPs.

New CDN service

Mosso’s new CDN service cost $0.22 per GB.  


Some simple tests show mosso cdn is just as fast as amazon cloud front. I offloaded some of my blog’s static image to mosso cloud files.

Pagetest  shows about 10% overall page loading time improvement.

I also wrote a simple bash script to help copying files. It seems mosso does not support gzip encoding yet, nor does cname support.

Some test result:

Pagetest from New Zealand:

New Zealand Waterfall

New Zealand Waterfall


New Zealand Connection

New Zealand Connection

Pagetest from VA USA:



VA USA Waterfall

VA USA Connection

VA USA Connection

My favorite Naruto episode

Identify Yourself: Powerful New Rivals.

I bought a naruto domain

You can start paying Google App Engine now

More cloud news this week.

Google just announced paid resources for GAE.

The price is similar to other cloud provider. Interesting is that they also charge 0.01 cent per email recipient .

WordPress approved my first plugin

Check this out.