2008年1月16日 星期三

合併網卡-Debian and ubuntu with a 2.6 kernel

Setup Bonding Ethernet on Debian and ubuntu with a 2.6 kernel

To use Bonding Ethernet for High-Availability (fail-over) on
Debian (Woody, Sarge,etch or Sid with a 2.4.x kernel) and ubuntu you need to:

install package ifenslave-2.6.To install this package follow this command

#apt-get install ifenslave-2.6

make sure the real NICs kernel modules are loaded automatically

edit /etc/network/interfaces to look like this:

iface bond0 inet static
address 10.31.1.5
netmask 255.255.255.0
network 10.31.1.0
gateway 10.31.1.254
up /sbin/ifenslave bond0 eth0
up /sbin/ifenslave bond0 eth1


comment or borrow the lines referring to your real NICs in the same file

add the following lines to your /etc/modprobe.d/arch/i386:

alias bond0 bonding

options bonding mode=1 miimon=100 downdelay=200 updelay=200

2008年1月15日 星期二

OpenGFS description

http://linux.softpedia.com/get/System/Filesystems/OpenGFS-1471.shtml

OpenGFS is a clustered filesystem. It's usefulness is thought to be mostly in SAN's, but goes well beyond that. It can be used with iSCSI, HyperSCSI, and even firewire.

OpenGFS is undergoing many changes at the moment, we appreciate any help in testing the current development branch. For those less adventurous souls we have our current stable branch (0.2.1).

Here are some key features of "OpenGFS":

Multiple clients per server

· We don't have to worry about two reads or writes overlapping on the server as the server opens the block file in syncronous mode, and network receives are keep apart with mutexes. Everything else must be handled by higherlevel layers, e.g. the OpenGFS filesystem.

Transparent reconnection.

· The loss of a server does not mean that programs using the device file immediatily get errors. Activity on the device pauses, and remains paused until gnbd gets reconnected to a server, and re-issuse any unfulfilled requests.

Other proccesses Suspending IO.

