Friday, April 15, 2011

Compile kernel for Kurobox HG

又是寫筆記的一篇文章

記得這台 Kurobox HG 已經買了至少 五六年以上了

kernel 從早期內建的 2.4.17_mvl-sandpoint 幾年之間一直不斷的升級到現在已經 2.6.32.28
(註:要使用自己的kernel必須先將機器的 bootloader
刷成 uboot,但是刷 bootloader有一定程度的風險,
不確定的朋友請勿輕易嘗試,以免機器變成磚頭)

機器上的系統也從

Debian 3.0 (woody) -> Debian 4.0 (etch) -> Debian 5.0 (lenny) -> Debian 6.0 (squeeze)
(註: Debian 的套件管理真的做的很好, 一路這樣升級都沒出什麼大問題)

年紀大了
每次 compile 新 kernel 都還要去看網頁
Compile a uBoot Kernel

記不了那麼多, 而且本人很懶也沒設 bookmark, 所以乾脆寫編文章也方便自己參考


1. Get the kernel source

# cd /usr/src
# wget http://www.kernel.org/pub/linux/kernel/v2.6/longterm/v2.6.35/linux-2.6.35.12.tar.bz2
# tar xjvf linux-2.6.35.12.tar.bz2


2. Compile your kernel
直接拿前一版的config來用比較快,而且我是 native compile 所以 ARCH=powerpc 就省了

# cp /boot/config-2.6.32.28 .config
# make oldconfig
...
...
# make uImage && make modules && make modules_install

通常我都從外面用 ssh 連回家而且開 screen 讓, 開始 make 後就 detach 了
沒意外的話應該是不會出什麼差錯

3. Backup your old kernel and dtb file

# cp /boot/uImage /boot/uImage.bak
# cp /boot/kuroboxHG.dtb /boot/kuroboxHG.dtb.bak


前面的步驟跟一般x86上 make kernel 的步驟都一樣, 讓我老是記不起來的是關於 dtb file
這些步驟, 如下

4. Compile the dtb file

# cp kuroboxHG.dtb /tmp/
# cd /usr/src/linux/arch/powerpc/boot/dts
# dtc -I dts -O dtb -V 16 -o /tmp/kuroboxHG.dtb kuroboxHG.dts
# cp /tmp/kuroboxHG.dtb /boot/kuroboxHG.dtb


5. Install the kernel & enable modules

# cp /usr/src/linux/arch/powerpc/boot/uImage /boot/uImage
# cd /lib/modules/2.6.35.12/
# depmod


6. Reboot

# reboot


7.Troubleshooting
如果不幸開不了機的話 XD
只好進去 EM mode 把剛剛備份的舊 kernel 和 dtb file copy 回來

# cp /boot/uImage.bak /boot/uImage
# cp /boot/kuroboxHG.dtb.bak /boot/kuroboxHG.dtb


(註:dtb file 是 uboot 使用的, 但是 uboot 必須要在某個版本以上才有支援(版本忘記了)
所以如果 Kurobox HG bootloader 沒刷機成 uboot 的朋友, 是不需要做出 dtb file 的)

Tuesday, April 12, 2011

Fedora - Build rpm package from src.rpm

參考
http://fedoraproject.org/wiki/Docs/CustomKernel

以下所有命令都是在非 root 下運行

在開始之前,先確保系統已安裝下列必要的包:

yum-utils
rpmdevtools


可通過下面的命令來安裝:
su -c 'yum install yum-utils rpmdevtools'

其中 yum-utils 包提供 yumdownloader 和 yum-builddep 這兩個命令,

rpmdevtools 包提供 rpmdev-setuptree 這個命令

獲得 Source
1. 首先建立 RPM 的打包環境目錄,運行下列命令:
rpmdev-setuptree

該命令會在用戶的 HOME 目錄下建立 rpmbuild/{SOURCES,SPECS,BUILD,RPMS,SRPMS} 這5個目錄,
以及一個 .rpmmacros 文件,該文件定義了一些 rpm 打包的環境變數。

2. 下載 kernel source src.rpm package。
可以直接到 fedora 的官方源上去下載,也可以用下列命令下載:
yumdownloader --source kernel

3. 安裝編譯內核所需要的包,運行下列命令:
su -c 'yum-builddep kernel-.src.rpm'

4. 安裝 kernel source src.rpm 包,運行下列命令:
rpm -Uvh kernel-.src.rpm

