南郭之家
南郭大侠的blog ^_^

openvpn通过isa server代理验证

August 25th, 2010 by Titan

首先,openvpn要配置为使用tcp模式,需要服务器支持tcp方式链接,

remote x.x.x.x 443 tcp

接下来,配置openvpn使用isa proxy,在openvpn.conf里面加入下面一行

http-proxy y.y.y.y 8080 stdin ntlm

这里y.y.y.y是isa的地址,ntlm方式是isa需要的认证方式,stdin指的是从命令行输入isa的认证密码,也可以存到本地文件里面去,然后把文件名放到stdin的位置

最好是把本地默认路由替换成通道的路由,这样就不会受到本地网络的限制了,哇哈哈哈,可以自由上网咯

Posted in 技术 | No Comments »

initrd的man文档

August 24th, 2010 by Titan

NAME
initrd – boot loader initialized RAM disk

CONFIGURATION
The /dev/initrd is a read-only block device assigned major number 1 and minor number 250. Typically /dev/initrd is owned by
root.disk with mode 0400 (read access by root only). If the Linux system does not have /dev/initrd already created, it can
be created with the following commands:
mknod -m 400 /dev/initrd b 1 250
chown root:disk /dev/initrd

Also, support for both “RAM disk” and “Initial RAM disk” (e.g. CONFIG_BLK_DEV_RAM=y and CONFIG_BLK_DEV_INITRD=y) must be
compiled directly into the Linux kernel to use /dev/initrd. When using /dev/initrd, the RAM disk driver cannot be loaded as
a module.

DESCRIPTION
The special file /dev/initrd is a read-only block device. This device is a RAM disk that is initialized (e.g., loaded) by
the boot loader before the kernel is started. The kernel then can use /dev/initrd’s contents for a two-phase system boot-up.

In the first boot-up phase, the kernel starts up and mounts an initial root file-system from the contents of /dev/initrd
(e.g., RAM disk initialized by the boot loader). In the second phase, additional drivers or other modules are loaded from
the initial root device’s contents. After loading the additional modules, a new root file system (i.e., the normal root file
system) is mounted from a different device.

Boot-up Operation
When booting up with initrd, the system boots as follows:

1. The boot loader loads the kernel program and /dev/initrd’s contents into memory.

2. On kernel startup, the kernel uncompresses and copies the contents of the device /dev/initrd onto device /dev/ram0 and
then frees the memory used by /dev/initrd.

3. The kernel then read-write mounts the device /dev/ram0 as the initial root file system.

4. If the indicated normal root file system is also the initial root file-system (e.g. /dev/ram0) then the kernel skips to
the last step for the usual boot sequence.
5. If the executable file /linuxrc is present in the initial root file-system, /linuxrc is executed with UID 0. (The file
/linuxrc must have executable permission. The file /linuxrc can be any valid executable, including a shell script.)

6. If /linuxrc is not executed or when /linuxrc terminates, the normal root file system is mounted. (If /linuxrc exits with
any file-systems mounted on the initial root file-system, then the behavior of the kernel is UNSPECIFIED. See the NOTES
section for the current kernel behavior.)

7. If the normal root file system has a directory /initrd, the device /dev/ram0 is moved from / to /initrd. Otherwise if the
directory /initrd does not exist, the device /dev/ram0 is unmounted. (When moved from / to /initrd, /dev/ram0 is not
unmounted and therefore processes can remain running from /dev/ram0. If directory /initrd does not exist on the normal
root file system and any processes remain running from /dev/ram0 when /linuxrc exits, the behavior of the kernel is
UNSPECIFIED. See the NOTES section for the current kernel behavior.)

8. The usual boot sequence (e.g., invocation of /sbin/init) is performed on the normal root file system.

