Rss聚合
Posts
Comments

- Next »

Protected: 记事本

This post is password protected. To view it please enter your password below:

网上有朋友按照如下办法解决。


I followed instructions here

Code:
http://www.virtualbox.org/wiki/Linux_Downloads

After adding the ‘hardy non-free’ to sources, downloading the key and registering, run update-manager to download and configure the latest version.

When you start up VirtualBox for the first time, any existing VMs have to be converted to a new format, so make sure you backup.

I haven’t fully tested yet, but it’s working fine and the upgrade was painless.

__________________
Running Ubuntu 8.10 LAMP on Toshiba Tecra A9
Give a man fire and keep him warm for a day, set him alight and keep him warm for life
import types
from django.db import models
from django.utils import simplejson as json
from django.core.serializers.json import DateTimeAwareJSONEncoder
from decimal import *
def json_encode(data):
“”"
    The main issues with django’s default json serializer is that properties that
    had been added to a object dynamically are being ignored (and it also has 
    problems with some models).
    “”"

def _any(data):
ret = None
if type(data) is types.ListType:
ret = _list(data)
elif type(data) is types.DictType:
ret = _dict(data)
elif isinstance(data, Decimal):
# json.dumps() cant handle Decimal
ret = str(data)
elif isinstance(data, models.query.QuerySet):
# Actually its the same as a list …
ret = _list(data)
elif isinstance(data, models.Model):
ret = _model(data)
else:
ret = data
return ret

def _model(data):
ret = {}
# If we only have a model, we only want to encode the fields.
for f in data._meta.fields:
ret[f.attname] = _any(getattr(data, f.attname))
# And additionally encode arbitrary properties that had been added.
fields = dir(data.__class__) + ret.keys()
add_ons = [k for k in dir(data) if k not in fields]
for k in add_ons:
ret[k] = _any(getattr(data, k))
return ret

def _list(data):
ret = []
for v in data:
ret.append(_any(v))
return ret

def _dict(data):
ret = {}
for k,v in data.items():
ret[k] = _any(v)
return ret

ret = _any(data)

return json.dumps(ret, cls=DateTimeAwareJSONEncoder)

小学就知道,数学定理中规定了余数永远非负,但是在计算机中的模运算不是这样,因此,不能把计算机程序设计中的模运算等同于数学概念中的取余数。

计算机取模运算的结果符号与被除数一致,也就是说取模运算的结果有可能为负数。
对于正数,二者计算出的结果是相等的,但是负数就不相等了。这就意味着,如果以后在使用数学中余数相关定理的时候,要注意计算机中余数的计算和数学定义不是完全一致的, 所以在计算机上,对于负数,数学定理并不完全适用。当然,对于正数,二者是没有区别的。至于为什么计算机上要这么实现,我想恐怕还是历史原因,最早的计算 机如果这样计算除法(取余是靠除法来完成的),那么就涉及到浮点数的计算以及取下界,这样,将比较大的降低效率,所以实现成了这样的方式,一直沿用至今。

1.  apt-get source subversion 

2.  cd subversion-xxxxx现在是1.4.6

3. 编辑 debian/rules (f.e.:  gedit debian/rules )


ENABLE_JAVAHL=no

修改为:

ENABLE_JAVAHL=yes

并且将rules中的with-jdk的路径位置设置正确

confflags += --enable-javahl --without-jikes --with-jdk=/usr/lib/sun-j2sdk1.5.0

4.  dpkg-buildpackage 

这时候可能会报很多包没装上,一一装好就可以了,但是我装的时候遇到了这样的问题

python2.5-dev:
Depends: python2.5 (=2.5.2-2ubuntu4.1) but 2.5.2-2ubuntu5 is to be installed表明,我的机器上已经装了 2.5.2-2ubuntu5 ,但是应该装2.5.2-2ubuntu4.1