準備 kernel source tree
1. 運行下列命令來建立 kernel source tree:

cd ~/rpmbuild/SPECS
rpmbuild -bp --target=`uname -m` kernel.spec

現在kernel source tree位於
~/rpmbuild/BUILD/kernel-/linux-. 目錄。

2. 如果還需要修改kernel source的話(可選),可按如下步驟操作:

cp -a ~/rpmbuild/BUILD/kernel-2.6.$ver/linux-2.6.$ver.$arch ~/rpmbuild/BUILD/kernel-2.6.$ver.orig
cp -a ~/rpmbuild/BUILD/kernel-2.6.$ver.orig ~/rpmbuild/BUILD/kernel-2.6.$ver.new
在 ~/rpmbuild/BUILD/kernel-2.6.$ver.new 中對 source 作修改,然後作成 patch:
cd ~/rpmbuild/BUILD
diff -uNrp kernel-2.6.x.orig kernel-2.6.x.new > ../SOURCES/linux-2.6-my-new-patch.patch


配置內核選項(可選)
如果需要修改內核的編譯選項的話,按如下操作:
1. 進入內核源代碼樹

cd ~/rpmbuild/BUILD/kernel-/linux-./


2. 從 configs 目錄中挑選一個基於其修改的 config 檔,把它複製成內核源代碼樹中的 .config 文件

cp configs/ .config


3. 配置內核編譯選項

make oldconfig
make menuconfig


4. 在新生成的 .config 檔的第一行添加一行指定硬體平臺的標識(uname -i 的輸出),以 # 號開頭,例如:

# i386


5. 把 .config 檔複製到 ~/rpmbuild/SOURCES/ 目錄下,並命名成 config-,例如 config-i686

cp .config ~/rpmbuild/SOURCES/config-


準備 spec 文件
進入 ~/rpmbuild/SPECS 目錄,編輯 kernel.spec 文件:
1. 定義 buildid 為一個唯一的標識,以區別不同的 kernel rpm 包。把
#% define buildid .local
改成
%define buildid .
注意去掉 % 和 define 之間的空格

2. 如果之前有生成 patch ,把 patch 加到 kernel.spec 文件中。一般放在所有已有的 patch 最後,並注明注釋。例如:

# cputime accounting is broken, revert to 2.6.22 version
Patch2220: linux-2.6-cputime-fix-accounting.patch
Patch9999: linux-2.6-samfw-test.patch

另外在打 patch 那一段也要補上:

ApplyPatch linux-2.6-cputime-fix-accounting.patch
ApplyPatch linux-2.6-samfw-test.patch

編譯新的內核
用 rpmbuild 命令來編譯 kernel rpm 包,默認的命令為:
rpmbuild -bb --target=`uname -m` kernel.spec
這個命令可能會編譯好幾遍 kernel,生成不同類型的 kernel image,
例如支援 xen、smp 等的 kernel。

可以通過添加 --without

Friday, April 01, 2011

load storage adapter driver 遇到的問題

今天成功的將 CentOS 5.5 機器的 kernel更新成了 Fedora Core 14 x86 64 bits 的 kernel,

因為CentOS 5.5 的 kernel實在太老舊了,

不過在開機過程 load SAS adapter driver, 發現 driver load 完, init 仍然繼續往前執行,

如果這時有設定 LVM/MD之類的東西就會發生錯誤,

後來拜Google大神找到一個類似的問題
rc.sysinit does not wait for udev loaded scsi adapters to finish scanning their busses

應該跟 rc.sysinit 有關係, 因為筆者使用 Fedora Core 14時並沒有這個現象,
索性就直接去比較 CentOS 5.5 和 Fedora Core 14 rc.sysinit 的差別
結果發現了, Fedora Core 14 裡面有一段

# Sync waiting for storage.
{ rmmod scsi_wait_scan ; modprobe scsi_wait_scan ; rmmod scsi_wait_scan ; } >/dev/null 2>&1

加到 CentOS 5.5 rc.sysinit 後, 一切 OK, 果然如 module name scsi_wait_scan 一樣
至於為什麼要先 rmmod -> modprobe -> rmmod 就再研究了

SCSI adapter driver initial 完會call scsi_scan_host 來 scan device
為了 async scan device 會 create 一個名為 "scsi_scan_x" 的 kernel thread 來執行 do_scan_async
詳細看 void scsi_scan_host(struct Scsi_Host *shost) source code

