Customize CyanogenMod ROM

不知道还有多少人在坚持使用早期的 Android 设备,比如 HTC Dream (G1)、Magic (G2) 等。上个月某天午饭时,一个同事说她最近入手了 Sensation (G14),因为原先的那台 Hero (G3) 实在太慢了。嗯,想起了 Richard Jones 说的——Android is the new Windows. 多数情况下,用户不会去管操作系统,于是太多的硬件资源被不必要地占用了,而且还带来不稳定性。但 Android 的开放性使得用户可以对其进行裁减/定制,最原始的做法是直接从源码开始,不过这太麻烦了,另一种做法是修改已经存在的 ROM 安装包。

我依然在使用 G2,已经两年半了,机器里跑的是基于 CM 6.1.0 裁减之后的版本,速度和稳定性都是能接受的。下表(Table 1)列出了修改细节:

Table 1. CyanogenMod ROM

程序包 用途 改变
AccountAndSyncSettings.apk 账户同步设置 保留
ADWLauncher.apk ADW 桌面起动器 保留
AndroidTerm.apk 终端模拟器 删除
ApplicationsProvider.apk 应用程序信息存储器 保留
Bluetooth.apk 蓝牙服务 保留
Browser.apk 浏览器 保留
Calculator.apk 计算器 删除
Calendar.apk 日历 保留
CalendarProvider.apk 日历存储器 保留
Camera.apk 照相机 保留
CertInstaller.apk 证书安装器 保留
CMParts.apk CM 高级设置 保留
CMPartsHelper.apk CM 提示 保留
CMStats.apk CM 统计 删除
CMWallpapers.apk CM 壁纸 删除
Contacts.apk 联系人 保留
ContactsProvider.apk 联系人存储器 保留
DefaultContainerService.apk 默认通讯录服务 保留
DeskClock.apk 闹钟时钟 保留
Development.apk 开发者调试工具 删除
DownloadProvider.apk 下载支持服务 保留
DrmProvider.apk DRM受保护数据存储服务 保留
DSPManager.apk DSP音频特效管理器 删除
Email.apk 电子邮箱 删除
FileManager.apk 文件管理器 保留
Gallery3D.apk 3D 图库 删除
HTMLViewer.apk HTML查看器 保留
LatinIME.apk 拉丁输入法 保留
LiveWallpapersPicker.apk 动态壁纸查看器 删除
MediaProvider.apk 媒体支持 保留
Mms.apk 短信彩信 保留
Music.apk 音乐播放器 删除
PackageInstaller.apk 应用安装程序 保留
Phone.apk 电话 保留
PicoTts.apk 语音朗读引擎 删除
Protips.apk 桌面帮助提示小插件 删除
Provision.apk 设置向导 保留
QuickSearchBox.apk 快速搜索框 删除
RomManager.apk ROM 管理器 删除
RootExplorer.apk ROOT 文件管理器 新增
Settings.apk 系统设置 保留
SettingsProvider.apk 系统设置存储器 保留
SoundRecorder.apk 录音机 删除
SpareParts.apk 附加选项 保留
Stk.apk SIM卡工具包 保留
Superuser.apk 超级用户 保留
TelephonyProvider.apk 拨号器储存 保留
TtsService.apk 语音服务 删除
UserDictionaryProvider.apk 用户字典存储服务 保留
VoicDialer.apk 语音拨号 删除
VpnServices.apk VPN 服务 保留

你可以下载以上裁减之后的包:update-cm-6.1.0-DS-lite-signed.zip (48M)
如果你的手机是 G1 或者 G2 32B,直接刷这个包就行了。如果你的手机是 G2 32A (EBL1),还需要刷一个 port 包

(OPTIONAL)注意,以上 ROM 是不包含 Google Addons 的,如果你需要 Google 提供的一些功能,比如 Gtalk、电子市场等的,需要刷 gapps 包。当然,我们也可以做一些裁减。以下表格(Table 2)所列是对 gapps-mdpi-20110501 的修改:

Table 2. gapps

