星期六, 五月 19, 2007

Xen On Edgy

原文链接
从源里安装内核支持及文件
sudo apt-get install xen-hypervisor-3.0-i386 xen-image-xen0-2.6.17-6-generic-xen0 xen-utils-3.0 xen-ioemu-3.0

如果运行的是server内核,那么
sudo apt-get install xen-hypervisor-3.0-i386-pae xen-image-xen0-2.6.17-6-server-xen0 xen-utils-3.0 xen-ioemu-3.0

如果是AMD64位处理器,那么使用 xen-hypervisor-3.0-amd64替换 of xen-hypervisor-3.0-i386
生成initrd image,使用如下命令
sudo mkinitramfs -o /boot/xen0-linux-2.6.17-6-generic-xen0.initrd.img 2.6.17-6-generic-xen0

添加Xen启动段到 /boot/grub/menu.lst:
title XEN/2.6.17
root (hd0,2)
kernel /boot/xen-3.0-i386.gz
module /boot/xen0-linux-2.6.17-6-generic-xen0 root=/dev/xxx ro
module /boot/xen0-linux-2.6.17-6-generic-xen0.initrd.img

"xxx"为你的启动分区,我的为hda3,故上为(hd0,2) root=/dev/hda3
PS: 1,on amd64, use xen-3.0-amd64.gz instead of xen-3.0-i386.gz
2,kernel and modules may need to have the /boot removed From them to get this to work. ie
kernel /xen-3.0-i386.gz

修改Xen的网络配置文件/etc/xen/xend-config.sxp,添加如下段
(network-script network-bridge)

If you are going to use the network-bridge, you must have the bridge-utils package installed (else your bridge won't be created by the network-bridge script and you will get an error like 'Error: Device 0 (vif) could not be connected. Hotplug scripts not working.' when attempting to start your DomU). To install it, run the following command:
sudo apt-get install bridge-utils

The later domU examples assume that you use a bridged networking using device xenbr0. If installing bridge-utils doesn't fix this, try moving the file /etc/udev/xen-backend.rules to /etc/udev/rules.d/10-xen-backend.rules
ok,重启系统
关于建立虚拟机以及启动
提到了三种方式来创建,分别是use loopback-mounted-file,和磁盘分区,以及vmware虚拟磁盘和qemu.这里说明我用的方法,也就是第一中方法。本来打算用第二种方法的,主要是我磁盘空间并不富裕了,从新分区会比较麻烦。如下创建了一个基本的edgy的guest系统
创建虚拟磁盘文件:
sudo dd if=/dev/zero of=/usr/local/diskimage-guest.ext3 bs=1024k seek=4096 count=0

格式化磁盘文件
sudo mkfs.ext3 /usr/local/diskimage-guest.ext3

note:会提示说不是一个设备文件,不用管他,选择y继续。
挂载该虚拟磁盘
sudo mount /usr/local/diskimage-guest.ext3 /mnt -o loop

安装debootstrap
sudo apt-get install debootstrap

安装edgy基本文件到虚拟磁盘
sudo debootstrap edgy /mnt

拷贝内核模块
sudo cp -a /lib/modules/2.6.17-6-generic-xen0/ /mnt/lib/modules

卸载虚拟磁盘
sudo umount /mnt

Configure the guest, create /etc/xen/edgy-guest.cfg
kernel = "/boot/xen0-linux-2.6.17-6-generic-xen0"
ramdisk = "/boot/xen0-linux-2.6.17-6-generic-xen0.initrd.img"
builder='linux'
memory = 128
name = "edgy-guest"
vcpus = 1
vif = [ 'bridge=xenbr0' ]
disk = [ 'file:/usr/local/diskimage-guest.ext3,ioemu:hda1,w' ]
root = "/dev/hda1 ro"

First start xend if it is not already started:
xend start

Now you can create your xen domain
sudo xm create edgy-guest.cfg

You can connect to the guest using
sudo xm console edgy-guest

星期日, 五月 06, 2007

可恶的网通&linux下突破共享破解方法

本来五一打了个工就挺累的,下午回去,网通竟然开始了限制共享,宿舍里面无法用路由器了。win下好说,可以用个共享神盾。linux下,开始是找了好多的资料,什么修改MAC地址啦,之类的,都不适用。实际上linux下下载东西都是没有问题的,apt也没有问题,现在就是无法浏览网页,打开网页就是网通的警告提示。(firefox)。
偶尔找到一个关于tor的文章,用了起来,真的不错,只用到3个东东,firefox的torButton插件以及tor和privoxy。
先安装tor和privoxy,从源里安装就好了,并修改然后配置文件:
nano /etc/privoxy/config

在文件开始加上一行:
forward-socks4a / localhost:9050 .

安装firefox的torButton插件,之后重起firefox即可了。
两个插件:foxyproxytorbutton
tor.jpg