Dec 24 2008

debian下面的/etc/network/interfaces配置文件

Category: 技术ssmax @ 17:00:12

今天做wake up on lan,要用到ethtool设置网卡状态,但是系统关机的过程中会重设这个状态,所以放在网卡关闭脚本的最后,就是 interfaces里面的post-down,这里可以执行任何脚本。。

man 5 interfaces

INTERFACES(5) File formats INTERFACES(5)

NAME
/etc/network/interfaces – network interface configuration for ifup and
ifdown

DESCRIPTION
/etc/network/interfaces contains network interface configuration infor‐
mation for the ifup(8) and ifdown(8) commands. This is where you con‐
figure how your system is connected to the network.

Lines starting with ‘#’ are ignored. Note that end-of-line comments are
NOT supported, comments must be on a line of their own.

A line may be extended across multiple lines by making the last charac‐
ter a backslash.

The file consists of zero or more “iface”, “mapping”, “auto” and
“allow-” stanzas. Here is an example.

auto lo eth0
allow-hotplug eth1

iface lo inet loopback

mapping eth0
script /usr/local/sbin/map-scheme
map HOME eth0-home
map WORK eth0-work

iface eth0-home inet static
address 192.168.1.1
netmask 255.255.255.0
up flush-mail

iface eth0-work inet dhcp

iface eth1 inet dhcp

Lines beginning with the word “auto” are used to identify the physical
interfaces to be brought up when ifup is run with the -a option. (This
option is used by the system boot scripts.) Physical interface names
should follow the word “auto” on the same line. There can be multiple
“auto” stanzas. ifup brings the named interfaces up in the order
listed.

Lines beginning with “allow-” are used to identify interfaces that
should be brought up automatically by various subsytems. This may be
done using a command such as “ifup –allow=hotplug eth0 eth1”, which
will only bring up eth0 or eth1 if it is listed in an “allow-hotplug”
line. Note that “allow-auto” and “auto” are synonyms.

Stanzas beginning with the word “mapping” are used to determine how a
logical interface name is chosen for a physical interface that is to be
brought up. The first line of a mapping stanza consists of the word
“mapping” followed by a pattern in shell glob syntax. Each mapping
stanza must contain a script definition. The named script is run with
the physical interface name as its argument and with the contents of
all following “map” lines (without the leading “map”) in the stanza
provided to it on its standard input. The script must print a string on
its standard output before exiting. See /usr/share/doc/ifupdown/exam‐
ples for examples of what the script must print.

Mapping a name consists of searching the remaining mapping patterns and
running the script corresponding to the first match; the script outputs
the name to which the original is mapped.

ifup is normally given a physical interface name as its first
non-option argument. ifup also uses this name as the initial logical
name for the interface unless it is accompanied by a suffix of the
form =LOGICAL, in which case ifup chooses LOGICAL as the initial logi‐
cal name for the interface. It then maps this name, possibly more than
once according to successive mapping specifications, until no further
mappings are possible. If the resulting name is the name of some
defined logical interface then ifup attempts to bring up the physical
interface as that logical interface. Otherwise ifup exits with an
error.

Stanzas defining logical interfaces start with a line consisting of the
word “iface” followed by the name of the logical interface. In simple
configurations without mapping stanzas this name should simply be the
name of the physical interface to which it is to be applied. (The
default mapping script is, in effect, the echo command.) The interface
name is followed by the name of the address family that the interface
uses. This will be “inet” for TCP/IP networking, but there is also
some support for IPX networking (“ipx”), and IPv6 networking (“inet6”).
Following that is the name of the method used to configure the inter‐
face.

Additional options can be given on subsequent lines in the stanza.
Which options are available depends on the family and method, as
described below. Additional options can be made available by other
Debian packages. For example, the wireless-tools package makes avail‐
able a number of options prefixed with “wireless-” which can be used to
configure the interface using iwconfig(8). (See wireless(7) for
details.)

Options are usually indented for clarity (as in the example above) but
are not required to be.