do_scan_async() 呼叫 do_scsi_scan_host() 開始啟動 scan,
呼叫 scsi_finish_async_scan() 來通知系統 scan 完成

從source code 可以得知如果是 async scan的話, scan到一個lun的時候並不會馬上註冊device name
device name的註冊是在scsi_finish_async_scan()裡面完成的

基本上這次遇到的問題是 async scan 造成的...

scsi_wait_scan module source code 很短, 主要應該是 scsi_complete_async_scans(void)
基本上作法就是 create 一個假的 "async_scan_data" insert 到
scanning_hosts list 的尾巴, 然後就等 wait_for_completion(&data->prev_finished);

int scsi_complete_async_scans(void)
{
struct async_scan_data *data;
...
...
data = kmalloc(sizeof(*data), GFP_KERNEL);
...
init_completion(&data->prev_finished);
...
...
list_add_tail(&data->list, &scanning_hosts);
...
printk(KERN_INFO "scsi: waiting for bus probes to complete ...\n");
wait_for_completion(&data->prev_finished);
...
return 0;
}


如果沒理解錯誤的話, 應該是會在
void scsi_finish_async_scan(struct async_scan_data *data) 中
被 complete(&next->prev_finished);

也因此 scsi_wait_scan module return 時只保證在它之前就啟動的scan

已經結束, 若是在它之後才啟動的scan 則有可能已經結束或未結束

Tuesday, March 29, 2011

客製 Fedora Core 14 initramfs


cp /boot/initramfs-2.6.35.6-45.fc14.x86_64.img .
mkdir ./temp
cd ./temp
gunzip < ../initramfs-2.6.35.6-45.fc14.x86_64.img | cpio -i


修改完後, 重新打包出新的 initramfs

find | cpio -H newc -o | gzip -9 > ../initramfs-2.6.35.6-45.fc14.x86_64-XXXX.img

Friday, March 18, 2011

CentOS 5.5 自己 build kernel

由於CentOS 5.5的kernel實在太舊了 (Version 2.6.18-194, 沒記錯的話是 2007年2月)
紀錄一下升級kernel的步驟
1. 安裝build kernel所需的套件

#yum groupinstall “Development Tools” && yum install ncurses-devel


2. 抓取要使用的kernel source

#cd /usr/src
#wget “http://www.kernel.org/pub/linux/kernel/v2.6/longterm/v2.6.35/linux-2.6.35.11.tar.bz2″
#bunzip2 linux-2.6.35.11.tar.bz2
#tar xf linux-2.6.35.11.tar
#ln -s linux-2.6.35.11 linux
#cd linux


3. 利用舊的kernel config來build kernel

#cp /boot/config-`uname -r` /usr/src/linux/.config
#cd /usr/src/linux
#make menuconfig

選取 'Load an alternate Configuration File' 將 .config load 進來

在 'General Setup' 選取
'enable deprecated sysfs features to support old userspace tools'

不選的話會在開機過程 switchroot 的時候 fail, 選取之後 save config


4. build kernel

#make rpm

如果過程沒問題的話, 等一段時間後 rpm 會被做出來,

5. install kernel

#rpm -ivh /usr/src/redhat/RPMS/i386/kernel-2.6.35.11-1.i386.rpm

rpm檔的名字不一定跟上面相同 (depend on 你的機器), 安裝完後我們檢查一下

#rpm -qa | grep -i kernel


6. build initrd image

#mkinitrd /boot/initrd-2.6.35.11.img 2.6.35.11


7. 修改 grub

#vim /boot/grub/menu.lst


剩下就不多說了

Tuesday, February 22, 2011

Ubuntu initrd.img 解壓縮和打包的步驟

每次要用到時候就要去網路爬文, 所以還是自己記錄一下,
年紀大了, 如果不是每天在用的話真的沒幾天就忘光光了

以 Ubuntu 10.10 為例
通常 initrd.img 可以在 /boot 下面找到,
為了測試先 copy 一份到一個暫時的目錄


cp /boot/initrd.img-2.6.35-25-generic /xxx/initrd.img.gz

到暫時的目錄去解壓縮

cd /xxx/
gzip -d initrd.img.gz

解壓縮後檔案為 initrd.img, 這個檔案需要用 cpio 解開成為一堆目錄和檔案

mkdir initrd
cd initrd
cpio -i -d < ../initrd.img

看一下裡面的檔案