之前之所以装上了2.5.2-2ubuntu5,是因为曾经Python2.5 version 2.5.2-2ubuntu5 在hardy package tree中可用。但是现在已经删除,因为当时的测试出了问题。因此 python2.5-dev对应的版本也就不可用了,解决办法是降级,按照如下方法:

$ sudo apt-get install python2.5-minimal=2.5.2-2ubuntu4.1 python2.5=2.5.2-2ubuntu4.1

另外有一种方法,通过

$ sudo apt-get install libsvn1=1.4.6* libsvn-java=1.4.6* 来降级,我当时是1.5.1 subclipse工作不正常。

ubuntu中eclipse的svn plugin建议使用JNI方式,而eclipse中的packages中的libsvn-javahl的版本有没有达到要求(1.3.1 or later)因此会有一些包冲突出现。我大概的解决方案就是,到http://packages.ubuntu.com/hardy/libsvn1 这个地址下面分别把libsvn1,libsvn-java,libsvn-javahl重新安装一遍。

在ubuntu 8.10下面,无法降级javahl到1.4.1了,那么我们可以把eclipse里面的subeclipse升级为如下地址:
http://subclipse.tigris.org/update_1.4.x/

方法1:出自:http://www.lostk.com/blog/virtualbox_install_and_network_config/

一、安装

1. 下载安装包。建议下载 Deb 包

2. 准备依赖。VirtualBox 的正常使用需要 libxalan110 和 libxerces27 这两个包。所以,你要先行安装它们,可以使用下面的指令:
sudo apt-get install libxalan110 libxerces27

3. 安装编译工具及相关包。在安装过程中,要编译 VirtualBox 所用的内核模块。为此,你需要准备基本的编译工具及包,你可以使用下列指令来安装它们:
sudo apt-get install build-essential linux-headers-`uname -r`

4. 现在,转到所保存 VirtualBox 安装包的目录,通过下面的指令来安装它:
sudo dpkg -i VirtualBox_1.x.x_Ubuntu_feisty_i386.deb
在安装的过程中,VirtualBox 会要求你接受许可协议。另外,安装程序也会创建 vboxusers 用户组,并编译所需的内核模块。
5. 现在,你还不能启动 VirtualBox,因为你的当前用户还不属于 vboxusers 用户组。你可以使用下面的指令来将当前的用户(请使用你的用户名代替指令中的“youruser”)添加到 vboxusers 用户组中:
sudo adduser youruser vboxusers

virtualbox 屏幕下移问题:
如果虚拟机的分辨率接近x的分辨率而导致部分界面在x边沿时,全屏后原来窗口管理器 title 的地方变为黑色条状区域,屏幕下移,windows的开始菜单显示在下一个桌面。
解决方法:全屏前把分辨率调小,全屏后右键把显示器分辨率调到同x一致,这样就不会有屏幕偏移。

二、桥接网络配置

一般而言,安装完VirtualBox设定网路时选择默认的NAT模式,Guest就可顺利联网了,但是这种方式比较死板,要作更有弹性的变化,应 该采用桥接模式(Bridged),这里的桥接模式就如同VMware中的Bridged模式,Host与Guest在局域网(LAN)中的地位是相等 的。

参考 virtualbox 安装后放在 VirtualBox 目录中的用户手册文件 UserManual.pdf 配置如下:

1. 在基于 Debian 和 Ubuntu 的系统上,首先要安装含有建立虚拟网络设备 ( TAP interfaces ) 的工具 uml-utilities 和桥接工具 bridge-utils:
sudo apt-get install uml-utilities
sudo apt-get install bridge-utils

为了使你的虚拟机能够访问网络接口,你必须将运行虚拟主机的用户的用户名(通常是你的ubuntu登录用户名)添加到uml-net用户组(请用你的用户名替换其中的“vboxuser”):
sudo gpasswd -a vboxuser uml-net
注意:为了使改动生效,请重新启动你的电脑。