程序包 用途 改变
CarHomeGoogle.apk 车载模式主程序 删除
CarHomeLauncher.apk 车载模式主屏幕 删除
Facebook.apk Facebook 删除
GenieWidget.apk 天气和资讯挂件 删除
Gmail.apk Gmail 删除
GoogleBackupTransport.apk Google 备份传输 删除
GoogleCalendarSyncAdapter.apk Google 日历同步 保留
GoogleContactsSyncAdapter.apk Google 联系人同步 保留
GoogleFeedback.apk Google 反馈 删除
GooglePartnerSetup.apk Google 伙伴设置 保留
GoogleQuickSearchBox.apk Google 快速搜索框 删除
GoogleServicesFramework.apk Google 服务框架 保留
googlevoice.apk Google 语音 删除
HtcCopyright.apk HTC 版权 删除
HtcEmailPolicy.apk HTC 电邮政策 删除
HtcSettings.apk HTC 设置 删除
kickback.apk 操作振动回馈 删除
LatinImeTutorial.apk 拉丁输入法教程 删除
Maps.apk Google 地图 删除
MarketUpdater.apk 电子市场升级程序 保留
MediaUploader.apk 媒体上载 保留
NetworkLocation.apk 网络位置 保留
OneTimeInitializer.apk 首次初始化工具 保留
PassionQuickOffice.apk 办公工具 删除
SetupWizard.apk 设置向导 保留
soundback.apk 操作声音回馈 删除
Street.apk 街景 删除
Talk.apk Gtalk 保留
talkback.apk 辅助功能 删除
Twitter.apk Twitter 删除
Vending.apk 电子市场 保留
VoiceSearch.apk 语音搜索 删除
YouTube.apk YouTube 删除

你可以下载以上裁减之后的 Google Addons 包:gapps-mdpi-20110501-lite-signed.zip (3M)

注:如果你自行修改了 ROM,一定要对新包进行签名,否则无法刷。android.com 上有指南:Signing Your Applications,就是使用 keytool、jarsigner 两个工具。

如此精简之后,你的“老旧”安卓手机应该也不会表现的太差,have fune ^o^

Posted in Android | 2 Comments

Installing Debian from USB Stick

This post describes how to install Debian Testing (current Testing is Wheezy). The procedure for installing Debian Stable (current Stable is Squeeze) is same, only the download links are different.

1. Install the necessary tools on your computer which runs a Linux as operating system. My ThinkPad runs Ubuntu 10.10:
$ sudo apt-get install mtools syslinux

2. Insert a USB stick into your computer, in most cases, your Linux should mount the USB disk automatically. If so, umount if firstly:
$ sudo umount /path/to/mount/point

3. Check the partitions information of the USB disk (assume the device is /dev/sdb):
$ sudo fdisk -l /dev/sdb

If the USB disk is never initialized and has no partition table, you need to create at least one partition on it.

4. Format (one partition is enough):
$ sudo mkdosfs /dev/sdb1

5. Install syslinux:
$ sudo syslinux /dev/sdb1

6. Mount the USB disk, and put necessary files into it:
$ sudo mount /dev/sdb1 /mnt
$ cd /mnt
$ sudo wget http://d-i.debian.org/daily-images/amd64/daily/hd-media/vmlinuz
$ sudo wget http://d-i.debian.org/daily-images/amd64/daily/hd-media/initrd.gz
$ sudo wget http://cdimage.debian.org/cdimage/daily-builds/daily/arch-latest/amd64/iso-cd/debian-testing-amd64-netinst.iso

Notes: Of course, since downloading images is time-consuming, you can download them separately and copy into the USB disk.

7. Create configuration file syslinux.cfg
$ cd /mnt
$ sudo vi syslinux.cfg

default vmlinuz
append initrd=initrd.gz

Umount the USB disk, it’s ready for use then.

No CD/DVD, more green :-) Have fun!

Posted in Linux | Tagged | Leave a comment

Create a Xen Virtual Machine

This tutorial shows how to create a VM (virtual machine) on Xen and install CentOS 6.0.

1. Prepare Virtual Disk Image