到這邊解開的動作已經完成
現在就可以對 initrd 裡面的檔案或者 scripts 作修改, 修改完接下來我們要打包出新的 initrd.img,
下面將打包出 newinitrd.img

find . | cpio -o -H newc > ../newinitrd.img


離開 initrd 目錄, 用 gzip 將 newinitrd.img 壓縮

cd ..
gzip -9 newinitrd.img
(gzip 的最高級壓縮)

newinitrd.img.gz 就是 Ubuntu 的 initrd.img 了

註: 注意一下 newinitrd.img.gz 的檔案大小, 如果檔案太小, 可能是步驟有錯

Thursday, January 13, 2011

Drop Caches

參考http://linux-mm.org/Drop_Cache

Linux kernel 2.6.16 之後的版本提供了 drop caches (包含 pagecache, indoe 和 dentry caches) 的機制,

此機制可以幫忙我們釋放大量的記憶體. 現在你可以扔掉以前只是為了去除 cache 而配置許多記憶體的 script

現在只需要操作 /proc/sys/vm/drop_caches 就可以完成

1. 釋放 pagecache:
echo 1 > /proc/sys/vm/drop_caches

2. 釋放 dentries 和 inodes:
echo 2 > /proc/sys/vm/drop_caches

3. 釋放 pagecache, dentries 和 inodes:
echo 3 > /proc/sys/vm/drop_caches

這是非破壞性的動作而且只會釋放完全沒在使用的部份

Dirty objects 在尚未寫到 disk 前其狀態將會維持在使用中而且是不能被釋放的
假如先執行 "sync" 使其 flush 到 disk 那 drop cache 動作應該會釋放更多記憶體

Friday, December 10, 2010

build kernel 遇到 PATH_MAX undeclared

今天在 Ubuntu 10.10 build 2.6.18.8 的 kernel 時遇到這個錯誤

爬文後發現很多人都有遇到這個問題

年紀大了還是寫下來以免忘記

修改 scripts/mod/sumversion.c

多 include limits.h 就 OK了


#include <linux/limits.h>

Windows 2008 R2 安裝 AD

在 Windows 2008 R2 安裝 AD 的簡易部簡易步驟

1. Set a static IP and set the same IP to DNS

2. start->run-> type dcpromo

3. Create a new Domain

4. Set FQDN ex: test.com

5. Set password for ADDR

Friday, November 26, 2010

/proc/sysrq-trigger的功能

sysrq-trigger功能很多, 之前最常用到是要作一些讓Linux kernel crash的測試時用sysrq-trigger就很方便了

當然要使用前記得先 enable 它, 平常是 disable 的
# echo 1 > /proc/sys/kernel/sysrq
使用方法如下

# 立即重新開機, 但不會 sync 和 umount
echo "b" > /proc/sysrq-trigger

# 立即關機
echo "o" > /proc/sysrq-trigger

# dump 記憶體分配的 information (可以使用 /var/log/message 查看)
echo "m" > /proc/sysrq-trigger

# Will dump the current registers and flags to your console. (應該是跟CPU相關的訊息)
echo "p" > /proc/sysrq-trigger

# Will dump a list of current tasks and their information to your console.
echo "t" > /proc/sysrq-trigger

# Will perform a kexec reboot in order to take a crashdump.
echo "c" > /proc/sysrq-trigger


其他功能可以查閱 Linux kernel 下 Documentation/sysrq.txt 文件

Saturday, November 20, 2010

Cluster Project FAQ

Cluster Project FAQ – Frequently Asked Questions

http://www.robertpeterson.org/faq.html

整理的很好, 有疑問的時候可以先去爬爬文, 以免走冤枉路

Wednesday, November 17, 2010

I/O fencing

就自己爬文和查資料所得的結果, 所謂 I/O fencing 的意義如下(不知是否有理解錯誤??)

什麼是 I/O fencing -

在cluster架構中, I/O fencing 是為了避免

假死或者動作異常的 cluster member 造成

shared media 資料損毀所採取的主動對策

為什麼需要它 -

Fencing 可以避免資料損毀, 降低 cluster 架構中的不確定性

以下以一個簡單的例子說明
*node 1 takes a lock
*node 1 hangs
*node 2 thinks node 1 is dead
*node 2 takes the same lock node 1 took
*node 2 writes data
*node 1 wakes up, still believing it has the lock
*node 1 overwrites data that node 2 just wrote out