2. 向你的 Debian 或者 ubuntu 操作系统描述你要添加的虚拟网络设备,编辑 /etc/network/interfaces:
sudo vim /etc/network/interfaces
在打开的文件后面添加下面的内容,将虚拟网络接口命名为 “tap0″,指定该接口IP配置方法为手动,并指定使用该接口的用户(请用你的用户名替换其中的 “vboxuser”):
auto tap0
iface tap0 inet manual
up ifconfig $IFACE 0.0.0.0 up
down ifconfig $IFACE down
tunctl_user vboxuser

3. 首次使用需要激活刚才建立的虚拟网络接口和网络桥:
sudo /sbin/ifup tap0
sudo /sbin/ifup br0

这个步骤只需要做一次,下次主机重新启动时,这个接口和桥将自动激活。

4. 另外还需要在 /etc/network/interfaces 中加入如下内容,建立一个名叫 “br0″ 的桥,该桥的IP配置方法为通过DHCP配置,主机中的所有网络接口,也包括tap0这个虚拟网络接口,都将建立在这个桥之上:
auto br0
iface br0 inet dhcp
bridge_ports all tap0

在这里你可以根据自己的网络状况做相应的更改,你可以使网络桥使用静态 IP:
iface br0 inet static
address 192.168.1.2
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1

5. 让 virtualbox 使用这个虚拟网络接口,启动 virtualbox,在主界面上选中要使用刚才建立的虚拟网络接口tap0的虚拟机,点“设置”,在弹出的窗口中选“网络”,选中其中一块网卡(通常为 “网络适配器 0”),选中“启用网络适配器”,“连接到”后面选 “Host Interface”,选中“接入网线”,然后在“主机网络界面名称”中填入刚才建立的虚拟网络接口的名字 “tap0″,确定。同样的你也可以使用 VBoxManage 的命令行工具(将 “My VM” 换成你的虚拟机名字 ):
VBoxManage modifyvm "My VM" -hostifdev1 tap0\

最后,配置主机和虚拟机的网络,使主机和虚拟机在同一个网段,这样主机和虚拟机就成了局域网中地位相同的两台机器了,可以互相访问了。

三、撤销网络桥
1. 禁用网桥和虚拟网卡:
sudo /sbin/ifdown br0
sudo /sbin/ifdown tap0

2. 将前面修改的 /etc/network/interfaces 文件还原。

方法2:出自:http://jim19770812.blogspot.com/2008/06/ubuntuvirtualbox_24.html

名词解释

Host:运行虚拟主机的操作系统,我的就是ubuntu 8.04
Guest:虚拟的操作系统,我的是windows xp sp2
NAT:网络地址转换,通过NAT,可以让Guest做为host的一个程序,通过某某端口来访问外部网络,NAT会自动的把发向这个端口的包转发给Guest。

virtualbox默认的网络连接方式只有NAT方式,这种方式如果通过Host上外网上网没问题,但如果希望为Guest分配一个独立的IP地址就没法访问Host和外网了,比较的不方便。本人参考了VirtualBox的帮助之后完美的解决了这个问题,现记录如下。
1.安装bridge-utils包

jim@jim-laptop:~$ sudo apt-get install bridge-utils

2.增加虚拟网桥

jim@jim-laptop:~$ sudo gedit /etc/network/interfaces

加入如下内容

#virtual box network bridge
auto br0
iface br0 inet dhcp
bridge_ports eth0

之后重启网络

jim@jim-laptop:~$ sudo /etc/init.d/networking restart
* Reconfiguring network interfaces...
There is already a pid file /var/run/dhclient.eth0.pid with pid 4284
killed old client process, removed PID file
Internet Systems Consortium DHCP Client V3.0.6
Copyright 2004-2007 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/sw/dhcp/

Listening on LPF/eth0/00:16:d3:32:4f:5f
Sending on   LPF/eth0/00:16:d3:32:4f:5f
Sending on   Socket/fallback
DHCPRELEASE on eth0 to 192.168.0.1 port 67
/usr/bin/poff: No pppd is running.  None stopped.
There is already a pid file /var/run/dhclient.eth0.pid with pid 134519072
Internet Systems Consortium DHCP Client V3.0.6
Copyright 2004-2007 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/sw/dhcp/

