Thursday, July 30, 2009

Backup with Acronis and without CD

Abstract: Boot Acronis True Image from grub.

Acronis True Image features online backup, however sometimes you may still want to do a off-line one, then normally you have to either install Acronis to hard disk or use a rescue media CD. Since I have both Arch Linux and Windows installed, I do not want to install Acronis to hard disk because I want to have grub in MBR. But I cannot use rescue cd either, because my cd has already been dead for years.

I've tried to make a usb disk rescue media, but it simply does not boot :(

So here's what I did:

  • Generate a rescue ISO with Acronis;
  • Expand ISO file and copy all in Recovery Manager to a directory on hard disk;
  • Write in Grub's menu.lst:
    title Acronis
    root (hdX,Y)
    kernel /acronis/kernel.dat quiet vga=0x317
    initrd /acronis/ramdisk.dat

  • Reboot and select Acronis from grub

Now you see, Acronis Rescue CD is actually Linux :)

Tuesday, July 28, 2009

bool & GCC

Abstract: I'll try to clear up confusion about bool for non-compiler people;)

Even some of my teammate on compiler would misunderstand bool with GCC some times. So I'm trying to make it a bit clear:

bool is not an valid type in C89, which is referred as ANSI C sometimes. Therefore, if you are working on a project that is supposed to be compiled with an ANSI C compiler, do not use bool type. However, bool is valid in C99 as _Bool, so you can use it safely if your code is not expected to be compiled with an ancient compiler;)

In GCC code, you can see 'bool' here and there, but bear in mind that it's fake - it's actually unsigned char, defined in gcc/system.h. This is because GCC is expected to bootstrap with an ANSI C compiler.

In C++, bool is always valid, you don't have to worry about bool.

SnipMate is fabulous

Abstract: A textmate-like snippet script for VIM.

I've been using snippetemu for about one year and happen to find another snippet script for vim - snipMate. After a try, I do think snipMate is much better than snippetemu, for tow reasons:

  • Its snippet format is simple and clear.
  • No placeholder.

I do suggest give it a try even if you're not a fan of TextMate, because it really makes coding easier.

You can find snipMate's VIM page here.

Tuesday, July 21, 2009

Firefox 3.5.1 (Shiretoko) fails to launch in Arch Linux

Abstract: Firefox 3.5.1 needs libjpeg.

After updating my Firefox (Shiretoki) to version 3.5.1 in Arch Linux, I cannot launch it. When I tried to start it from command line, it says:

$ firefox
Coundn't load XPCOM
$

Then I tried to run xulrunner directly, I got a Error message saying that libjpeg cannot be found. So I installed libjpeg-7-1, and Firefox is back again. Hopefully the Arch people can add libjpeg to Firefox's dependency.

Monday, July 20, 2009

Pm-hibernate with MX440

Abstract: Some tweaks to avoid black screen after resume from hibernation with old nVidia MX440 graphic card and Intel motherboard.

First edit the setting for pm-utils in /etc/pm/config.d/config(you can name this file whatever you like).

HIBERNATE_MODE="shutdown"
S2RAM_OPTS="-f"
DISPLAY_QUIRK_VBE_POST=false

Then I edit /etc/modprobe.d/modprobe.conf(the modprobe.conf is here for Arch Linux, but may lies in different place in other distros):

blacklist intel_agp

Then reboot the computer, and try hibernate again, everything goes well :)

Monday, July 13, 2009

How to Compact Virtualbox vdi

Abstract: a memo on how to compact virtualbox vdi files.

VirtualBox comes with a utility to compact vdi files which drops zero block. So the problem is how to write zero to unused blocks. If you have a windows guest, run the following command in cmd:

sdelete -c

If you have a linux guest, run this:

cat /dev/zero > zero.fill;sync;sleep 1;sync;rm -f zero.fill

And in the host run:

VBoxManage modifyvdi harddisk.vdi compact

These may reduce the size of vdi files considerably if it has been used for a long time.

Tuesday, July 7, 2009

"The greeter application appears to be crashing"

Abstract: Resolved "The greeter application appears to be crashing" problem after updating Linux system.

I don't know whether this could be called a solution... actually just a tip if you happened to come across a same problem. I updated my Arch Linux, and after reboot this dialog box jumps up and gdm could not start normally. I checked the system and found the problem was caused by a full filesystem. I cleaned up some old files and then everything goes right.

So I guess I should give more disk space to / in the future.