Xen supports to run VM on physical device or virtual disk image. Here I am going to use virtual disk image in raw format. The below creates a 8G virtual disk for root partition, and a 512M virtual disk for swap:

# dd if=/dev/zero of=centos6.img bs=4K count=0 seek=2048K
# dd if=/dev/zero of=centos6.swp bs=4K count=0 seek=128K

Or, you can use qemu-img utility to replace dd:

# qemu-img create -f raw centos6.img 8G
# qemu-img create -f raw centos6.swp 512M

2. Prepare Configuration for Xen VM installation

Xen needs three files to install a VM: kernel, ramdisk, and a configuration file.

You can always find appropriate kernel and ramdisk from your Linux distribution’s website, for example, CentOS 6.0:

# wget http://mirror.centos.org/centos/6.0/os/x86_64/isolinux/vmlinuz
# wget http://mirror.centos.org/centos/6.0/os/x86_64/isolinux/initrd.img

And create a Xen configuration file:

# vi centos6-x64-domu

kernel = "/data/vm/vmlinuz"
ramdisk = "/data/vm/initrd.img"
name = "xc6"
memory = "512"
disk = [ "file:/data/vm/centos6.img,xvda,w","file:/data/vm/centos6.swp,xvdb,w" ]
vif = [ "bridge=br0" ]
vcpus = 1
on_reboot = "destroy"
on_crash = "destroy"

Notes:

file: uses dom0 kernel page cache, and thus might give better performance than phy: or tap:aio:, but it’s also more insecure because of caching. tap:aio: uses direct IO, so it bypasses dom0 kernel cache, and works like phy: in that sense. Refer to blktap on Xen’s wiki to understand more.

Please be aware:
1, your dom0 must have loaded blktap modules before you can use tap:aio:. Not every Linux distribution has built everything in.
2, if your blktap is version 2 (i.e., blktap2), for example, Debian Wheezy, you need to use tap2:tapdisk:aio: etc.

3. Start Installing

Now it’s time to create the VM and start installing CentOS 6.0 in it:

# xm create centos6-x64-domu

Then you can connect to the virtual console, and do regular OS installation:

# xm console xc6

4. Change Configuration for Xen VM Normal Operation

After the OS is installed, the VM is destroyed. You need to edit the configuration from Xen VM installation to normal operation.

# vi centos6-x64-domu

name = "xc6"
memory = "512"
disk = [ "file:/data/vm/centos6.img,xvda,w","file:/data/vm/centos6.swp,xvdb,w" ]
vif = [ "bridge=br0" ]
bootloader = "/usr/lib/xen-4.1/bin/pygrub"
vcpus = 1
on_reboot = "restart"
on_crash = "destroy"

The new configuration uses pygrub as a bootloader that acts grub and uses grub.conf from inside the VM. Of course, you can continue using the separated kernel and ramdisk, but this means you need to maitain them by yourselves.

Then you can start your VM by typing:

# xm create centos6-x64-domu

Have fun!

Posted in Cloud Computing | Tagged , | Leave a comment

QEMU-KVM with SPICE Support on Ubuntu 11.10 64-bit

SPICE server requires 64-bit system. Make sure you are running Oneiric x86_64.

1. Remove AppArmor

$ sudo invoke-rc.d apparmor stop
$ sudo update-rc.d -f apparmor remove
$ sudo apt-get autoremove --purge apparmor
$ sudo reboot

After the machine is rebooted, you can check if there are configurations or data folders not deleted automatically, if yes, you can delete them safely, for example:

$ cd /etc
$ sudo rm -fr apparmor*

2. Configure Bridge (optional)

This step is only required when you want to provide ethernet bridging for VMs.

First of all, bridging tool needs to be installed:

$ sudo apt-get install bridge-utils

By default, Ubuntu uses NetworkManager to configure network devices automatically. But here we need to edit the configuration file manually to add bridging settings:

$ sudo vi /etc/network/interfaces

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual

auto br0
iface br0 inet static
address 192.168.96.88
netmask 255.255.255.0
network 192.168.96.0
broadcast 192.168.96.255
gateway 192.168.96.1
bridge_ports eth0
bridge_stp off
bridge_fd 0
bridge_maxwait 0