Listening on LPF/eth0/00:16:d3:32:4f:5f
Sending on   LPF/eth0/00:16:d3:32:4f:5f
Sending on   Socket/fallback
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 4
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 7
DHCPOFFER of 192.168.0.4 from 192.168.0.1
DHCPREQUEST of 192.168.0.4 on eth0 to 255.255.255.255 port 67
DHCPACK of 192.168.0.4 from 192.168.0.1
bound to 192.168.0.4 -- renewal in 933216184 seconds.
* Stopping NTP server ntpd
...done.
dsl-provider: ERROR while getting interface flags: No such device
Plugin rp-pppoe.so loaded.
* Stopping NTP server ntpd
...done.

Waiting for br0 to get ready (MAXWAIT is 32 seconds).
* Starting NTP server ntpd
...done.
* Starting NTP server ntpd
...done.
Internet Systems Consortium DHCP Client V3.0.6
Copyright 2004-2007 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/sw/dhcp/

Listening on LPF/br0/00:16:d3:32:4f:5f
Sending on   LPF/br0/00:16:d3:32:4f:5f
Sending on   Socket/fallback
DHCPREQUEST of 192.168.0.2 on br0 to 255.255.255.255 port 67
DHCPNAK from 192.168.0.1
DHCPDISCOVER on br0 to 255.255.255.255 port 67 interval 6
DHCPOFFER of 192.168.0.4 from 192.168.0.1
DHCPREQUEST of 192.168.0.4 on br0 to 255.255.255.255 port 67
DHCPACK of 192.168.0.4 from 192.168.0.1
bound to 192.168.0.4 -- renewal in 933216154 seconds.
[ OK ]
jim@jim-laptop:~$  * Stopping NTP server ntpd
...done.
* Starting NTP server ntpd
...done.

这时候执行ifconfig可以看到刚才加的br0网桥

jim@jim-laptop:~$ ifconfig
br0       Link encap:以太网  硬件地址 00:16:d3:32:4f:5f
inet 地址:192.168.0.4  广播:192.168.0.255  掩码:255.255.255.0
inet6 地址: fe80::216:d3ff:fe32:4f5f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST  MTU:1500  跃点数:1
接收数据包:47 错误:0 丢弃:0 过载:0 帧数:0
发送数据包:77 错误:0 丢弃:0 过载:0 载波:0
碰撞:0 发送队列长度:0
接收字节:4028 (3.9 KB)  发送字节:11339 (11.0 KB)

eth0      Link encap:以太网  硬件地址 00:16:d3:32:4f:5f
inet6 地址: fe80::216:d3ff:fe32:4f5f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST  MTU:1500  跃点数:1
接收数据包:984 错误:0 丢弃:0 过载:0 帧数:0
发送数据包:1159 错误:0 丢弃:0 过载:0 载波:0
碰撞:0 发送队列长度:1000
接收字节:322583 (315.0 KB)  发送字节:205474 (200.6 KB)
中断:19

注意:因为选择的是dhcp,所以网桥的ip是192.168.0.4,这是系统自动分配的,不通的网段ip也会不同

3.创建一个Host networking interface
语法是这样的

VBoxAddIF <用户名> <网桥设备名>

我执行的代码如下:

jim@jim-laptop:~$ sudo VBoxAddIF vbox0 jim br0
VirtualBox host networking interface creation utility, version 1.6.2
(C) 2005-2007 Sun Microsystems, Inc.
All rights reserved.

Creating the permanent host networking interface “vbox0″ for user jim.

再次查看一下网络配置

jim@jim-laptop:~$ ifconfig
br0       Link encap:以太网  硬件地址 00:16:d3:32:4f:5f
inet 地址:192.168.0.4  广播:192.168.0.255  掩码:255.255.255.0
inet6 地址: fe80::216:d3ff:fe32:4f5f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST  MTU:1500  跃点数:1
接收数据包:139 错误:0 丢弃:0 过载:0 帧数:0
发送数据包:113 错误:0 丢弃:0 过载:0 载波:0
碰撞:0 发送队列长度:0
接收字节:8517 (8.3 KB)  发送字节:15183 (14.8 KB)