加入 fencing 機制後
*node 1 takes a lock
*node 1 hangs
*node 2 thinks node 1 is dead
*node 2 fences node 1
*node 2 takes the same lock node 1 took
*node 2 writes data
*node 1 wakes up, still believing it has the lock
*node 1 tries to write data, but can't since it has lost its I/O paths to the disk
在第二個case中資料損毀的情況被避開了

目前在cluster software使用的技術

I/O Fencing Variants
*power fencing - 假如 power loss, 該 node 就無法做 I/O. 這可以藉由外部的 power switches 來完成
或者藉由整合的 power management 功能來完成, 例如 iLO, IPMI, DRAC, RSA, 等等

*fibre channel zoning - 一般來說是由 fibre channel switches 來切斷 host 到 shared SAN 的路徑

*SCSI-2 reservations (old) - 詳情見SPI-2

*SCSI-3 reservations (group) - 每個 node 須完成對 LUN或者LUNs 的註冊, 詳情見 SPI-3

*Network Disconnect (NAS only) - 當以(NFS, iSCSI, etc)來連接一個 NAS設備, 可以用一個 managed switch 將 node 的 network port 與網路隔離開

*ssh "reboot" - 此方法很不可靠

*virtual machine destruction - 等同於 power fencing

Wednesday, November 10, 2010

小技巧-檢查目錄是否有裝置mount在上面


if ! mountpoint -q /mnt/test; then
mount /mnt/test
fi

Cluster 名詞大集合

大部分資料從 Wikipedia 查到的, 只是作筆記整理
---------------------------------------------
Cluster 的種類 :
1.High-availability (HA) clusters
2.Load-balancing clusters
3.Compute clusters
---------------------------------------------
Two-node cluster - A two-node cluster is the minimal high-availability cluster that can be built.
---------------------------------------------
Classification by role symmetry
1.Active/Passive
One node owns the services, the other one remains inoperative.
Should the primary node fail, the secondary or backup node takes the resources and reactivates the services, while the ex-primary remains in turn inoperative.
This is a configuration where only one node is operative at any point of time.

2.Active/Active
There is no concept of a primary or backup node: both nodes provide some service, should one of these nodes fail, the other must also assume the failed node's services.
---------------------------------------------

Tuesday, October 26, 2010

PCIe study part (1)

PCIe
● topology : Point-to-Point
● frequency: 2.5 GHz
● width : 2 wires per lane/per direction (Up to 32 lanes)
● Max. throughput : 500~16000 MB/sec
● Split transaction : Yes
● Dev. type: Root complex, Switches, Bridges, Endpoints
● Layer : Physical layer, Data Link layer, Transaction layer

● PCIe employs packets to accomplish data transfer between devices--
Transaction Layer Packets (TLPs)

● There are 4 types of transactions--
Memory, I/O, Configuration, Messages

● What is transactionsseries ?
series of packet transmissions to complete information exchange between
requester and completer

● Posted = Requester transmits TLP request packet, completer
does not return completion packet --> Memory Write, Message

● Non-posted = Requester transmits TLP request packet,
completer returns completion packet to requester,
May include data in the request or completion TLP
--> Memory Read, Memory Read Lock, I/O Read, I/O Write, Config Read, Config Write

High Availability systems under Linux

文章閱讀筆記


#
What is HA?
High Availability is what it says it is.
Something that is Highly Available.

#
The service runs on a machine, and redirecting the service and requests to another healthy machine is the art of High Availability.

#
How will this work
if master node fails, then the slave node may take over its ip address and start serving the requests.This method is called IP takeover.

#
How do clusters talk
They will talk to each other over a serial cable and over a cross link Ethernet cable (for redundancy, serial cable or Ethernet cable may fail) and check each others heartbeat.
The program to monitor the heartbeats of the cluster nodes is called... guess...heartbeat.
heartbeat is available at http://www.linux-ha.org/download/
The program for ip address take over is called fake and is integrated in heartbeat.

#
What about data integrity issues
When service httpd moves from node1 to node2 it does not see the same data. I loose all the files that I was creating with my httpd CGI's.

Two Answers:
1. You should never write to file from your CGI's. (use a network database instead.. MySQL is pretty good)
2. You can attach the two nodes to a central external SCSI storage, and make sure that only one is talking to it at one time, and also make sure that you change the SCSI id of the host card on machine a to 6 and leave on machine b 7 or vice -versa.

You can run GFS (Global File System, see below in resources) over FC which allows you to have transparent access to the storage from all machines as if they were local storage.