· Simply, some other process can come and state that the device should stop talking (or trying to talk) to the server. Think `Entering cluster tansition'

Notification of change of server.

· Just change the ip and port of where the device looks for a server.

Resumption of service.

· Connect to the server again, and re-issue any requests that haven't gotten replies yet.

Currently gnbd has a kernel thread and a TCP socket for each opened block device. If either of these fail, the device is still opened. This is to allow modification of some parameters via ioctl.

There is a short and simple userland program to set the ip and port. Done with those ioctls.

Server ip and port can also be specified at module load. This uses the config option durring insmod. More details in the main.c file.

FreeBSD UFS/ZFS Snapshot

http://people.freebsd.org/~rse/snapshot/

Additionally, with the help of md(4) and mdconfig(8) you can mount UFS snapshots as read-only filesystems, too. For illustration purposes, look at this sample session where a snapshot of /var is created on UFS:

# echo "before" >/var/tmp/foo.txt
# ls -l /var/tmp/foo.txt
-rw-r--r-- 1 root wheel 7 Sep 3 16:19 /var/tmp/foo.txt

# test -d /var/.snap mkdir /var/.snap
# mount -u -o snapshot /var/.snap/test /var
# ls -l /var/.snap/test
-r-------- 1 root operator 2147483784 Sep 3 16:19 /var/.snap/test

# echo "after" >/var/tmp/foo.txt
# ls -l /var/tmp/foo.txt
-rw-r--r-- 1 root wheel 6 Sep 3 16:20 /var/tmp/foo.txt

# mdconfig -a -t vnode -f /var/.snap/test -u 1
# mount -o ro /dev/md1 /mnt
# ls -l /mnt/tmp/foo.txt /var/tmp/foo.txt
-rw-r--r-- 1 root wheel 7 Sep 3 16:19 /mnt/tmp/foo.txt
-rw-r--r-- 1 root wheel 6 Sep 3 16:20 /var/tmp/foo.txt
# cat /mnt/tmp/foo.txt /var/tmp/foo.txt
before
after

# umount /mnt
# mdconfig -d -u 1
# rm -f /var/.snap/test



The same session with /var on ZFS could look like this:

# echo "before" >/var/tmp/foo.txt
# ls -l /var/tmp/foo.txt
-rw-r--r-- 1 root wheel 7 Sep 3 16:19 /var/tmp/foo.txt

# zfs snapshot `zfs list -H -o name /var`@test
# ls -ld /var/.zfs/snapshot/test
drwxr-xr-x 23 root operator 23 Sep 3 16:19 /var/.zfs/snapshot/test

# echo "after" >/var/tmp/foo.txt
# ls -l /var/tmp/foo.txt
-rw-r--r-- 1 root wheel 6 Sep 3 16:20 /var/tmp/foo.txt

# ls -l /var/.zfs/snapshot/test/tmp/foo.txt /var/tmp/foo.txt
-rw-r--r-- 1 root wheel 7 Sep 3 16:19 /mnt/tmp/foo.txt
-rw-r--r-- 1 root wheel 6 Sep 3 16:20 /var/tmp/foo.txt
# cat /var/.zfs/snapshot/test/tmp/foo.txt /var/tmp/foo.txt
before
after

# zfs destroy `zfs list -H -o name /var`@test

2008年1月14日 星期一

FREENAS 學習備忘

UnisonGUI for WindowsXP v. 0.2.1.26
http://www.freenaskb.info/kb/?View=entry&EntryID=211

freenas iscsi
http://www.freenaskb.info/kb/?View=entry&EntryID=204

FreeNAS Setup and User guide
http://www.freenas.org/index.php?option=com_openwiki&Itemid=30&id=sug:en#services

2008年1月10日 星期四

iscsi-target

目的是做模擬磁盤陣列櫃

三台服務器
01-----iscsi-target---192.168.0.1
02----iscsi-initiator--192.168.0.2
03----iscsi-initiator--192.168.0.3

首先去下載iscsi-target(下載地址自己google吧)!
有些喜歡下載源代碼包編譯安裝.有些喜歡下載src.rpm包.我就圖方便省事.直接下載了iscsi-target0.42.src.rpm.
安裝的環境是RHEL U4 內核為kernel-2.6.9.4.10_ELsmp x86_64
安裝步驟.

01# rpmbuild -ba iscsitarget-0.42.src.rpm
01# rpm -ivh /usr/src/redhat/RPMS/x86_64/iscsitarget*

01# vi /etc/ietd.conf
# iscsi target configuration
Target iqn.2000-12.com.digicola:storage.lun1
IncomingUser gfs secretsecret
OutgoingUser
Lun 0 Path=/dev/sdb,Type=fileio
Alias iDISK0

配置以上內容.
最後

01# /etc/init.d/iscsi-target start

01# netstat -an
檢查是否開啟3260端口

這樣iscsi-target就算配置完成了.
接下來配置iscsi-initiator
iscsi-initiator在RHEL系統上默認都安裝的.如果沒有請用查找iscsi-initiator的rpm包安裝

02#vi /etc/iscsi.conf
DiscoveryAddress=192.168.0.1
OutgoingUserName=gfs
OutgoingPassword=secretsecret
LoginTimeout=15
DiscoveryAddress=192.168.0.1

配置完成後

02#/etc/init.d/iscsi start

iscsi啟動成功.
fdisk -l
就能看到多一個分區.
03配置和02一樣.
配置成功後你就可以為所欲為了.哈哈.

Linux下DOM製作流程

製作系統盤現在使用32M電子盤(DOM)。以下比較詳細的說明怎樣製作一個嵌入式Linux系統盤。

1. 首先可以先把電子盤掛到一台機器上作為從盤,使用PQMagic分區工具進行分區操作,因為DOS分區所有內容只有1.56M,所以第一個分區只需要2M就足夠了。分區類型是基本分區(primary),文件系統類型是FAT,並且設為活動分區(A ctive)。

2. Linux分區可以現在分好,也可以等製作文件系統時再分。現在分可以把剩餘空間都作為第二個分區。分區類型是基本分區(primary),文件系統類型是Linux Ext2。

3. 重啟機器,可以看到一個兩兆的分區。把編譯好的Linux內核和DOS加載工具等內容(見系統文件清單)全部拷到這個分區上,第一個分區就做好了。如果分了三個區,而且想把第三個分區作為工作分區,則需要把AUTOEXEC.BAT中的工作分區指向 /dev/hda2 改為/dev/hda3即可。

4. 在機器上安裝一個Linux系統,把電子盤掛在IDE2上。如果沒有進行第二步操作,打開一個終端,進行分區和製作文件系統操作。
fdisk /dev/hdd
回車,出現提示,輸入p,可以看見現在hdd的分區狀態;
輸入n,增添分區,回車;
輸入2,指定設備號,回車;
輸入3,指定起始柱面號,回車;
輸入+30M,指定分區大小,回車;
輸入w,把剛才的分區設置寫入分區表;
mkfs.ext2 /dev/hdd2,製作文件系統,類型是ext2。
mount /dev/hdd2 /mnt,加載到主盤的mnt下

5. 現在開始製作第二個分區上的文件系統。因為原有文件系統大約有53M左右,必須有所刪減。而其中最大的是lib,大約佔了40M,而使用lib中庫的主要是bin和sbin中的工具。因而使用了嵌入式Linux常用的busybox和tinylog in。
從網上下載了busybox-1.00-pre3.tar和tinylogin-1.4.tar,把busybox-1.00-pre3.tar解壓到一個指定的目錄下。
運行「make menuconfig」命令,選擇想要在工作系統中使用的工具。保存設置。
找到init目錄下的init.c文件,找到 INIT_SCRIPT "/etc/init.d/rcS",更改為「/etc/rc」。
看Makefile中是否有「DOSTATIC = false」,如果有,改false為true,使busybox靜態編譯。
修改了/usr/include/asm/errno.h頭文件中27行的一個錯行,否則編譯通不過。
在當前目錄下用命令「make menuconfig」進入工具選擇界面,選項如下所示:
進入「Build Options」 ,選擇「Build Busybox as a static binary」選項;
進入「Archival Utilities」 ,選擇「gunzip, gzip, tar」 選項;
進入「Console Utilities」 ,選擇「clear, reset」 選項;
進入「Finding Utilities」 ,選擇「find, grep」 選項;
進入「Init Utilities」 ,選擇全部的選項;
進入「Login/Password Management Utilities」 ,選擇除第一項和最後兩項的全部選項;
進入「Linux Module Utilities」 ,選擇全部的選項;
進入「Networking Utilities」 ,選擇「arping, ftpget, ftpput, hostname, ifconfig下一共5項, ifupdown, use busybox ifconfig and route applets, Enable support for IPV4, Enable support for IPX, Enable mapping support, inetd全選,ip全選, ipcalc全選, netstat, nslookup, ping, telnet, telnetd」 選項;
進入「Process Utilities」 ,選擇「free, kill, killall, ps, uptime」 選項;
進入「Linux System Utilities」 ,選擇「dmesg, fdisk, write support, 」 選項,其餘默認。
別的其他選項默認,保存退出。

make,在當前目錄下生成一個大約800k的「busybox」,就是我們所需要的了。把它拷到mnt下的bin目錄下。然後就可以把自己想要的工具在bin下面建立一個鏈接就可以了。如:
ln –s busybox cp
ln –s busybox ls
……
對於tinylogin,操作和busybox完全相同。也要靜態編譯,然後把login,passwd,adduser等帳戶管理的工具建立和tinylogin的鏈接即可。需要注意的是有些工具是在sbin當中的,所以也可以把tinylogin拷到 sbin目錄下,bin下的工具要想鏈接到tinylogin,可以如下操作:
ln –s tinylogin ../bin/login

6. 有些bin和sbin下的工具是busybox和tinylogin中所沒有的,必須從完整的系統中拷過來,例如在這個系統中,由於選擇vi時編譯出錯,所以vi是直接從主盤上拷過來的,而且必須把這個工具使用的相應的庫也拷到lib下面。如使用 ldd vi,就可以看到vi使用了哪些庫,然後把這些庫拷到/mnt/lib下就可以了。

7. 在bin中還有兩個命令ro和rw,是自己定義的兩個可執行腳本。作用是使系統變更為只讀和可讀寫,也要拷到bin下面。


8. 在lib中建立目錄modules和tls,使用命令mkdir modules和 mkdir tls。把原來lib中這兩個目錄下的東西拷過來即可。把應用程序所需要的cpr-2.0.1.so和jpeg-6a.so拷到lib中。這樣bin,sbin和lib就做好了。這樣lib只有8M左右。

9. 把剩下的目錄etc、dev、proc、usr、var、boot、mnt和root全部拷到mnt目錄下。因為要求系統不使用頁面交換,所以在etc下的rc腳本中添加了一句swapoff –a
如果需要新添加用戶或者更改用戶密碼,還需要建立一個home目錄。

10.這時mnt下所用空間大小大約是16M左右。umount /mnt,電子盤就可以在工作機上啟動了。

以下是各目錄中建立鏈接的詳細清單:
bin:
ln –s busybox ash
ln –s busybox cat
ln –s busybox chmod
ln –s busybox chown
ln –s busybox chroot
ln –s busybox chvt
ln –s busybox clear
ln –s busybox cp
ln –s busybox cut
ln –s busybox date
ln –s busybox dd
ln –s busybox df
ln –s busybox dirname
ln –s busybox dmesg
ln –s busybox du
ln –s busybox echo
ln –s busybox env
ln –s busybox false
ln –s busybox find
ln –s busybox grep
ln –s busybox gunzip
ln –s busybox gzip
ln –s busybox head
ln –s busybox hostname
ln –s busybox id
ln –s busybox insmod
ln –s busybox kill
ln –s busybox killall
ln –s busybox klogd
ln –s busybox linuxrc
ln –s busybox ln
ln –s busybox logger
ln –s ../sbin/tinylogin login
ln –s busybox ls
ln –s busybox mkdir
ln –s busybox mkswap
ln –s busybox more
ln –s busybox mount
ln –s busybox mv
ln –s busybox netstat
ln –s ../sbin/tinylogin passwd
ln –s busybox pidof
ln –s busybox ps
ln –s busybox pwd
ln –s busybox reset
ln –s busybox rm
ln –s busybox rmdir
ln –s busybox route
ln –s busybox sh
ln –s busybox sleep
ln –s busybox sort
ln –s ../sbin/tinylogin su
ln –s busybox sync
ln –s busybox tar
ln –s busybox test
ln –s busybox touch
ln –s busybox true
ln –s busybox tty
ln –s busybox umount
ln –s busybox uname
ln –s busybox uptime
ln –s busybox wc
ln –s busybox zcat

sbin:
ln –s tinylogin addgroup
ln –s tinylogin adduser
ln –s tinylogin delgroup
ln –s tinylogin deluser
ln –s tinylogin sulogin

lib:
ln –s ld-2.3.2.so ld-linux.so.2
ln –s libacl.so.1.0.3 libacl.so.1
ln –s libattr.so.1.0.1 libattr.so.1
ln –s libc-2.3.2.so libc.so.6
ln –s libcom_err.so.2.0 libcom_err.so.2
ln –s libcrypt-2.3.2.so libcrypt.so.1
ln –s libdl-2.3.2.so libdl.so.2
ln –s libe2p.so.2.3 libe2p.so.2
ln –s libext2fs.so.2.4 libext2fs.so.2
ln –s libgcc_s-.3.2.2-20030225.so.1 libgcc_s.so.1
ln –s libm-2.3.2.so libm.so.6
ln –s libnss1_files-2.2.4.so libnss1.so.1
ln –s libnss_files-2.2.4.so libnss_files.so.1
ln –s libnss_files-2.3.2.so libnss_files.so.2
ln –s libpam.so.0.75 libpam.so.0
ln –s libpthread-0.10.so libpthread.so.0
ln –s libresolv-2.3.2.so libresolv.so.2
ln –s libtermcap.so.2.0.8 libtermcap.so.2
ln –s libutil-2.3.2.so libutil.so.1
ln –s libuuid.so.1.2 libuuid.so.1
lib/tls:
ln –s libc-2.3.2.so libc.so.6
ln –s libm-2.3.2.so libm.so.6
ln –s libpthread-0.10.so libpthread.so.0

2008年1月3日 星期四

Port Multiplier support for sata_sil24 and ahci

PMP(Port Multiplier) support is tested with the following controllers.

* Silicon Image 3124 (1095:3124)
* Silicon Image 3132 (1095:3132)
* Intel ICH9R (8086:2922)
* JMicron JMB360 (197b:2360)
* JMicron JMB363 (197b:2363)

With the following Port Multipliers.

* Silicon Image 3726 (1095:3726)
* Silicon Image 4726 (1095:4726)
* Silicon Image 5744 (1095:5744)
* Marvell 88SM4140 (11ab:4140)

運作模式:

5埠 SATA轉卡 (SiI 3726)

外接eSATA介面卡( SiI 3132)
5 bay SATA外接機箱

相關網址:
LibAta-tj PATCH: http://home-tj.org/wiki/index.php/Libata-tj-stable
KERNEL-SOURCE: http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.23.tar.bz2

測試主機:

OS : Unbutu 7.10 Server ( AMD64bit)

Kernel : 2.6.22-14-server

Main_board : 技嘉 GA-MA69G-S3H

更新過程:

1.更新kernel

cd /usr/src

wget http://ftp.ntu.edu.tw/ftp/linux/kernel/v2.6/linux-2.6.23.tar.bz2

tar -jxvf linux-2.6.23.tar.bz2

ln -s linux-2.6.23 linux

cd linux

2.linata-tj 修補

tar -jxvf libata-tj-2.6.23-20071011.tar.bz2

patch -p1 < /path/libata-tj-2.6.23-20071011/2.6.23-to-acc27ff7f1262c40d26adc834df8be57f8c4c0d0.patch

修補完畢..

3.自編kernel

apt-get install build-essential dialog kernel-package libncurses5-dev fakeroot

make menuconfig (儲存設定備份.config)

make-kpkg clear (清除舊的編譯檔)

fakeroot make-kpkg --initrd --append-to-version=-custom kernel_image kernel_headers

dpkg -i linux-image.deb

dpkg -i linux-headers.deb

待續......Testing

How To Compile A Kernel - The Ubuntu Way

http://www.howtoforge.com/kernel_compilation_ubuntu

1.Preliminary Note
#su root
#apt-get update

2.Install Required Packages For Kernel Compilation
#apt-get install kernel-package libncurses5-dev fakeroot wget bzip2
3.Download The Kernel Sources
#cd /usr/src
#wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.18.1.tar.bz2
#tar xjf linux-2.6.18.1.tar.bz2
#ln -s linux-2.6.18.1 linux
#cd /usr/src/linux
4.Apply Patches To The Kernel Sources (Optional)
#bzip2 -dc /usr/src/patch.bz2 patch -p1 --dry-run
#bzip2 -dc /usr/src/patch.bz2 patch -p1

5.Configure The Kernel
#cp /boot/config-`uname -r` ./.config
#make menuconfig
6.Build The Kernel
#make-kpkg clean
#fakeroot make-kpkg --initrd --append-to-version=-custom kernel_image kernel_headers

7.Install The New Kernel
#cd /usr/src
#ls -l
On my test system they were called linux-image-2.6.18.1-custom_2.6.18.1-custom-10.00.Custom_i386.deb (which contains the actual kernel) and linux-headers-2.6.18.1-custom_2.6.18.1-custom-10.00.Custom_i386.deb (which contains files needed if you want to compile additional kernel modules later on). I install them like this:
#dpkg -i linux-image-2.6.18.1-custom_2.6.18.1-custom-10.00.Custom_i386.deb
#dpkg -i linux-headers-2.6.18.1-custom_2.6.18.1-custom-10.00.Custom_i386.deb
(You can now even transfer the two .deb files to other Ubuntu systems and install them there exactly the same way, which means you don't have to compile the kernel there again.)

That's it. You can check /boot/grub/menu.lst now, you should find two stanzas for your new kernel there:


#vi /boot/grub/menu.lst
The stanzas that were added on my test system look like these:

title Ubuntu, kernel 2.6.18.1-custom
root (hd0,0)
kernel /boot/vmlinuz-2.6.18.1-custom root=/dev/sda1 ro quiet splash
initrd /boot/initrd.img-2.6.18.1-custom
savedefault
boot

title Ubuntu, kernel 2.6.18.1-custom (recovery mode)
root (hd0,0)
kernel /boot/vmlinuz-2.6.18.1-custom root=/dev/sda1 ro single
initrd /boot/initrd.img-2.6.18.1-custom
boot

2008年1月2日 星期三

Port Multiplier support for sata_sil24 and ahci 核心修補 libata-tj

This is README for libata-tj-2.6.23-20071011
Latest information can be found at the following URL.
http://home-tj.org/wiki/index.php/Libata-tj-stable
You can contact me at
htejun@gmail.com
If the contained information isn't confidential, please cc the
following address.
linux-ide@vger.kernel.org
NOTE: hotplug-by-poll is dropped for now.
This archive contains a patch to update libata of 2.6.23 to libata
devel branch.
* Port Multiplier support for sata_sil24 and ahci
* Bunch of other libata stuff scheduled for 2.6.24 merge
Patches are against Linux v2.6.23.
Apply the contained patch by executing the following in your kernel
tree.
$ patch -p1 < 2.6.23-to-acc27ff7f1262c40d26adc834df8be57f8c4c0d0.patch
PMP support is tested with the following controllers.
* Silicon Image 3124 (1095:3124)
* Silicon Image 3132 (1095:3132)
* Intel ICH9R (8086:2922)
* JMicron JMB360 (197b:2360)
* JMicron JMB363 (197b:2363)
With the following Port Multipliers.
* Silicon Image 3726 (1095:3726)
* Silicon Image 4726 (1095:4726)
* Silicon Image 5744 (1095:5744)
* Marvell 88SM4140 (11ab:4140)

Various disks from all major vendors have been tested and ATAPI device
works too. With the patch applied, things should just work when you
plug things in.
PMP port number corresponds to SCSI ID, so if the controller the PM is
attached to is ata2 and a harddrive is connected to the third port of
the PM, it will be identified as 'ata2.03' and the corresponding SCSI
H:C:I:L would probably be '1:0:3:0'. Please note that mapping between
ATA and SCSI host numbers is not fixed.
PMP support is fully compatible with Power Management and ATA-ACPI.
If you have the correct setup, libata will happily suspend and resume
with PMP attached.
Caveats/notes:
* Sil4726 is a bit too quirky. Without the first fan-out port
occupied, the thing acts really weirdly. As long as the first port
is occupied, it works okay. This is reportedly fixed by new
firmware. I tried to update the firmware but installing 3124 driver
on Windows was just too difficult for me and I gave up after thirty
painful minutes. Anyone up for testing?
* Again, Sil4726 doesn't like ahci driver initialization sequence.
During driver initialization, the whole controller is reset and the
PHY goes offline and comes back. Sil4726 doesn't like it and goes
out for lunch for several secs after that which makes initial
probing think that the port is empty. After probing is complete,
Sil4726 comes back and gets detected but at that point detection is
asynchronous and if boot device is on one of fan-out ports, it can
be a problem. Again, this might have been fixed by new firmware.
Anyone up for testing?
* The long boot delay on ASUS boards with on-board PMP chips should be
fixed by this patchset but I don't have such a board or Sil4723
which is used on those boards, so I'm not sure. Anyone up for
testing?
* ICH9R has six ports. The last two sometimes behave erratically.
If Sil3726 is attached to one of those ports during probing, the
controller causes IRQ storm even though all IRQs are masked off.
The controller doesn't even set IRQ status bit for the port. It
looks like a hardware bug.
* Resume might take some time as libata spins up each disk
sequentially. This will be improved in future.
* AHCI controllers + SIMG 5744 doesn't work. Have no idea whatsoever.
Have fun.
--
tejun