vbox0     Link encap:以太网  硬件地址 00:ff:f8:de:a4:08
inet6 地址: fe80::2ff:f8ff:fede:a408/64 Scope:Link
UP BROADCAST RUNNING MULTICAST  MTU:1500  跃点数:1
接收数据包:0 错误:0 丢弃:0 过载:0 帧数:0
发送数据包:0 错误:0 丢弃:37 过载:0 载波:0
碰撞:0 发送队列长度:500
接收字节:0 (0.0 B)  发送字节:0 (0.0 B)

两个虚拟设备都已经有了

4.配置VirtualBox
打开VirtualBox,找到设置->网络
选择启用网络连接2,配置如下

网路连接方式:Host Interface
Interface Name : vbox0

配置如下图所示

出自:

http://www.mydigitallife.info/2006/04/23/freebsd-apache-http-accept-filter-error/

When Apache web server is starting up in FreeBSD system, Apache loads succcessfully and web server functioning properly, but the following warning error occurs:

[warn] (2)No such file or directory:
Failed to enable the ‘httpready’ Accept Filter

The resolution to the above problem is to a accf_http module, which function is to buffer incoming connections until a certain complete HTTP requests arrive, into FreeBSD kernel by using kernel linker:

kldload accf_http

To permanently load enable HTTP Accept Filter FreeBSD kernel module (accf_http), add the following line into /boot/loader.conf:

accf_http_load=”YES”

Note: The default settings is located in /boot/defaults/loader.cnf. To see the related settings about accf, use:

grep accf /boot/defaults/loader.conf

which will returns:

accf_data_load=”NO” # Wait for data accept filter
accf_http_load=”NO” # Wait for full HTTP request accept filter

最近整理了一下在NetBSD下建立Raid1的过程,当时建立bsdchina.org服务器的时候由于时间仓促没有将整个的制作过程记录下来,前两天抽时间在虚机中重新做了这个过程,跟大家分享。

起因:现在一些SATA的主板上自带的Raid控制器并不能被NetBSD识别,因此如何将双硬盘制作为Raid1从而提高数据安全性成为一个比较头疼的问题,最终在bsdchina.org服务器上,采用了软件模拟Raid控制器的方式来实现Raid1。使用的软件是NetBSD标准安装中自带的RaidFrame软件。

过程:

1 在VMware中建立虚拟机,两块硬盘大小10G。
2 安装NetBSD4.0系统至disk0。
3 启动系统后,dmesg|grep -i raid 检查内核是否支持RaidFrame,如果输出类似下面的格式则表示内核有RaidFrame支持。
# dmesg|grep -i raid
Kernelized RAIDframe activated
4 如果没有RaidFrame支持,请先编译内核使其支持RaidFrame。
5 执行df,查看硬盘使用情况。
2.bmp

disklabel -r wd0

3.bmp

 # fdisk /dev/rwd0d
4.bmp

 通过上面的一些命令,可以帮助我了解目前虚机中第一块硬盘的情况,接下来要在第二块硬盘上做一些准备工作,核心的操作就是将第二块硬盘wd1中的全部扇区用0填充,命令如下:
# dd if=/dev/zero of=/dev/rwd1d bs=8k count=1


执行完毕后,通过如下的命令来确认第二块硬盘上的mbr和全部的数据已经被清空。
# disklabel -r wd1
6.bmp
观察上面的信息,offset都为0证明全部分区没有数据占用。由此可以确定硬盘上既没有数据也没有mbr引导记录。
接下来,我将第一块硬盘上的mbr中的引导记录传送至第二块硬盘。在此之前,先将第二块硬盘wd1设置为可启动。
# fdisk -0ua /dev/rwd1d
按照如下的内容进行回答。