If your machine is using DHCP for IP configuration, change the third section (device br0) to:

auto br0
iface br0 inet dhcp
bridge_ports eth0
bridge_stp off
bridge_fd 0
bridge_maxwait 0

Save your configuration file, and restart network to take effect:

$ sudo invoke-rc.d networking stop
$ sudo invoke-rc.d networking start

Or, if you are working remotely, stopping network will disconnect you to the machine, just do reboot machine alternatively.

After restarted network or rebooted machine, use ifconfig and brctl show to check if ethernet briding works as expected.

$ brctl show
bridge name	bridge id		STP enabled	interfaces
br0		8000.5c63bf86e499	no		eth0

3. Install KVM and SPICE packages

The qemu-kvm version in Oneiric is 0.14, but Ubuntu’s compilation does not include SPICE support. We have to use another repository which has compiled qemu-kvm with SPICE support.

$ sudo apt-add-repository ppa:bderzhavets/qemu-git
$ sudo apt-get update

I don’t know if there are the other repositories better than the above found in Ubuntu wiki. But at least it works.

Install:

$ sudo apt-get install qemu-kvm virt-manager spice libspice-server

After installed the packages, your Oneiric is ready to run VM with SPICE support. Refer to another post to learn how to install guest with SPICE support.

Posted in Cloud Computing | Tagged , , | 6 Comments

iptables in Ubuntu

Since 7.10, Ubuntu uses UFW to manage firewall. Well, UFW is easier than iptables, but I prefer to use iptables directly. Keep it less layers.

Stop and remove UFW:

$ sudo invoke-rc.d ufw remove
$ sudo update-rc.d -f ufw remove
$ sudo apt-get autoremove --purge ufw

Then install a utility for loading iptables rules at boot-time:

$ sudo apt-get install iptables-persistent

By default the iptables rules are stored in /etc/iptables/rules.v4.

Sample 1: configure a dual-NIC Linux box as a NAT gateway. Let’s assume eth0 be connected with external network, eth1 be connected with internal network, and the internal network is 192.168.96.0/24.

Use editor to open the above file, and add the following line under POSTROUTING ACCEPT chain of nat table:

-A POSTROUTING -s 192.168.96.0/24 ! -d 192.168.96.0/24 -o eth0 -j MASQUERADE

Sample 2: Open ports. Assume needs to open TCP ports 22, 53, 80, and 5900-5920.

Adding the below line under INPUT ACCEPT chain of filter table:

-A INPUT -p tcp -m multiport ‐-dports 5900:5920 -j ACCEPT
-A INPUT -p tcp -m multiport ‐-dports 22,53,80 -j ACCEPT

<EOF>

Posted in Linux | Tagged , | Leave a comment

Install a Windows Guest with SPICE

There are many choices for desktop virtualization (sometimes called desktop cloud):

  • ICA – Citrix XenDesktop supports it
  • PCoIP – VMWare View supports it
  • RDP – Microsoft supports it
  • SPICE – Red Hat (RHEV) supports it
  • … …

The last one, SPICE, really rocks, especially in multimedia and WAN! The user experience is really great.

SPICE (Simple Protocol for Independent Computing Environments) is an open standard. Red Hat got SPICE and KVM when it acquired Qumranet in 2008, and opened them. SPICE support was added to upstream Qemu in April 2010, that means, if your Qemu is released after April 2010, you can play with SPICE easily with the following steps.

This experiment uses Fedora 15 x86_64 as the host machine OS, SPICE server doesn’t support 32-bit system due to its reliance to 64-bit atomic operation, and uses Windows XP as the guest machine OS, because Windows still dominates the personal desktop area.

1. Create a VM and install Windows XP:

Prepare a virtual disk:

$ sudo qemu-img create -f raw winxp.img 10G

Install VM:

$ sudo virt-install --connect=qemu:///system \
                    --name=richdesk --ram=1024 --vcpus=1 \
                    --os-type=windows --os-variant=winxp \
                    --hvm --virt-type kvm \
                    --cdrom=/path/to/winxp_install.iso \
                    --disk path=/path/to/winxp.img \
                    -w network=default \
                    --graphics spice,port=5901,listen=0.0.0.0 \
                    --video qxl --channel spicevmc \
                    --soundhw default \
                    --accelerate

Notes:

  • The above command uses NAT for network, if you prefer bridge mode, change network option to --network bridge=br0. Of course, you need to configure a bridge device br0 firstly.
  • The above command uses 5901 as SPICE server port, you can change it to any valid port. Please make sure the port is opened on the host machine if it has firewall enabled.

After installed the basic Windows XP, shutdown the VM.

2. Install SPICE guest packages for Windows

Download the latest Windows binaries packages from SPICE website:

$ wget http://spice-space.org/download/binaries/qxl-win-0.1010-20110308-d9eb3203bd.zip
$ wget http://spice-space.org/download/binaries/virtio-serial_20110725.zip
$ wget http://spice-space.org/download/binaries/vdagent-win32_20110801.zip

Copy qxl, virtio-serial, vdagent packages into the images:

$ sudo virt-copy-in -a winxp.img *.zip 'win:c:\'

Then start VM, and install the drivers qxl and virtio-serial.

Unzip vdagent package to any place, for example, C:\opt, and register it as a Windows service:

C:\opt\vdagent-win-x86> vdservice install

Reboot this Windows VM.

3. Connect to VM via SPICE protocol

There are several client tools which support SPICE protocol, for example, Vinagre, spicec, virt-manager, etc. My favourite is Vinagre. Also you can buy a thin client hardware whose firmware supports SPICE protocol.

By default the SPICE plugin of Vinagre is disabled, you can enable it through Edit -> Plugins. Then you can connect to host:5901.

Now you have gotten a Windows guest with SPICE support, then enjoy the great quanlity and smooth operation experience brought to you by SPICE! Is it all? Yes if you mean SPICE. But if you want to improve the performance of your virtual desktop more, recommend to use virtio drivers for hard disk and network card. I’m not going to cover virtio in this post.

Have fun ^o^

Posted in Cloud Computing | Tagged , , , | 1 Comment

Compile and Install SPICE Client on Ubuntu

Since 11.10 (Oneiric), Ubuntu includes SPICE client in its official repository. But how can we get SPICE client if we still use the old Ubuntu releases prior to Oneiric?

The following describes how to compile and install a SPICE client from source code on Ubuntu 10.10 (Maverick) 32bit. The procedure for the other Ubuntu releases or Debian distributions should be similar.

1. Install the standard tools for compilation
$ sudo apt-get install build-essential autoconf git-core libtool

2. Install dependencies existing in repository
$ sudo apt-get install libavcodec-dev libssl-dev libasound-dev libpng12-dev libfreetype6-dev libogg-dev libxrandr-dev libgcrypt-dev libsdl-dev libnss3-dev libpixman-1-dev libxfixes-dev libjpeg8-dev libsasl2-dev

3. Install dependencies not existing in repository

3.1. libcacard

This library is what SPICE uses to emulate smart cards and smart card readers.

$ git clone git://anongit.freedesktop.org/~alon/libcacard
$ cd libcacard
$ ./autogen.sh
$ make
$ sudo make install

3.2. celt051

There is newer celt packages in Maverick’s repository, the version is 0.7.1. But SPICE client requires a specific version – 0.5.1, so we have to install this required version manually.

Get the below two packages from launchpad then install:

$ sudo dpkg -i libcelt051_0.5.1.3-2_i386.deb
$ sudo dpkg -i libcelt051-dev_0.5.1.3-2_i386.deb

3.3. SPICE protocol

$ wget http://spice-space.org/download/releases/spice-protocol-0.8.1.tar.bz2
$ tar jxvf spice-protocol-0.8.1.tar.bz2
$ cd spice-protocol-0.8.1
$ ./configure --prefix=/usr
$ make
$ sudo make install
$ cd /usr/include
$ sudo ln -s spice-1/spice .