IFACE OPTIONS
The following “command” options are available for every family and
method. Each of these options can be given multiple times in a single
stanza, in which case the commands are executed in the order in which
they appear in the stanza. (You can ensure a command never fails by
suffixing “|| true”.)

pre-up command
Run command before bringing the interface up. If this command
fails then ifup aborts, refraining from marking the interface as
configured, prints an error message, and exits with status 0.
This behavior may change in the future.

up command

post-up command
Run command after bringing the interface up. If this command
fails then ifup aborts, refraining from marking the interface as
configured (even though it has really been configured), prints
an error message, and exits with status 0. This behavior may
change in the future.

down command

pre-down command
Run command before taking the interface down. If this command
fails then ifdown aborts, marks the interface as deconfigured
(even though it has not really been deconfigured), and exits
with status 0. This behavior may change in the future.

post-down command
Run command after taking the interface down. If this command
fails then ifdown aborts, marks the interface as deconfigured,
and exits with status 0. This behavior may change in the
future.

There exists for each of the above mentioned options a directory
/etc/network/if-

All of these commands have access to the following environment vari‐
ables.

IFACE physical name of the interface being processed

LOGICAL
logical name of the interface being processed

ADDRFAM
address family of the interface

METHOD method of the interface (e.g., static)

MODE start if run from ifup, stop if run from ifdown

PHASE as per MODE, but with finer granularity, distinguishing the pre-
up, post-up, pre-down and post-down phases.

VERBOSITY
indicates whether –verbose was used; set to 1 if so, 0 if not.

PATH the command search path: /usr/local/sbin:/usr/local/bin:‐
/usr/sbin:/usr/bin:/sbin:/bin

Additionally, all options given in an interface definition stanza are
exported to the environment in upper case with “IF_” prepended and with
hyphens converted to underscores and non-alphanumeric characters dis‐
carded.

INET ADDRESS FAMILY
This section documents the methods available in the inet address fam‐
ily.

The loopback Method
This method may be used to define the IPv4 loopback interface.

Options

(No options)

The static Method
This method may be used to define ethernet interfaces with statically
allocated IPv4 addresses.

Options

address address
Address (dotted quad) required

netmask netmask
Netmask (dotted quad) required

broadcast broadcast_address
Broadcast address (dotted quad)

network network_address
Network address (dotted quad) required for 2.0.x kernels

metric metric
Routing metric for default gateway (integer)

gateway address
Default gateway (dotted quad)

pointopoint address
Address of other end point (dotted quad). Note the
spelling of “point-to”.

media type
Medium type, driver dependent

hwaddress class address
Hardware Address. class is one of ether, ax25, ARCnet or
netrom. address is dependent on the above choice.

mtu size
MTU size

The manual Method
This method may be used to define interfaces for which no configuration
is done by default. Such interfaces can be configured manually by means
of up and down commands or /etc/network/if-*.d scripts.

Options

(No options)

The dhcp Method
This method may be used to obtain an address via DHCP with any of the
tools: dhclient, pump, udhcpc, dhcpcd. (They have been listed in their
order of precedence.) If you have a complicated DHCP setup you should
note that some of these clients use their own configuration files and
do not obtain their configuration information via ifup.

Options

hostname hostname
Hostname to be requested (pump, dhcpcd, udhcpc)

leasehours leasehours
Preferred lease time in hours (pump)

leasetime leasetime
Preferred lease time in seconds (dhcpcd)

vendor vendor
Vendor class identifier (dhcpcd)

client client
Client identifier (dhcpcd, udhcpc)

hwaddress class address
Hardware Address. class is one of ether, ax25, ARCnet or
netrom. address is dependent on this choice.

The bootp Method
This method may be used to obtain an address via bootp.

Options

bootfile file
Tell the server to use file as the bootfile.

server address
Use the IP address address to communicate with the
server.

hwaddr addr
Use addr as the hardware address instead of whatever it
really is.

The ppp Method
This method uses pon/poff to configure a PPP interface. See those com‐
mands for details.

Options

provider name
Use name as the provider (from /etc/ppp/peers).

The wvdial Method
This method uses wvdial to configure a PPP interface. See that command
for more details.

Options