fdisk: primary partition table invalid, no magic in sector 0
Disk: /dev/rwd1d
NetBSD disklabel disk geometry:
cylinders: 19386, heads: 16, sectors/track: 63 (1008 sectors/cylinder)
total sectors: 19541088
BIOS disk geometry:
cylinders: 1023, heads: 255, sectors/track: 63 (16065 sectors/cylinder)
total sectors: 19541088
Do you want to change our idea of what BIOS thinks? [n]Partition 0:The data for partition 0 is:sysid: [0..255 default: 169]
start: [0..1216cyl default: 63, 0cyl, 0MB]
size: [0..1216cyl default: 19541025, 1216cyl, 9542MB]
bootmenu: []
Do you want to change the active partition? [n] y
Choosing 4 will make no partition active.
active partition: [0..4 default: 0] 0
Are you happy with this choice? [n] y

We haven’t written the MBR back to disk yet.  This is your last chance.
Partition table:
0: NetBSD (sysid 169)
start 63, size 19541025 (9542 MB, Cyls 0-1216/96/1), Active
1:
2:
3:
Bootselector disabled.
Should we write new partition table? [n] y
接下来查看第二块硬盘的数据情况:
# disklabel -r -e -I wd1
输出类似如下所示:

type: unknown
disk: Disk1
label:
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 16
sectors/cylinder: 1008
cylinders: 19386
total sectors: 19541088
[…snip…]
16 partitions:
#        size    offset     fstype [fsize bsize cpg/sgs]
a:  19541025        63       RAID                     # (Cyl.      0*-19385)
c:  19541025        63     unused      0     0        # (Cyl.      0*-19385)
d:  19541088         0     unused      0     0        # (Cyl.      0 -19385)
可以看到在a:区的offset为63,那么a区前面的部分便是mbr的引导记录,这表示引导记录已经传送至wd1。

接下来建立Raidframe设备的配置文件:
# vi /var/tmp/raid0.conf
START array
1 2 0
START disks
/dev/wd9a
/dev/wd1a
START layout
128 1 1 1
START queue
fifo 100
我们看到配置文件中写了wd9这个设备,这个设备对于系统来说是一个虚拟设备(psudeo设备),我们最后会用wd0替换掉它。
尽管如此,还是必须在系统中建立这个设备节点。
# cd /dev
# sh MAKEDEV wd9
# cd -

下一步,将使用这个配置文件来建立raid设备,命令如下:
# raidctl -v -C /var/tmp/raid0.conf raid0
输出如下:
8.bmp
正如预料那样,在wd9这个设备上出现错误,当它不存在就好了。
初始化硬盘数据同步:
# raidctl -v -i raid0
Initiating re-write of parity
# tail -1 /var/log/messages
raid0: Error re-writing parity!
 
查看同步结果:
# raidctl -v -s raid0
输出:
9.bmp

 接下来要用wd0来替换掉wd9这个设备,这个环节稍微有些复杂,需要进行一定的计算操作,为了简单起见,我的硬盘分区中除了swap分区便是一个大分区,一共只有2个分区。

执行如下命令来查看刚刚建立的raid设备情况:
# disklabel -r -e -I raid0
输出类似如下信息:
type: RAID
disk: raid
label: fictitious
flags:
bytes/sector: 512
sectors/track: 128
tracks/cylinder: 8
sectors/cylinder: 1024
cylinders: 19082
total sectors: 19540864
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0 # microseconds
track-to-track seek: 0 # microseconds
drivedata: 0
#        size    offset     fstype [fsize bsize cpg/sgs]
a:  19015680         0     4.2BSD      0     0     0  # (Cyl.      0 - 18569)
b:    525184  19015680       swap                     # (Cyl.  18570 - 19082*)
d:  19540864         0     unused      0     0        # (Cyl.      0 - 19082*)
可以看出swap大小为525兆。
接下来格式化分区为4.2BSD FFSv1 File System
# newfs -O 1 /dev/rraid0a
接下来检查硬盘
# fsck -fy /dev/rraid0a

