安裝套件: apt-get install python2.5-examples
套件路徑: /usr/share/doc/python2.5/examples/Tools/freeze/freeze.py
指令參數: python freeze.py -h
測試編譯: python /path/to/freeze.py [參數] 編譯檔名.py
# python /path/to/freeze.py -o dist test1.py
# cd dist
# make
測試編譯後的linux執行檔
# ./test1
---
錯誤提示:
缺少python2.6/config/config.c.in
安裝以下套件即可
apt-get install python2.6-dev
錯誤提示:
/usr/lib/python2.6/config/libpython2.6.a(posixmodule.o): In function `posix_tmpnam':
(.text+0x783): warning: the use of `tmpnam_r' is dangerous, better use `mkstemp'
/usr/lib/python2.6/config/libpython2.6.a(posixmodule.o): In function `posix_tempnam':
(.text+0x865): warning: the use of `tempnam' is dangerous, better use `mkstemp'
config.o:(.data+0x98): undefined reference to `init_warnings'
collect2: ld returned 1 exit status
make: *** [client] Error 1
安裝以下套件即可
apt-get install ?????
---
安裝 psyco 加速模組
# wget http://downloads.sourceforge.net/project/psyco/psyco/1.6/psyco-1.6-linux.i386-2.5.tar.gz?use_mirror=nchc
# tar xzvf psyco-1.6-linux.i386-2.5.tar.gz
# cd psyco-1.6
# cp -rf psyco /usr/lib/python2.5/site-packages/
#加入 import psyco
try:
import psyco
psyco.profile()
except:
pass
加入psyco模組,再用freeze作編譯,正常可執行
2009年8月29日 星期六
Python Compiler (freeze) for Linux
2009年7月23日 星期四
[Ubuntu] 取得硬碟 UUID
Ubuntu fstab 是採用 uuid 處理,所以有幾個方法可以取得 uuid
vol_id 指令
sudo vol_id /dev/sda1
用 ls 指令
ls -l /dev/disk/by-uuid/
用blkid
blkid /dev/sda1
2009年7月18日 星期六
[紀錄]找回Linux丟失的RAID設備
轉載:http://blog.csdn.net/shaohui/archive/2009/03/13/3985804.aspx
最近遇到一件讓我很頭疼的事情,自己維護的Linux文件服務器一下子無緣無故崩掉了。 根文件系統裏面很多東西文件消失了。所有的數據全在一個RAID設備上面,但是/etc/下的mdadm.conf也沒有了。UUID丟失了。
這個RAID上面有1T 的數據,備份服務器空間不足,沒有全部備份,數據丟失了還不讓我瘋掉才怪呢。
直覺告訴我RAID上的數據是可以找回來的, 於是把系統重新安裝了一下,查了一下RAID的資料,其實只有一條命令就可以恢複安裝系統以前的RAID設備.
mdadm -A /dev/md0 /dev/sdb1 /dev/sdc1 /dev/sdd1
其中/de/sdb1 /dev/sdc1 /dev/sdd1,是以前RAID當中的幾塊硬盤。
#RAID的配置文件
/etc/mdadm.conf 的文件主要提供我們方便管理,編輯這個文件可以讓RAID更好的為我們工作,當然這個步驟不是必要的.不經過編輯配置文件也可以讓RAID工作。
首先掃描系統中的全部陣列
mdadm --detail -scan
關於UUID,也很容易用mdadm重新找回,然後重新生成以下mdadm.conf,問題居然就這麼解決了。
不過,這樣驚險的時候,以後再也不敢這麼折騰了。
2009年5月12日 星期二
UFW簡易設定
ufw disable
ufw default deny
ufw logging OFF
ufw enable
ufw allow 22/tcp
ufw allow proto tcp from 192.168.1.0/24 to 192.168.1.117 port 3260
ufw allow proto tcp from 192.168.1.0/24 to 192.168.1.117 port 20000
ufw allow proto tcp from 192.168.1.0/24 to 192.168.1.117 port 139
ufw allow proto tcp from 192.168.1.0/24 to 192.168.1.117 port 445
ufw allow proto udp from 192.168.1.0/24 to 192.168.1.117 port 137
ufw allow proto udp from 192.168.1.0/24 to 192.168.1.117 port 138
#關閉/刪除 條件
ufw delete allow proto tcp from 192.168.1.0/24 to 192.168.1.117 port 3260
ufw delete allow proto tcp from 192.168.1.0/24 to 192.168.1.117 port 20000
ufw delete allow proto tcp from 192.168.1.0/24 to 192.168.1.117 port 139
ufw delete allow proto tcp from 192.168.1.0/24 to 192.168.1.117 port 445
ufw delete allow proto udp from 192.168.1.0/24 to 192.168.1.117 port 137
ufw delete allow proto udp from 192.168.1.0/24 to 192.168.1.117 port 138
Bonding in Ubuntu
Why you may want to do this:
Network Bonding, otherwise known as port trunking allows you to combine multiple network ports into a single group, effectively aggregating the bandwidth of multiple interfaces into a single connection. For example, you can aggregate two gigabyte ports into a two-gigabyte trunk port. Bonding is used primarily to provide network load balancing and fault tolerance. First, we will run two different network tools to check for network connectivity and capability. Run mii-tool to check your interfaces for connectivity:
mii-tool
For our purposes, we will assume you have three interfaces. The result of the mii-tool command is listed below:
eth0: negotiated 100baseTx-HD, link ok
eth1: negotiated 100baseTx-HD, link ok
eth2: negotiated 100baseTx-HD, link ok
Next run ethtool for each interface to check to see what capabilities:
ethtool eth0 && ethtool eth1 && ethtool eth3
The result of the ethtool command is listed below:
Settings for eth0:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Advertised auto-negotiation: Yes
Speed: 100Mb/s
Duplex: Half
Port: MII
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: g
Wake-on: g
Current message level: 0x00000007 (7)
Link detected: yes
Settings for eth1:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised auto-negotiation: Yes
Speed: Unknown! (65535)
Duplex: Unknown! (255)
Port: Twisted Pair
PHYAD: 0
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: umbg
Wake-on: d
Current message level: 0x00000007 (7)
Link detected: no
Settings for eth3:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised auto-negotiation: Yes
Speed: Unknown! (65535)
Duplex: Unknown! (255)
Port: Twisted Pair
PHYAD: 0
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: umbg
Wake-on: d
Current message level: 0x00000007 (7)
Link detected: no
Next, we need to install ifenslave. It’s a simple install:
apt-get update && apt-get install ifenslave
Options for mode types:
You can set up your bond interface according to your needs. In order to do this, you simply change the mode type depicted in the examples below (mode=X). There are seven mode types available. They are as follows:
mode=0
This mode uses the Round-robin policy: Transmit packets in sequential order from the first available slave through the last. This mode provides load balancing and fault tolerance.
mode=1
This mode uses an Active-backup policy: Only one slave in the bond is active. A different slave becomes active if, and only if, the active slave fails. The bond's MAC address is externally visible on only one port (network adapter) to avoid confusing the switch. This mode provides fault tolerance. The primary option affects the behavior of this mode.
mode=2
Transmit based on [(source MAC address XOR'd with destination MAC address) modulo slave count]. This selects the same slave for each destination MAC address. This mode provides load balancing and fault tolerance.
mode=3
Broadcast policy: transmits everything on all slave interfaces. This mode provides fault tolerance.
mode=4
IEEE 802.3ad Dynamic link aggregation. Creates aggregation groups that share the same speed and duplex settings. Utilizes all slaves in the active aggregator according to the 802.3ad specification.
*Pre-requisites:
1. Ethtool support in the base drivers for retrieving the speed and duplex of each slave.
2. A switch that supports IEEE 802.3ad Dynamic link aggregation. Most switches will require some type of configuration to enable 802.3ad mode
mode=5
Adaptive transmit load balancing: channel bonding that does not require any special switch support. The outgoing traffic is distributed according to the current load (computed relative to the speed) on each slave. Incoming traffic is received by the current slave. If the receiving slave fails, another slave takes over the MAC address of the failed receiving slave.
*Prerequisite: Ethtool support in the base drivers for retrieving the speed of each slave.
mode=6
Adaptive load balancing: includes balance-transmit load balancing plus receive load balancing for IPV4 traffic, and does not require any special switch support. The receive load balancing is achieved by ARP negotiation. The bonding driver intercepts the ARP Replies sent by the local system on their way out and overwrites the source hardware address with the unique hardware address of one of the slaves in the bond such that different peers use different hardware addresses for the server.
Now append the following items to your aliases file:
pico /etc/modprob.d/aliases
# Append to the bottom of this file:
alias bond0 bonding
alias eth0 e100
alias eth1 e100
alias eth2 e100
options bonding mode=0 miimon=100
Next, append the following items to your i386 file:
pico /etc/modprob.d/arch/i386
# Append to the bottom of this file:
alias bond0 bonding
options bonding mode=0 miimon=100 downdelay=200 updelay=200
Now we have to modify the interface file. Start off by commenting out any information on the physical interfaces, eth0, eth1, etc, and create a virtual interface such as bond0, configure it similar to below, and be sure to choose a unique hwaddress. Be sure to leave the loopback interface configuration intact.
pico /etc/network/interfaces
It should look something like this:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
#auto eth0
#iface eth0 inet static
# address 192.168.0.120
# netmask 255.255.255.0
# network 192.168.0.0
# broadcast 192.168.0.255
# gateway 192.168.0.1
auto bond0
iface bond0 inet static
address 192.168.0.120
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1
hwaddress ether 00:03:B3:48:50:2C
post-up ifenslave bond0 eth0 eth1
Save the file and then reboot the system:
shutdown -r now
MDADM-raid指令
mdadm --manage --stop /dev/md0
#啟動磁碟陣列
mdadm --assemble --run /dev/md0
#查看RAID狀態
# mdadm --detail /dev/md0
#建立RAID5
mdadm --create /dev/md1 --level=raid5 --raid-devices=5 --chunk=4 /dev/sd{b,c,d,e,f}1
mdadm --create /dev/md1 --level=raid5 --raid-devices=5 --chunk=4 /dev/sd{g,h,i,j,k}1
#建立 RAID0
mdadm --create /dev/md0 --level=raid0 --raid-devices=3 /dev/sda4 /dev/sdb1 /dev/sdc1
mdadm --create /dev/md0 --level=raid0 --raid-devices=5 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde3
#RAID的配置文件
/etc/mdadm.conf 的文件主要提供我們方便管理,編輯這個文件可以讓RAID更好的為我們工作,當然這個步驟不是必要的.不經過編輯配置文件也可以讓RAID工作。
首先掃描系統中的全部陣列
# mdadm --detail -scan
ARRAY /dev/md0 level=raid5 num-devices=3 UUID=37230e69:51bcf476:9889f244:18b07644
devices=/dev/sda,/dev/sdb,/dev/sdd,/dev/sdc
# vi /etc/mdadm.conf
-------------------------------------------------------------------------------------------------------
DEVICE /dev/sdb1 /dev/sdc1 /dev/sdd1
ARRAY /dev/md0 level=raid5 num-devices=3 UUID=37230e69:51bcf476:9889f244:18b07644
devices=/dev/sda,/dev/sdb,/dev/sdd,/dev/sdc
-------------------------------------------------------------------------------------------------------
其中的資料就如同 mdadm --detail -scan 一樣定義了RAID基本資料.
如果你不想手動設定用下面的指令同樣也可以.
mdadm --detail -scan >> /etc/mdadm.conf
#RAID的管理
mdadm /dev/md0 --add /dev/sdd1
mdadm /dev/md0 --fail /dev/sdc1
mdadm /dev/md0 --remove /dev/sdc1
mdadm --manage --run /dev/md0 重建指令 !!小心使用!!
#spare-group
#Multipath
mdadm -C /dev/md0 --level=multipath --raid-devices=2 /dev/sda1 /dev/sdb1
ARRAY /dev/md0 level=raid5 num-devices=5 metadata=00.90 spares=1 UUID=90dcc677:e6ef7c62:9baf8322:4f9d823d
ARRAY /dev/md1 level=raid5 num-devices=5 metadata=00.90 spares=1 UUID=981e1b70:736d1fb5:9baf8322:4f9d823d
2008年3月22日 星期六
2008年1月3日 星期四
Port Multiplier support for sata_sil24 and ahci
* 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
2007年10月19日 星期五
由日本發起、新的開放系統Mona OS
發表人 droger 於 2007/10/9 0:11:09 (1591 人讀取)
新聞來自 http://www.osnews.com/
Mona OS是一個由C++寫成的一個MicroKernel的系統,在另一個部落格當中看到
是從日本一個使用度相當高的web討論版2ch所聚眾發起的,主要特色在於系統簡潔
適合讓學校或寫程式針對作業系統方面來教學使用,Mona OS是採MIT授權發行
以下是新聞擷取
引言:
MonaOS is a free operating system. It's new, small, simple, open source and well structured. So, MonaOS may be suitable for education of operating system and program at school." It's a microkernel-based operating system, MIT-licensed, and available for IA-32.
全文網址
http://www.osnews.com/story.php/18732/Introducing-MonaOS
http://monaos.org/about.html