provider name
Use name as the provider (from /etc/ppp/peers).

IPX ADDRESS FAMILY
This section documents the methods available in the ipx address family.

The static Method
This method may be used to setup an IPX interface. It requires the
ipx_interface command.

Options

frame type
type of ethernet frames to use (e.g. 802.2)

netnum id
Network number

The dynamic Method
This method may be used to setup an IPX interface dynamically.

Options

frame type
type of ethernet frames to use (e.g. 802.2)

INET6 ADDRESS FAMILY
This section documents the methods available in the inet6 address fam‐
ily.

The loopback Method
This method may be used to define the IPv6 loopback interface.

Options

(No options)

The static Method
This method may be used to define interfaces with statically assigned
IPv6 addresses.

Options

address address
Address (colon delimited) required

netmask mask
Netmask (number of bits, eg 64) required

gateway address
Default gateway (colon delimited)

media type
Medium type, driver dependent

hwaddress class address
Hardware Address. class is one of ether, ax25, ARCnet or
netrom. address is dependent on this choice.

mtu size
MTU size

The manual Method
This method may be used to define interfaces for which no configuration
is done by default. Such interfaces can be configured manually by means
of up and down commands or /etc/network/if-*.d scripts.

Options

(No options)

The v4tunnel Method
This method may be used to setup an IPv6-over-IPv4 tunnel. It requires
the ip command from the iproute package.

Options

address address
Address (colon delimited)

netmask mask
Netmask (number of bits, eg 64)

endpoint address
Address of other tunnel endpoint (IPv4 dotted quad)
required

local address
Address of the local endpoint (IPv4 dotted quad)

gateway address
Default gateway (colon delimited)

ttl time
TTL setting

KNOWN BUGS/LIMITATIONS
The ifup and ifdown programs work with so-called “physical” interface
names. These names are assigned to hardware by the kernel. Unfortu‐
nately it can happen that the kernel assigns different physical inter‐
face names to the same hardware at different times; for example, what
was called “eth0” last time you booted is now called “eth1” and vice
versa. This creates a problem if you want to configure the interfaces
appropriately. A way to deal with this problem is to use mapping
scripts that choose logical interface names according to the properties
of the interface hardware. See the get-mac-address.sh script in the
examples directory for an example of such a mapping script. See also
Debian bug #101728.

It is not currently possible to divide up /etc/network/interfaces into
multiple files. A feature that would make this possible is some sort
of inclusion directive. No such feature exists in the current ifupdown
program. For more information see Debian bug #159884.

AUTHOR
The ifupdown suite was written by Anthony Towns . This manpage was contributed by Joey Hess
.

SEE ALSO
ifup(8), iwconfig(8), run-parts(8).

For advice on configuring this package read the Network Configuration
chapter of the Debian Reference manual, available at
http://www.debian.org/doc/manuals/reference/ch-gateway.en.html or in
the debian-reference-en package.

Examples of how to set up interfaces can be found in
/usr/share/doc/ifupdown/examples/network-interfaces.

ifupdown 5 April 2004 INTERFACES(5)


Dec 23 2008

substring返回类型在mysql驱动 3.x 和 5.x中的区别

Category: 技术ssmax @ 17:16:52

tnnd,有人竟然用jdbcType来决定mysql查询返回的对象类型。。。但是mysql驱动也在3.x -> 5.x 这个升级过程中改变了一点,造成jdbcType来判断就有问题了。。。

ResultSet rs = stmt.executeQuery(“select substring(now(),12,2) as gtime;”);
ResultSetMetaData rsmd = rs.getMetaData();
for(int i=1; i<=rsmd.getColumnCount(); i++) { System.out.print(rsmd.getColumnName(i)); System.out.print("::"); System.out.print(rsmd.getColumnType(i)); System.out.print("::"); System.out.print(rsmd.getColumnTypeName(i)); System.out.print("::"); System.out.println(); } 这样子,在3.x的驱动里面,会认为: gtime::12::VARCHAR 但是在 5.x的驱动里面,就会认为这个是: gtime::-3::VARBINARY jdbcType判断有有问题了,很无奈啊。。。虽然有办法,但是要改代码, select cast(substring(now(),12,2) as CHAR(2)) as gtime 这样子就可以了,但是效率肯定有点影响,懒得改了,只有升级到mysql 3.1的最新版算了,不用5.x了