前几天老许问我关于initrd的作用,说起来只知道是放驱动程序用的磁盘镜像,我的理解就是放了一些linux要用的基本目录,加上/lib/modules里面跟启动关系紧密的驱动程序,但是完全不懂里面到底是什么东西,所以今天想起来,在ubuntu上面做了一下实验,注意,这个initrd文件在不同的发行版上面使用不太一样的格式存储,所以要区别对待

mkdir /tmp/initrd
cd /tmp/initrd
gzip -d /boot/initrd.img-2.6.32-24-generic
file initrd.img #看到是cpio文件
cpio -i < initrd.img

到这里就解压出来了镜像里面的全部内容,ls一下可以看到目录结构包含了 bin conf etc init lib sbin scripts var, 其中init是个可执行文件,应该就是我们的1号进程。这里有点疑问,我比较了一下这个init和/sbin/init,发现并不是同一个文件,再结合上面initrd的man文档的第6步解释,猜想这个文件一般不会被执行,因为在这里会挂上我们的根文件系统以后执行/sbin/init了

然后我看了一下这个目录下面lib/modules下面果然有这个版本内核的驱动程序,总共有14M大小,而我/lib/modules下面同一个内核的驱动程序模块为89M,少了这么多,我大概看了一下内容,虽然不是很了解每个模块的作用,但是看名字,感觉是内核启动时可能会需要用到的驱动程序,比如磁盘,网络支持等功能。比如摄像头驱动啥的这里就都没有,所以小了不少,反正这些在启动阶段用不到的。

Posted in 技术 | No Comments »

Liferea RSS Reader

August 24th, 2010 by Titan

一直想要一个可以在桌面与GReader同步的rss reader,在源里面搜了半天,发现貌似liferea还不错,但是安装以后跟GReader一直同步不上,一直弹出Authentication框框,提示输入密码,后来上网搜到,说是1.6.4版修复了这个问题,是因为GReader那边更新验证协议造成的。但是1.6.4版在源里面暂时没有,所以自己下载了源代码来编译

tar xvf ~/Downloads/liferea-1.6.4.tar.gz
cd liferea-1.6.4
sudo apt-get build-dep liferea
./configure
make
sudo make install

Posted in 技术 | No Comments »

CPU cache – Wikipedia, the free encyclopedia

August 20th, 2010 by Titan

CPU cache – Wikipedia, the free encyclopedia.

cpu cache讲解,包含L1, L2 Cache等,和cache使用策略。

Posted in 技术 | No Comments »

[转载]Linux 磁盘“Block Size”研究!

August 19th, 2010 by Titan

自从开始Linux 软件平台开发,经常遇到“Block Size”。但经常发现此block size非彼block size。意义不一样,大小值也不一样。Open Source的东东有时候也挺烦的。下面是自己的总结。通常Linux的“block size”指的是1024 bytes,Linux用1024-byte blocks 作为buffer cache的基本单位。但linux的文件系统的block确不一样。例如ext3系统,block size是4096。使用tune2fs可以查看带文件系统的磁盘分区的相关信息,包括block size。
例如:
tune2fs -l /dev/hda1 |grep “Block size”
Block size: 4096
另一个工具dumpe2fs也可以。

其实本来这几个概念不是很难,主要是NND他们的名字都一样,都叫“Block Size”。
1. 硬件上的 block size, 应该是”sector size”,linux的扇区大小是512byte
2. 有文件系统的分区的block size, 是”block size”,大小不一,可以用工具查看
3. 没有文件系统的分区的block size,也叫“block size”,大小指的是1024 byte
4. Kernel buffer cache 的block size, 就是”block size”,大部分PC是1024
5. 磁盘分区的”cylinder size”,用fdisk 可以查看。

我们来看看fdisk显示的不同的信息,理解一下这几个概念:

Disk /dev/hda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 1305 10482381 83 Linux
/dev/hda2 1306 1566 2096482+ 82 Linux swap
/dev/hda3 1567 30401 231617137+ 83 Linux