4. Finally we are ready to compile and install SPICE client

$ wget http://spice-space.org/download/releases/spice-0.8.2.tar.bz2
$ tar jxvf spice-0.8.2.tar.bz2
$ cd spice-0.8.2
$ ./configure --enable-smartcard
$ make
$ sudo make install

That’s it. Now you can connect to your VM with spicec, for example:

$ spicec --host SPICE_SERVER --port 5300

Enjoy the speed and performance of SPICE!

<EOF>

Posted in Cloud Computing | Tagged , | 1 Comment

My Must-Have PPAs

Within a release life cycle, Ubuntu only maintains the minor upgrades of the applications installed in the release. If you want to keep your applications up-to-date and catch their major upgrades, you have to do the upgrades by yourselves, or use PPAs which are maintained actively by someone or a community team. The following PPAs are my recommendations:

ppa:libreoffice/ppa
ppa:chromium-daily/stable
ppa:mozillateam/firefox-stable
ppa:pidgin-developers/ppa

If you need QQ support in Pidgin, you can install a protocol plugin: libqq-pidgin. You can compile its source code and install it, of course, there is a PPA usable:

ppa:lainme/libqq

<EOF>

Posted in Linux | Tagged | Leave a comment

OpenVPN 客户端配置之 GNOME Network Manager 篇

主流 Linux 桌面系统之一的 GNOME 默认携带的 Network Manager 支持 OpenVPN。安装非常简单:

Fedora:

$ sudo yum install NetworkManager-openvpn

Debian/Ubuntu:

$ sudo apt-get install network-manager-openvpn

以下步骤是在 Fedora 15 中配置 GNOME Network Manager 连接至 HLYY OpenVPN 服务,其他 Linux 分发版应该都是一样一样滴:

1. 下载 HLYY OpenVPN CA 证书:
$ wget http://vpn.yunsong.net/hlyy-ca.crt

2. 打开 系统设置 -> 网络,点击左下角的加号(图1),在出现的对话框中选择创建一个 VPN 连接、并选择 OpenVPN 类型。


图1

3. 如下图2配置 OpenVPN 客户端


图2

网关:vpn.yunsong.net
认证类型:密码
用户名:your_username
密码:your_password
CA 证书:选择在第一步中下载的 hlyy-ca.crt 文件

并点击“高级…”按钮,在弹出的新对话框(图3)中做如下配置:


图3

选中“使用自定义网关端口”,并指定端口为 11194
选中“使用 LZO 压缩”

OK,这就完成了配置。

需要注意的是,当你在 Network Manager 中启用了这个 OpenVPN 连接后,所有你的计算机的网络流量都得经过这个 VPN 线路,这对于访问那些墙内资源就不合适了。这时你需要考虑分流,即只有墙外资源走 VPN 线路,Google Code 上有一个很好的项目 chnroutes 可以帮助你。

Posted in Uncategorized | Tagged , | Leave a comment

Install Lotus Notes 8.5.3 on Fedora 15 64bit

Lotus Notes still has no native support for 64bit Linux, but we can have workaround.

$ cd /etc/yum.repo.d
$ sudo wget http://pokgsa.ibm.com/projects/o/openclient/lotus/notes/beta/8.5.3/notes-8.5.3-ea.repo
$ sudo yum clean all
$ sudo yum update
$ sudo yum install ibm_lotus_notes

This is going to install Lotus Notes 8.5.3 and dependencies in your Linux. After installed, you can launch Lotus Notes to configure it, then you can see Lotus Notes launched with a blank main frame. Well, that’s a bug, don’t worry, shutdown Notes, and do the following workaround:

$ cd /opt/ibm/lotus/notes
$ sudo wget http://linux-aha.de/wordpress/wp-content/uploads/2009/10/notes_libs_karmic.tgz

There are 4 .so files in the package, extract it, and make sure they are owned by root and executable.

$ sudo chown root.root libg?k*
$ sudo chmod 755 libg?k*

OK now, you can start Lotus Notes again, the blank is gone.

Posted in Uncategorized | Tagged , | 22 Comments