Dec 19 2008

ipv6的一点笔记

Category: 技术ssmax @ 16:03:56

昨天帮别人搞ipv6的代理服务器,要求是内网ipv6的主机能访问,但是出去的时候要是ipv4的,其实就是一个只有ipv6的内网想正常访问现在的ipv4的系统了。
squid 3.1开始就集成了ipv6的代码,而且还是在这两种协议中切换,如果域名有AAAA解释的就用ipv6,只有A的就用ipv4了,哈哈,本来是十分简单的东西,但是自己对ipv6并不是太熟悉,所以还是搞了半天。。。

首先就是ipv6的格式了,ifconfig 一般就可以看到
inet6 addr: fe80::212:3fff:fe24:f258/64 Scope:Link

这个inet6就是默认配置上去的ipv6地址了,但是没有路由,所以ipv6只能从本机访问了。
ipv6一般就是6段,每段是4个十六进制数
而缩略符号可以代表任意多个0000段,但是在一个地址里面只能出现一次
比如 fe80::212:3fff:fe24:f258 就是 fe80:0000:212:3fff:fe24:f258

而本机地址 ::1 就是 0000:0000:0000:0000:0000:1

ipv6这东西,由于规则不同,基本就和ipv4不兼容,各个软件都有自己一套转换方法,但是实际上的时候还是自己定义路由的,没有什么全球性的网络,所以还是和当前的ipv4系统是完全独立出来了。

一些基本命令在ipv6下面的使用
比如ping命令,ipv6下面就有个ping6的命令
但是这个命令一定要加上指定的网卡端口,否则就会出错。。。
ping6 -I eth0 fe80::212:3fff:fe24:f258
PING fe80::212:3fff:fe24:f258(fe80::212:3fff:fe24:f258) from fe80::212:3fff:fe24:f258 eth0: 56 data bytes
64 bytes from fe80::212:3fff:fe24:f258: icmp_seq=1 ttl=64 time=0.030 ms
64 bytes from fe80::212:3fff:fe24:f258: icmp_seq=2 ttl=64 time=0.019 ms

另外一个有用的命令就是telnet了
比如要连接3128端口
telnet -6 fe80::212:3fff:fe24:f258%eth0 80

而这里的%eth0 也是制定网卡设备了,和ping一样的问题。


Dec 18 2008

http 代理的两种模式

Category: 技术ssmax @ 17:38:00

今天帮别人做代理,用squid来做,以前一直都是用来做反向代理,其实正向代理设置也基本一样。。。

代理有两种模式,一种直接就是http代理,另外一种就是CONNECT 代理
第一种方式:
发包的方式是改变http的GET头:

浏览器的请求包模式应该是
GET http://www.163.com/ HTTP/1.1
Accept: */*
Proxy-Connection: Keep-Alive
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Maxthon; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; MAXTHON 2.0)
Host: www.163.com
Pragma: no-cache

而第二种模式,是可以建立TCP连接的,当初是为了ssl而建立的。
发包的过程是:

先发送:
CONNECT www.163.com:80 HTTP/1.1

然后代理服务器收到这个包之后,就会去和www.163.com 80建立连接

成功的话会返回:
HTTP/1.0 200 Connection established

然后客户端再发送正常的http请求:
GET / HTTP/1.1
Accept: */*
Proxy-Connection: Keep-Alive
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Maxthon; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; MAXTHON 2.0)
Host: www.163.com
Pragma: no-cache

就会拿到正常的结果了


Dec 09 2008

从netstat中统计ip连接数

Category: 技术ssmax @ 14:21:23

看看是不是有人攻击了,不过一般都看不出什么东东来的了

 

netstat -n | awk ‘{print $5}’ | awk -F: ‘{print $1}’ | sort |uniq -c|sort -n


Dec 08 2008

Intel集成显卡 AGP纹理加速不可用

