Monday, March 30, 2009

Clone Arch Linux to another computer

I’ve just cloned my arch linux installation from my lab pc to my laptop, and it is much easier than I’ve expected. First I packed every thing up into a tar in a removable disk like this: (you need to change sdxx and sdyy below to your corresponding partition)

#mount the backup disk
mkdir /mnt/backup
mount /dev/sdxx /mnt/backup
cd /
tar -cvpzf /mnt/backup/BACKUP_FILE.tar.gz --exclude=/{dev,lost+found,mnt,proc,sys,tmp,}/* /

Then in my laptop:

# boot with arch iso
# mount the dest partition
mkdir /mnt/arch
mount –t ext3 /dev/sdyy /mnt/arch
# mount the backup disk
mkdir /mnt/backup
mount –t vfat /dev/sdxx /mnt/backup
# expand the installation tar
cd /mnt/arch
tar –xvpzf /mnt/backup/BACKUP_FILE.tar.gz
# something necessary to boot
chroot /mnt/arch
cd /dev
mknod -m 660 console c 5 1
mknod -m 660 null c 1 3
# modify the /etc/fstab
# make a new boot ramdisk
mkinitcpio -p kernel26
# install grub
# modify /boot/grub/menu.lst
exit
umount /dev/sdxx
umount /dev/sdyy
shutdown –r now
# have fun

Besides what are listed here, I also changed my video card driver and edited my /etc/xorg.conf file. The workflow works well for Arch Linux, but might not work exactly with other distro(e.g. mkinicpio seems to be Arch-only), in this case you may need to consult the all-mighty adviser – Google ;)

Monday, March 23, 2009

Cannot use visudo?

Su is not always the best tool to grand permission to users, so I installed sudo on my Arch Linux system. However when I tried to issue visudo, I got the following error:

bash-3.2# visudo
bash: visudo: command not found
The reason of this is quite simple - /usr/sbin is not in the PATH environment variable by default, and you can locate the visudo command by:
bash-3.2# whereis visudo
visudo: /usr/sbin/visudo /usr/share/man/man8/visudo.8.gz
so just use the full path to visudo:
bash-3.2# /usr/sbin/visudo
then everything goes right.

Sunday, March 22, 2009

Script to set all pdf bookmarks to zoom: inherit

When you create a bookmark in Acrobat, it automaticly sets the current zoom setting to te bookmark. This may be smart and sweet for someone, but to me it's stupid and annoying. Since when I read a file in a large screen, I want a greater zoom, while on a smaller screen, I wanna save space and see more content; setting a zoom for bookmarks screws things up. Finally I found {a great perl script} that can convert all pdf bookmark to zoom: inherit.

Use the bookmarks-fitpage.pl script from the zip, which set all bookmarks to zoom: inherit (the script is named as fitpage, which is a bit confusing...)

Notice that the script only works for PDF version 1.4 or earlier, if you're using Acrobat 9, you can convert the file to pdf-1.4 (Acrobat 5) by going to menu: advanced>print production>preflight, the wizard will do a nice convert job for you.

VIM in GNU coding style

I guess I'll start working on GCC recently, so I tried to prepare my VIM for GNU coding style. However, it's not as easy as I hoped, since VIM seems to favor BSD style more than GNU style which is a great waste of screen space in my view...Anyway, after a vast amount of Googling and attempts, it works now. Here's what I did to VIM: create a file named c.vim in my "~/.vim/after/ftplugin" directory, with the following content:
"GNU Coding Standards
setlocal cindent
setlocal cinoptions=>4,n-2,{2,^-2,:2,=2,g0,h2,p5,t0,+2,(0,u0,w1,m1
setlocal expandtab
setlocal shiftwidth=2
setlocal tabstop=8
setlocal softtabstop=2
setlocal textwidth=80
setlocal fo-=ro fo+=cql
I have to put it here otherwise the settings might be overrode by VIM's default ftplugin settings.

Saturday, March 21, 2009

My Score Summary as a Nerd…

I came accross this quiz (nerd quiz) when I was browsing my RSS feeds -____-b

Overall, you scored as follows:




10% scored higher (more nerdy),
1% scored the same, and
89% scored lower (less nerdy).

What does this mean? Your nerdiness is:
High-Level Nerd. You are definitely MIT material, apply now!!!.

Wednesday, March 18, 2009

Vim春季新装面世


Vim是什么?Vim是一种异空间里的宗教……那就让我来展示一下我看到的Vim世界的样子吧=)
color scheme: molokai