下面,需要建立真实的swap分区,刚刚看到的swap分区大小实际上是raid0这个设备的。由于raid0b作为swap分区,但是这个分区是无法作为真正的swap分区使用,因为如果系统挂掉了,进程调度停止了,那么是无法将dump出来的信息存储到raid0b这个分区的,因此这里采取了一个hack的方法,需要我们自己计算大小从而对分区表进行修改,使得我们在真实的wd1这个设备上建立一个分区大小使之与raid0b这个分区所标示的分区大小重叠一致。这步必须小心。
接下来再回顾一下刚刚的raid0分区情况以及wd1的分区情况。
  # disklabel raid0  8 partitions:
#        size    offset     fstype  [fsize bsize cpg/sgs]
a:  19015680         0     4.2BSD   1024  8192    64
b:    525184  19015680     swap
d:  19540864         0     unused      0     0     0
  # disklabel wd1  8 partitions:
#        size    offset     fstype  [fsize bsize cpg/sgs]
a:  19541025        63     RAID
c:  19541025        63     unused      0     0
d:  19541088         0     unused      0     0

在所有的RAID设备中都保留有64个block大小的预留区域来保存RAID的一些结构信息。因此我们使用dc来计算实际的swap分区的偏移大小。将那块区域空出来为raid0b分区所用。

# dc   63 # offset of wd1a   64 # RF_PROTECTED_SECTORS   +   19015680 # offset of raid0b   +p   19015807 # offset of swap within wd1   q

接下来编辑现有的wd1的分区表信息。
# disklabel wd1 > disklabel.wd1
# vi disklabel.wd1
  8 partitions:
#        size    offset     fstype  [fsize bsize cpg/sgs]
a:  19541025        63       RAID
b:    525184  19015807       swap
c:  19541025        63     unused      0     0
d:  19541088         0     unused      0     0
offset为上面计算出来的真实偏移量大小。
然后便可以应用这个修改后的配置了。
# disklabel -R -r wd1 disklabel.wd1

现在raid0的配置已经完成,但是raid0这个设备上还没有系统,接下来将wd0上的系统迁移到raid0a这个分区上:
# mount /dev/raid0a /mnt
# df -h /mnt
Filesystem    Size     Used     Avail Capacity  Mounted on
/dev/raid0a   9.0G     2.0K      8.6G     0%    /mnt
# cd /; pax -v -X -rw -pe / /mnt
然后编辑fstab文件,使用# vi /mnt/etc/fstab/dev/raid0a  /  ffs  rw  1  1
/dev/raid0b  none  swap  sw  0  0
/dev/wd0b  none  swap  dp  0  0
kernfs    /kern  kernfs  rw
procfs    /proc  procfs  rw

# vi /mnt/etc/rc.conf
swapoff=YES
这是为了防止重启后出现同步错误。在wd1硬盘上安装启动文件。
# /usr/sbin/installboot -o timeout=30 -v /dev/rwd1a /usr/mdec/bootxx_ffsv1通过下面的命令将raid0设置成可自动配置。
# raidctl -v -A root raid0
raid0: Autoconfigure: Yes
raid0: Root: Yes
# tail -2 /var/log/messages
raid0: New autoconfig value is: 1
raid0: New rootpartition value is: 1
# raidctl -v -s raid0
[…snip…]
Autoconfig: Yes
Root partition: Yes
Last configured as: raid0
[…snip…]
# shutdown -r now
一定要用shutdown重启,而不要使用reboot。重启后通过下面的命令查看raid0设备情况。