8225280就是cylinder size。一共有30401个cylinder。Start和End分别标记的是各个分区的起始cylinder。第4列显示的就是以1024为单位的 block(这一列最容易把人搞晕)。为什么“2096482+”有个“+”号呢?因为啊,总size除1024除不尽,是个约数,表示2096482 强!哈哈。搞笑吧,只有opensource的人想得出来这么表示。

Posted in 技术 | No Comments »

Best Vim Tips – Vim Tips Wiki

August 19th, 2010 by Titan

Best Vim Tips – Vim Tips Wiki.

一些基本的使用技巧,整理的非常好,学习vi需要一个过程,建议新手循序渐进,学完基本的就开始用,过一段时间增加一些新的内容,慢慢扩展自己的操作。这篇文章整理的很好,按照难度等级一级一级增加,高手可以看看自己玩到那一层啦,哈哈

Posted in 技术 | No Comments »

ofetion – Project Hosting on Google Code

August 18th, 2010 by Titan

ofetion – Project Hosting on Google Code.

linux下面用的fetion,界面很漂亮,界面功能也完善。下载了代码自己编译的,自己安装了libgstreamer0.10-dev包以后就完美了

Posted in 技术 | No Comments »

using adb and fastboot for samsung galaxy(i7500) on ubuntu10.04

August 17th, 2010 by Titan
  1. 【2】下载android-sdk-tools,解压家目录下面,在【1】里下载patch过的adb和fastboot放到tools目录下面,把sdk下面的tools目录加入到PATH变量里面,重新加载环境变量或者重启terminal,让环境变量生效
  2. 在手机上面做如下设置:
    1. About Phone -> Additional settings -> 将Mass storage only取消选择
    2. Applicaition Settings -> Development -> 选中USB Debugging
  3. 编写udev的规则
    1. /etc/udev/rules.d/90-android.rules
      SUBSYSTEM=="usb", ATTRS{idVendor}=="04e8" , ATTRS{idProduct}=="6640", OWNER="titan", SYMLINK+="samsung-galaxy"

      这里titan要换成你自己的用户名,04e8和6640这两个参数下面命令可以看到

      lsusb | grep -i samsung
    1. /etc/udev/rules.d/51-android.rules,下面的18d1参数也是在fastboot模式时lsusb看到的
      SUBSYSTEM=="usb", ATTRS{idVendor}=="18d1", MODE="0666", OWNER="titan"
  4. 重新加载udev规则:
    sudo reload udev
  5. 重新用usb连接手机
  6. 现在用adb devices应该能看到I7500了
  7. 另外,fastboot devices只有将手机重启进入fastboot模式以后才能看到。

Reference:

  1. How to ADB, Fastboot, Mass storage in Linux by sado1
    [HOWTO] Linux ADB, fastboot, mass storage
  2. http://developer.android.com/sdk/index.html

Posted in 随想 | No Comments »

memcached-session-manager – Project Hosting on Google Code

August 8th, 2010 by Titan

使用memcached作为tomcat的session manager,在部署大型集群的时候,tomcat自带的session replication技术会影响效率,使用统一的session存放策略更有利于集群规模的扩展,替换session manager的方法可以在程序代码不做修改的情况下实现,很不错

via memcached-session-manager – Project Hosting on Google Code.

Posted in 技术 | No Comments »

代码片段管理工具,Snipt | Share and store code or command snippets.

August 7th, 2010 by Titan

Snipt是一个snippet管理的网站,一直想找在ubuntu下面能跟mac下面Snippets媲美的snippet管理软件,试用了几个都没有合适的,应该不是我要求太高吧,起码这个网站除了不是桌面程序以外都能满足我的要求啦

我的snippet manager需求

  • 语法高亮
  • tag
  • 搜索,最好能incremental search
  • 桌面软件同步
  • 快速复制或者像snippets那样能够快速插入也行,我更倾向于快速复制就可以了

via Snipt | Share and store code or command snippets..

Posted in 技术 | No Comments »

« Previous Entries