Category: 技术ssmax @ 10:08:38

公司的机器,集成的X3100显卡,dxdiag报AGP纹理加速不可用,我记得以前如果真的不可用,那么玩游戏会慢很多的,更新了驱动和directx都没有解决,然后上网查了一下,在intel和微软的网站看到的标准答案

微软的说明:

即使 Dxdiag.exe 不能检测 AGP 纹理加速,AGP 纹理加速仍有可用。 某些视频适配器驱动程序实现 AGP 纹理加速和管理他们自己的 AGP 堆内存,以及执行不将其报告给 Microsoft DirectX 运行库。 Dxdiag.exe 使用 GetAvailDriverMemory 函数来查询显示驱动程序。 但是,某些视频适配器驱动程序不响应对此查询。 对于视频适配器驱动程序管理 AGP 纹理加速独立于 DirectX,游戏不受 Dxdiag.exe 失败报告 AGP 纹理加速状态。

Intel的说明:

大致的意思就是旧版(13.x)驱动回报告显卡的非本地内存,而最新的(14.x)xp下面的驱动不会报告,所以就是不可用,而vista下面的最新驱动(15.x)又可以报告了,摆明就是歧视xp用户了。

 

Graphics
AGP Texture Acceleration shows as “Not Available”
 
Symptom(s):

  • The game or application reports AGP is off or disabled.
  • Microsoft DirectX* Diagnostic Tool (dxdiag.exe) shows AGP Texture Acceleration is “Not Available” on the “Display” tab.

 

Cause:

If the graphics driver reports all of the video memory is local, the DirectX AGP Texture Acceleration setting shows “Not Available”. If some or all of the video memory reported is non-local, the AGP Texture Acceleration setting shows “Available.”

Older Intel graphics drivers (Production Versions 13.x) report all of the video memory as non-local video memory (AGP memory). Therefore, the AGP Texture Acceleration setting shows “Available.”

Newer Intel® graphics drivers (Production Versions 14.x) do not report non-local video memory. Instead all of the video memory is reported as local video memory. It is normal and expected behavior that the AGP Texture Acceleration setting shows “Not Available” on computers using newer Intel graphics drivers because non-local video memory is not being reported by the driver.

Note: With the Intel graphics drivers (Production Versions 15.x) on the Windows Vista* operating system, AGP Texture Acceleration shows as “Available.” While the Intel graphics driver still reports only local memory, Windows Vista controls the memory management and interprets the Intel graphics aperture as non-local memory. To further clarify, the graphics aperture is a contiguous virtual memory space where the Intel graphics driver initiates access to the graphics memory.

 

Solution:

Having the AGP Texture Acceleration setting as “Not Available” is a normal and expected behavior for the Intel graphics drivers (Production Versions 14.x). This setting does not need to be made available, enabled, or activated and does not affect the performance of games or 3D applications.

If you have a game or application checking for AGP or AGP Texture Acceleration, it is looking for non-local memory. In general, local video memory is usually faster than non-local. Therefore, Intel recommends contacting the game or application vendor if they have a setting or update that allows the game or application to check for local video memory first.

 

Operating System:

Windows* 2000, Windows* XP Professional, Windows* XP Home Edition, Windows* XP Tablet PC Edition, Windows* XP Media Center Edition


Dec 05 2008

rhel5 转到 centos5

Category: 技术ssmax @ 13:04:57

rhel5的yum source 不好找,还是直接用centos的方便,转换一下就好了

 

It is not hard to switch to CenOS5, just install a couple of rpm packages and your done, but you really do not have to switch. It is possible to add the CentOS repos to your yum configuration. Sample /etc/yum.repos.d/ CentOS5.repo (sample name) file below;

[CentOS5 base]
name=CentOS-5-Base
mirrorlist=http://mirrorlist.centos.org/?release=5&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=0
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

[CentOS5 updates]
name=CentOS-5-Updates
mirrorlist=http://mirrorlist.centos.org/?release=5&arch=$basearch&repo=updates
gpgcheck=0
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