#
What about active/active cluster

You can easily build an Active/Active server if you have a good storage system that allows concurrent access.
Examples are Fibrechannel and GFS.

If you are content with Network filesystems such as NFS, you may use that, but I would not suggest that.

Anyway, you can map serviceA to clustnode1 and serviceB to clustnode2 example of my haresource file

clustnode2 172.23.2.13 mysql
clustnode1 172.23.2.14 ldap
clustnode2 172.23.2.15 cyrus

I use GFS for storage so I don't have a problem with concurrent access to data and can run as many services as is manageable by these machines.
Here clustnode2 is the master for mysql and cyrus which clustnode1 is the master for ldap.
If clustnode2 goes down then clustnode1 takes over all the ip addresses and the services.

Wednesday, October 20, 2010

Advantages of Ethernet Tunneling through PCI Express

There are many advantages to tunneling Ethernet packets through PCIe, including:

1. PCIe has higher bandwidth than Ethernet (64 Gbps today vs. 10 Gbps);
2. PCIe has lower latency compared to any other protocol;
3. PCIe has the lowest per port pricing (1/10) compared to any higher-level protocol;
4. Ethernet tunneling saves power and cost; and
5. Ethernet tunneling uses the same software stack protecting software investment.

These advantages are compelling.

以上文字擷取自以下網址
http://www.wwpi.com/index.php?option=com_content&view=article&id=6540:ethernet-tunneling-through-pci-express-inter-processor-communication-low-latency-storage-io&catid=99:cover-story&Itemid=2701018

Saturday, March 06, 2010

spew - measures I/O performance and/or generates I/O load

無意間找到一個軟體
http://spew.berlios.de/
看起來應該是可以用來測試 I/O performance
有空再來試試看, 先把網址記起來免得忘記了

Wednesday, November 04, 2009

解決在 Busybox中 ctrl+c 沒有作用的問題

最近在公司弄 embedded linux 的東西,
boot 完 kernel 進到 busybox 後,
發現 ctrl+c 竟然沒有作用(沒有 ctrl+c真的很不方便),
我們可以看一下當ctrl+c 按下所經過的路徑

driver/char/n_tty.c :
n_tty_receive_buf() -->
n_tty_receive_break() -->
isig(SIGINT,tty,1)-->

kernel/signal.c :
kill_pgrp(tty->pgrp, SIGINT, 1)-->
kill_pgrp_info(SIGINT, __si_special(priv), pid)-->

最後會中斷每個 group number 為 tty->pgrp的task,
只要process具有相同的group id
不管 background / foreground 都會被 kill 掉,
ctrl+c是傳送到 /dev/ttyS0 driver 的,
在原本的 root file system 並沒有 ttyS0 這個 device node,
使用的是 /dev/console 這個 device
後來在 busybox 網站  FAQ 查到

http://www.busybox.net/FAQ.html#job_control

Job control will be turned off since your shell can not obtain a controlling terminal. This typically happens when you run your shell on /dev/console. The kernel will not provide a controlling terminal on the /dev/console device. Your should run your shell on a normal tty such as tty1 or ttyS0 and everything will work perfectly. If you REALLY want your shell to run on /dev/console, then you can hack your kernel (if you are into that sortof thing) by changing drivers/char/tty_io.c to change the lines where it sets "noctty = 1;" to instead set it to "0". I recommend you instead run your shell on a real console... 

解決方法如下

第一種方法
1. 在 dev 目錄下建立 ttyS0 device node, 將 console link 到 ttyS0

#mknod --mode 666 ttyS0 c 4 64
#ln -s ttyS0 console


2. 修改 /etc/inittab

#vi /etc/inittab
console::sysinit:-/etc/rcS
ttyS0::respawn:-/bin/sh


第二種方法
Hack kernel
修改 drivers/char/tty_io.c
將 noctty = 1 的地方改為 noctty = 0
然後 /etc/inittab 就可以寫成
console::sysinit:-/etc/rcS
console::respawn:-/bin/sh

重新製作 root file system 測試果然 ok了
 
不過 busybox 的建議是在 real console 下 run shell ....

Monday, November 02, 2009

BUG_ON(size & (size - 1));

今天看 Linux kernel 中 kfifo (circular buffer) 的 code, 無意間看到一行code


/* size must be a power of 2 */
BUG_ON(size & (size - 1));

這真是個好用的判断技巧