2010年8月4日 星期三

用 Serial Console 管理 Linux主機

要使主機就像一般網路設備一樣,可以在不接螢幕,鍵盤及滑鼠之下,直接透過 serial console 的連接方式來管理內部系統。當然囉!! 若你和我一樣使用超小型主機來安裝,這技巧更是不可或缺。
首先看一下,這個超小型主機。要充分發揮它的迷你的特性,當然是不能接上螢幕/鍵盤/滑鼠,不然就遜掉。那系統管理該如何作呢?
作過網管的人都知道,一般網路設備都只是透過一條 serial console line 連接筆記型電腦和網路設備,以終端機軟體來管理內部的系統。此篇將告訴你如何在系統上實現,而且步驟實在很簡單。
要實現這樣的應用,事實上關鍵在於 Linux 作業系統。

步驟一:編輯 /boot/grub/menu.lst
在 title ..... 上方,加上

## Enable serial console
serial --unit=0 --speed=9600 --word=8 --parity=no --stop=1
terminal --timeout=10 serial console

這行前面加上註解

#splashimage=(hd0,1)/boot/grub/splash.xpm.gz

找到實際開機所需的那一行,例如是

title CentOS-4 i386-up (2.6.9-34.0.2.EL)
        root (hd0,1)
        kernel /boot/vmlinuz-2.6.9-34.0.2.EL ro root=LABEL=/1
        initrd /boot/initrd-2.6.9-34.0.2.EL.img

在 kernel 後方加上 console=tty0 console=ttyS0,9600n8

kernel /boot/vmlinuz-2.6.9-34.0.2.EL ro root=LABEL=/1 console=tty0 console=ttyS0,9600n8
步驟二:編輯 /etc/inittab最下方加上這行

# Enable serial console
sc:2345:respawn:/sbin/agetty ttyS0 115200,9600 xterm

步驟三: 系統預設是不予許 root 直接從 serial console 登入,這樣造成管理不是很方便,所以修改一下設定。
編輯 /etc/securetty,最底下加上
ttyS0
步驟四:完成了,到這兒,主機已經可以用 serial console 登入管理。
接著,準備一台筆記型電腦,還有自己習慣用的終端機軟體,如沒有,就用 Windows 內建的超級終端機也可,再一條 USB 轉 COM 的 console 線。設定終端機連接埠的參數為
資料傳輸率:9600
資料位元:8
同位檢查:無
停止位元:1
流量控制:硬體
以 serial console 方式的管理介面與 telnet 是一樣的,只是若使用 Windows 內建的超級終端機軟體,會有畫面被截掉情形,筆者推薦使用 Putty   這工具。

耗電只要5W的超迷你IP PBX硬體

這個硬體稱為 Plug Computer,基本規格簡述如下:
  • Marvell RISC Architecture ARM CPU(800MHz-1.2GHz)
  • DDR2 512MB RAM
  • NAND Flas 512MB
  • 可外接 SDHC/USB 儲存裝置
  • 1000/100 網路
  • 平均電源消耗 5W
  • 系統支援 Linux 2.6.x
更詳細硬體資訊,請前往
- http://www.ionics-ems.com/plugcomputer.html
- http://www.globalscaletechnologies.com/t-sheevaplugdetails.aspx#extern

2010年7月15日 星期四

IEEE 802.1p

From Wikipedia, the free encyclopedia

IEEE 802.1p, also known as Class of Service (CoS), is a 3 bit field within an Ethernet frame header when using tagged frames on an 802.1 network. It specifies a priority value of between 0 and 7 inclusive that can be used by Quality of Service (QoS) disciplines to differentiate traffic.
IEEE P802.1p is also the name of a task group active during 1995–98 responsible for adding traffic class expediting and dynamic multicast filtering to the IEEE 802.1D standard. Essentially, they provided a mechanism for implementing QoS at the Media Access Control (MAC) level. The group's work with the new priority classes and Generic Attribute Registration Protocol (GARP) was not published separately but was incorporated into a major revision of the standard, IEEE 802.1D-1998. It also required a short amendment extending the frame size of the ethernet standard by four bytes which was published as IEEE 802.3ac-1998.

Short Summary

802.1p defines eight different classes of service which are available, usually expressed through the 3-bit user_priority field in an IEEE 802.1Q header added to the frame. The way traffic is treated when assigned to any particular class is undefined and left to the implementation.
The IEEE however has made some broad recommendations:
User priority Traffic Type
0 Background
1 Best Effort
2 Excellent Effort
3 Critical Applications
4 Video, < 100 ms latency
5 Voice, < 10 ms latency
6 Internetwork Control
7 Network Control
Note that the above recommendations were revised in IEEE 802.1Q-2005 and differ from the original recommendations found in IEEE 802.1D-2004.

2010年7月14日 星期三

packETH - ethernet packet generator



IEEE 802.1Q-in-Q VLAN Tag (QinQ)

The IEEE 802.1Q-in-Q VLAN Tag is purpose to expand the VLAN space by tagging the tagged packets, thus producing a "double-tagged" frame. The expanded VLAN space allows the service provider to provide certain services, such as Internet access on specific VLANs for specific customers, and yet still allows the service provider to provide other types of services for their other customers on other VLANs.

2010年7月5日 星期一

googlecl (Command line tools for the Google Data APIs)

GoogleCL brings Google services to the command line.
We currently support the following Google services:

  • Blogger
  • $ google blogger post --title "foo" "command line posting"
  • Calendar
  • $ google calendar add "Lunch with Jim at noon tomorrow"
  • Contacts
  • $ google contacts list name,email > contacts.csv
  • Docs
  • $ google docs edit --title "Shopping list"
  • Picasa
  • $ google picasa create --title "Cat Photos" ~/photos/cats/*.jpg
  • Youtube
  • $ google youtube post --category Education killer_robots.avi
Check out our ExampleScripts for many more examples of what you can do, or the SystemRequirements for simple install instructions.



LINK:http://www.pcadv.com.tw/posts/2904-googlecl

2010年7月1日 星期四

Subversion, Grep, Diff

習慣用 grep 來找 source code 當中的字串;也很習慣用 diff 來比較兩個 source tree 的差異。如:
grep -r STRING *
diff -ur DIR1 DIR2
這兩個指令很好用。但是遇到 Subversion 的 working copy 時,就會受到 .svn 目錄的干擾。所幸這兩個指令都提供排除非必要目錄的方法:
grep --exclude-dir=.svn -r STRING *
diff -x .svn -ur DIR1 DIR2

老實說,常會忘記這些參數,也常弄混。 因此建議在 .bashrc 當中加上以下設定,這樣以後不管是不是 working copy 都可以安心使用 grep -r 和 diff -r 了:
alias grep='grep --exclude-dir=.svn'
alias diff='diff -x .svn'

from Rupert's blog :http://softsmith.blogspot.com/2009/03/subversion-grep-diff.html

How to repair and clone disk with ddrescue

  ddrescue  is a tool that can be used to repair and clone disks on a  Linux system . This includes hard drives, partitions, DVD discs, flas...