[CentOS5plus]
name=CentOS-5-Plus
mirrorlist=http://mirrorlist.centos.org/?release=5&arch=$basearch&repo=centosplus
gpgcheck=0
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

Notice the CentOS5 repos are by default disabled. This is a good idea, one can enable the repos at anytime using the yum –enablerepo switch. It might be a good idea to import the CentOS5 key (see the example repo file above) and enable the gpgcheck;

rpm –import http://isoredirect.centos.org/centos/5/os/i386/RPM-GPG-KEY-CentOS-5

If you really want to switch to CentOS then download and install the;

For 64-bit based system:

http://isoredirect.centos.org/centos/5/os/x86_64/CentOS/centos-release-5-0.0.el5.centos.2.x86_64.rpm
http://isoredirect.centos.org/centos/5/os/x86_64/CentOS/centos-release-notes-5.0.0-2.x86_64.rpm

For 32-bit based system:

http://isoredirect.centos.org/centos/5/os/i386/CentOS/centos-release-5-2.el5.centos.i386.rpm
http://isoredirect.centos.org/centos/5/os/i386/CentOS/centos-release-notes-5.2-2.i386.rpm

上面的地址会经常变的,升级版本就会变,所以直接到 http://isoredirect.centos.org/centos/5/os/
里面找

A couple of additional packages might be needed but these should get you started nicely. Test install them to find out if you need to add any packages first, example;

rpm -Uvh centos-release*.rpm –test

You might want to remove the Red Hat release packages first, or you may have to use the force or replace packages switch to really install, for example;

rpm -Uvh centos-release*.rpm –force [–replacepkgs]

Of course the example repo file above would not be needed if you really switch. It would be an excellent idea to first unregister any systems from RHN before switching, this way you can re-register other systems on RHN if desired.


Dec 05 2008

ipvs debian内核

Category: 技术ssmax @ 10:51:40

最好把

CONFIG_IP_VS_TAB_BITS=12

调整成

CONFIG_IP_VS_TAB_BITS=20

这样hash表有100多w,可以顶得住大流量的情况了,哎。

如果是同版本的source,直接把/boot/config-xxx 拷贝到源代码目录下面的.config,然后修改就可以了 ,省下了下面make menuconfig的一步。

 

首先要介绍一下,通常其它操作系统的内核编译是比较繁琐的。然而,由于Debian强大的dpkg软件包管理系统,使得内核的升级、编译也变得容易很多。这篇文章将会一步一步教你如何编译自己的,带有grsecurity的Linux 2.6内核。Grsecurity是一个Linux的内核补丁,针对Linux内核的某些安全漏洞进行修补以及安全性的增强。
首先用 apg-get 自动下载并安装一些必要的软件包,包括编译内核需要的kernel-package和ncurses-dev等。如果在内核编译、制作过程中,遇到错误提示说某个软件包不存在的话,请同样使用 apt-get install 命令进行下载安装。

apt-get install build-essential kernel-package ncurses-dev fakeroot wget bzip2 make patch

cd /usr/src
wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.11.7.tar.bz2
tar -xjf linux-2.611.7.tar.bz2

请到 http://www.kernel.org 查看最新的内核版本。

之后,下载grsecurity。请注意,务必选择与内核版本相应的grsecurity版本。(grsecurity网站)

wget http://www.grsecurity.org/grsecurity-2.1.5-2.6.11.7-200504111924.patch.gz
gunzip grsecurity-2.1.5-2.6.11.7-200504111924.patch.gz

执行以下命令将新内核打上grsecurity补丁

patch -p0 < ./grsecurity-2.1.5-2.6.11.7-200504111924.patch

OK,切换到新内核的目录

cd linux-2.6.11.7

为了节省时间,请执行以下命令从现有内核中获得配置

make oldconfig

执行完此条命令后,会根据新老内核的差异情况,询问你一些问题,如果不确定的话请都是用默认(直接按回车)。

以上步骤完成后,执行内核配置程序

make menuconfig

如果你的Debian有X的话,也可以使用 make xconfig 来进行内核的配置。请自行根据实际情况进行配置,不确定的话请保持默认。