#
egrep -i “raid|root” /var/run/dmesg.boot
raid0: RAID Level 1
raid0: Components: component0[**FAILED**] /dev/wd1a
raid0: Total Sectors: 19540864 (9541 MB)
boot device: raid0
root on raid0a dumps on raid0b
root file system type: ffs
# df -h
Filesystem    Size     Used     Avail Capacity  Mounted on
/dev/raid0a   8.9G     196M      8.3G     2%    /
kernfs        1.0K     1.0K        0B   100%    /kern
# swapctl -l
Device      1K-blocks     Used    Avail Capacity  Priority
/dev/raid0b    262592        0   262592     0%    0
# raidctl -s raid0
Components:
component0: failed
/dev/wd1a: optimal
No spares.
component0 status is: failed.  Skipping label.
Component label for /dev/wd1a:
Row: 0, Column: 1, Num Rows: 1, Num Columns: 2
Version: 2, Serial Number: 2004082401, Mod Counter: 65
Clean: No, Status: 0
sectPerSU: 128, SUsPerPU: 1, SUsPerRU: 1
Queue size: 100, blocksize: 512, numBlocks: 19540864
RAID Level: 1
Autoconfig: Yes
Root partition: Yes
Last configured as: raid0
Parity status: DIRTY
Reconstruction is 100% complete.
Parity Re-write is 100% complete.
Copyback is 100% complete.

可以看出wd9那个设备还是error状态,接下来我们就需要将wd0这个设备替换掉wd9这个根本不存在的设备。在这之前将所有的两个硬盘的分区表、disklabel等信息进行备份。
# disklabel -r wd1 > /tmp/disklabel.wd1
# disklabel -R -r wd0 /tmp/disklabel.wd1
# disklabel -r wd0 > /tmp/disklabel.wd0
# disklabel -r wd1 > /tmp/disklabel.wd1
# diff /tmp/disklabel.wd0 /tmp/disklabel.wd1
# fdisk /dev/rwd0 > /tmp/fdisk.wd0
# fdisk /dev/rwd1 > /tmp/fdisk.wd1
# diff /tmp/fdisk.wd0 /tmp/fdisk.wd1
# mkdir /root/RFbackup
#
cp -p /tmp/{disklabel,fdisk}* /root/RFbackup

将wd0a设备添加至raid0
# raidctl -v -a /dev/wd0a raid0
/netbsd: Warning: truncating spare disk /dev/wd0a to 241254528 blocks
# raidctl -v -s raid0
Components:
component0: failed
/dev/wd1a: optimal
Spares:
/dev/wd0a: spare
[…snip…]
# raidctl -F component0 raid0
RECON: initiating reconstruction on col 0 -> spare at col 2
11% |****                                   | ETA:    04:26 \

#
raidctl -S raid0
Reconstruction is 0% complete.
Parity Re-write is 100% complete.
Copyback is 100% complete.
Reconstruction status:
17% |******                                 | ETA: 03:08 -
# raidctl -v -s raid0
Components:
component0: spared
/dev/wd1a: optimal
Spares:
/dev/wd0a: used_spare
[…snip…] # /usr/sbin/installboot -o timeout=15 -v /dev/rwd0a /usr/mdec/bootxx_ffsv1# shutdown -r now
完成。
最后可以考虑测试一下我们的swap分区设置的是否正确,以免将来真的发生kernel panic的时候dump出来的文件造成我们的生产数据丢失。
具体方法如下:
在系统中按下Ctrl+Alt+Esc。进入内核调试模式输入命令 sync 或者 reboot 0×104 。这会强制将当前的内核映像存储到dump区域(wd0b)。如果一切都正常,那么我们的swap计算是正确的,如果失败了,那么好好检查一下,重新来过吧。:)

vino的密碼是放在gconf xml裡面, 而且是用base64編碼方式存放
所以我的作法是…先到online的Base64 Encoder and Decoder將自己的密碼encode後,
然後再下

gconftool-2 -s -t string /desktop/gnome/remote_access/vnc_password 編碼後的密碼

這樣一來就可以再次用vnc連上遠端電腦了

以密碼”test”為例 , 經過base64編碼得到”dGVzdA==”

gconftool-2 -s -t string /desktop/gnome/remote_access/vnc_password dGVzdA==

- Next »

京ICP备05029144