在 Security Options 中,选择 Grsecurity 并将其设置到 medium。然后根据grsecurity的官方推荐,请在 Security Options -> PaX -> PaX Control 中,将 MAC system integration 设置为 [None] 。

至此,内核的配置就算完成了。请按 ESC 多次后退出内核配置页面(在系统询问是否要保存新内核的配置时,当然要选择yes)。

执行以下命令进行新内核的生成!

make-kpkg clean
fakeroot make-kpkg –initrd –append-to-version=noobu –revision=1.0 kernel_image

fakeroot 的作用是在内核的生成过程中暂时性获取root权限。如果你直接是用root帐号操作的话,可以省略fakeroot。–append-to-version定义的是内核的软件包名字,类似 kernel-image-2.6.11.7-noobu 这样。而 –revision定义的是软件包的版本。

现在系统会开始进行新内核的生成,屏幕上会有许多文字闪过。请注意,如果生成过程中出现错误,请执行 make clean 后,用 make menuconfig 重新配置内核。一般都是仔细看错误信息,找到出错的模块,然后将其去除。

内核顺利生成完毕后,会在/usr/src目录下产生一个 deb 包。例如 kernel-image-2.6.11.7-noobu_1.0_i386.deb

 

如果用

fakeroot make-kpkg –initrd –append-to-version=noobu –revision=1.0 binary

就会生成 headers、image、manual、doc、src 所有的包。

 

执行以下命令安装新内核!^_^

dpkg -i kernel-image-2.6.11.7-noobu_1.0_i386.deb

接着Debian会安装新内核并更新Grub的配置文件。重新启动(shutdown -r now)后将会boot到新内核。

用 uname -a 看一下,是不是看到新内核的名字啦?

怎么样,在Debian上重新编译内核是不是很简单很高效呢?
(http://www.fanqiang.com)


Dec 01 2008

linux shell 获取毫秒数 计时

Category: 技术ssmax @ 18:28:39

man date


       %m     month (01..12)

       %M     minute (00..59)

       %n     a newline

       %N     nanoseconds (000000000..999999999)

       %p     locale’s equivalent of either AM or PM; blank if not known

       %P     like %p, but lower case

       %r     locale’s 12-hour clock time (e.g., 11:11:04 PM)

       %R     24-hour hour and minute; same as %H:%M

       %s     seconds since 1970-01-01 00:00:00 UTC

       %S     second (00..60)

%n就是纳秒数,%s是1970以来的秒数,如果只是想要毫秒就自己cut一下就ok了。

1秒s = 1000 毫秒ms

1毫秒ms = 1000 微秒us

1微秒us = 1000 纳秒ns

1纳秒ns = 1000 皮秒ps

1毫秒 就等于 1000 * 1000 纳秒

下面这个我是懒得cut了,直接除以以一百万就是了。

cat count.sh

START=`date +%s%N`;
sleep 3;
END=`date +%s%N`;
echo `expr \( $END – $START \) / 1000000`


Nov 26 2008

flash的crossdomain

Category: 技术ssmax @ 18:24:33

用flash写了一个测试网络质量的小东东,类似于js的http request了,flash的crossdomain没有js限制得这么严格,只要在目标地址根目录下面加一个crossdomain.xml就好了,记录一下要点:

要点1:不能出现style=”display: none” ,只要在这个里面,flash就不会运行

要点2:跨域访问,如果swf和html不在同一个域下面,以前只要通过html的域就可以了,但是现在连swf所在的域都要在corssdomain.xml中通过才行,要不还是访问不了。

要点3:crossdomain中的通配符,*.sample.com,就匹配了多级子域的了,不需要每一级都设置。

附上corssdomain.xml 的普通格式

<?xml version=”1.0″?>
<!DOCTYPE cross-domain-policy SYSTEM
http://www.adobe.com/xml/dtds/cross-domain-policy.dtd“>

<cross-domain-policy>
        <site-control permitted-cross-domain-policies=”master-only”/>
        <allow-access-from domain=”*.xxx.com”/>
        <allow-access-from domain=”*.oooxxx.com”/>
</cross-domain-policy>


« Previous PageNext Page »