2011年8月2日 星期二

新版 Linux 的 console 管理

作者: Baron. Wan

   過去使用 Redhat 及 CentOS, 知道要管理/控制 console, 可在 /etc/inittab 中進行. 但新版Linux (Fedora 12以上吧, 及 sl6 linux) 的 inittab 中, 只存在 runlevel 的該行敘述, 其他相關 console 設定都已經移到 /etc/event.d/ 當中, 其中 tty1~tty6, 以及 serial 則是對於 console 有效管理的設定檔; 

    由於工作中有時需要將建制的系統, 讓User 無法進行 [Ctrl]+[Alt]+[F1]~[F6] 的切換動作, 這時就可以在相關的 tty1~tty6 的設定檔中, 進行相關控制動作, 方式就是把各設定檔中最後一行的敘述:exec /sbin/mingetty 註解掉即可. 

    另外, 測試中我發現一項有趣的事情, 那就是如果我將 /etc/securetty 的內容全部註解掉, 則 tty1~tty6 就無法進行 root 的 login 作業. 小技巧 ~ 呵呵.

2011年7月21日 星期四

我的客製化光碟

作者: Baron. Wan



    在網路上, 只要你打個 linux 客製化 光碟 的字樣, 搜尋引擎就會幫你找出一堆, 但實做起來常感到落東落西的, 而且我就一直覺得, 難道沒有比較方便的做法, 或是如果能夠將它標準化, 其實我在兩年前就做過這樣的研究, 當時也寫了自動化的 script 讓它可以產生出真正自己要的安裝光碟, 不過當時的研究花的時間頗長, 之後又沒有做完善的注釋, 以至於兩年後的今天, 原以為我自離開那家公司後, 可能很難有機會再用到了....不過因為腦袋有著之前的研究紀錄, 關鍵的地方它都幫我一一標註, 所以我只花了少許的時間, 一方面再次確認與之前的記憶是否更新或衝突, 另一方面則是再次著手撰寫 shell script, 以便於日後客製化的過程, 但是很抱歉的是, 在這裡我是不會將 shell script 一一公布, 因為那是我自己花時間研究的, 同時我認為給魚吃, 不如教會怎麼釣魚, 雖然我有個朋友每次都苦口婆心的傳授我一些釣魚的訣竅, 不過可能要等我上心了, 我才會想去好好了解,...哈哈, 話題說遠了, 現在, 來體會這個經過我邏輯化的製作過程吧....呵呵 (^^)

    我就不說過去的光碟格式內容了, 因為那已經是過去, 隨著時間也將淹沒掉, 目前我測試的系統是 SL6 Linux, 或是 fedora 大概 10版以後是一樣的吧, 沒去考究它, 不過就算不一樣, 也只是增加/減少 hdlists 的這個檔案吧. 我測試的這個系統(SL6), 還真是進化了! Install 時不但有 mini (base) 系統環境可選擇, 而且它可是我看到目前安裝完 Linux 後, 最節省系統資源的一套OS了, 真的是好東西呀!! ^^, 只是, 習慣 RHEL 或 CentOS 的使用者們, 剛開始接觸它會有一點點的不適應感吧, 畢竟我感覺它是介於 Fedora 與 EL 之間呢. 好了, 我廢話很多, 哈哈哈....進入主題.

    請先安裝好一個最基本的系統, 這個系統安裝好之後一定不大, 然後第一步我們先查看系統內安裝了哪些套件, 經由原光碟, 我們將這些套件取出, 我會先放在一個叫 /rpms/rpmsource/ 的目錄中.

    接下來第二步, 我們可以利用 yum, 先將偵測到可 update 的套件, 複製一份到...我叫他 /rpms/rpmupdate/ 目錄中, 集中存放; 然後我要將 /rpms/rpmupdate/ 與 /rpms/rpmsource/ 做比較: /rpms/rpmupdate/ 中有 /rpms/rpmsource/ 中也有該套件的話呢, 由 /rpms/rpmsource/ 中做刪除的動作, 之後確定兩個目錄的內容沒有重複的套件存在. (為何要從 /rpms/rpmsource/ 做刪除呢? 因為 rpmsource/ 內容是原生套件, 也就是舊的, 而 rpmupdate/ 是由 yum update download 下來的, 所以是新的, 如果套件一樣, 當然是把舊的砍了, 留下新的 !! )

    第三步開始, 我們想要製作什麼樣的客製化內容? 就利用 yum 去找, 去安裝, 然後複製一份, 記得是連同相依性的套件, 一起放到 /rpms/rpmsource/ 中, 這過程可能會花較久的時間, 有時候 yum 上沒有, 就要去拜託 G神幫忙, 然後抓下來先安裝, 確定相依性問題...等等. 集合起來後, 我們的 /rpms/rpmsource/ 內容就越來越豐富了.

    接下來是個人習慣了...我先將光碟內容, 完整複製一份到 sl6iso/ 的目錄中, 然後又複製 sl6iso/ 給 custiso/, 目前這兩個目錄內容看起來是一樣的, 漸漸的, 我們要讓他不一樣!

    在 custiso/ 中, 將 Packages/ 和 repodata/ 這兩個目錄內容--[清空], 然後我們把上面1~3步所完成的 rpmsource/ 跟 rpmupdate/ 內的所有套件, 全部, 都複製到 /custiso/Packages/ 中, 現在, /custiso/Packages/ 內的所有套件都是你需要的了.

    接下來這個動作就重要了, 錯誤的話, 光碟不會安裝任何套件, 而且還會跳出錯誤訊息 要求你重新開機.

    comps.xml 這個檔, 網路上也很多人在說明它的格式, 不過自己還真是覺得越參考越亂 (= =|||), 最簡單, 最直接的方式, 就是把原光碟內(sl6iso)中的 repodata/comps.xml 點開來看裡面內容, 它是 xml 檔, 所以前面兩行的抬頭...很重要! 所有的內容都包覆在 [comps] 當中, 仔細看查閱就會發現, 每個主題 [id] 都用一個 [group] 包起來, 無論如何, 系統一定會去找這三個主題: core, base, buildsys-build; [name] 是給人看得, [id] 是給系統看的, 這樣說就懂了吧!! 其次是 [default] 不管原先是 true 還是 false, 在 base 中我一律是給它 true; [uservisiable] 是使用者看不看的見? 自己思考吧 (^^)...呵呵, 可 true 可 false;

    [packagelist] 內容包著就是我們最需要的擺放的套件名稱 [packagereq] 了, 在 [packagereq] 中有幾個參數: optional, mandatory, default, 我會將 optional 換成 mandatory; 上述 comps.xml 的說明, 個人覺得相當重要, 因為接下來要做的事情跟它有直接關係, 不要小看了這個檔, 很多人都需要費一番工夫來研究!!

    我要說的是: comps.xml 只需要以這三個 (core, base, buildsys-build) 為主的 [group], 其他的, 都刪了吧! 而 core 跟 buildsys-build, 其中 buildsys-build 的內容是需要的, 因為它內容所指的 package 都是在建構系統時會需要的命令, 而且你會發現其 type 值都是 mandatory. 至於 core, 因為我在 base 中, 會將所有需要的套件, 一次放在這裡, 所以 core 只需要留個樣子給系統看就行了! 知道我說的意思嗎? 就是只需要這樣做:


[group]
  [id]core[/id]
  [name]this is a core program[/name]
    [default]true[/default]
    [uservisiable]false[/uservisiable]
    [packagelist][/packagelist]
[/group]

注意, 在這裡我沒辦法用正常的 xml 來標示"<>", 所以改用"[]"替代.

我怎麼才能知道 [packagereq] 內對應的套件名稱是啥? 很簡單, 舉個 rpm 套件包: php-mbstring.1.34-1.i386.rpm (假設有此套件), 則套件名稱就是 php-mbstring, 對於套件解析的語法可以用 "-[0-9]." 取這之前的字串作為套件名稱, 而我們有很多個套件要放入....是不是很暈?!! shell script 可以幫我們達到我們要的. 例如:
for fs in `ls`
do
echo $fs|awk -F'-[0-9].' '{print $1}'
done

還記得剛剛複製的那個目錄 sl6iso/ ?!
那個目錄就是這時候用上啦! 你必須編寫一個 script, 它能夠以 sl6iso/repodata/comps.xml 這份完整的內容為藍圖, 針對 custiso/Packages/ 內我們所需要的套件, 自動產生套件名稱, 同時先格式化客製化一份新的 comps.xml, 然後將這些套件名稱, 依依的放入 [packagereq] 所屬的標籤欄位中, 從而產生出如下的樣式內容:

PS. 完成之後的 comps.xml 應該是像這樣:
[comps]
    [group]
        [id]core[/id]
        ....
    [/group]

    [group]
        [id]buildsys-build[/id]
        ....
        [packagelist]
            [packagereq type="..."]...[/packagereq]
            ...
        [/packagelist]
    [/group]

    [group]
        [id]base[/id]
        ....
        [packagelist]
            [packagereq type="default"]php-mbstring[/packagereq]
            ....
        [/packagelist]
    [/group]
[/comps]
如果你真的自己撰寫好了一支可以完整呈現如上的架構跟實際你需要的內容, 恭喜你, 以後就靠它行走江湖了...哈哈.

    產生了我們需要的客製化 comps.xml 後, 我們先複製它到 custiso/repodata/, 然後產生 comps.xml.gz, 再複製它到 custiso/repodata/ 中; 這時的 custiso/repodata/ 有兩個檔: comps.xml 與 comps.xml.gz, gz 怎麼產生不用我解釋吧?!! gzip comps.xml 就是了.

    實做到這裡, 告訴你一個好消息, 快完成了! 真的, 就差臨門一腳!! 興奮吧 (^^).

    進入 custiso/ 中, 這時我們底下其中有兩個目錄: repodata/ 與 Packages/, 在現在的這個位置執行:
createrepo -g 完整路徑+comps.xml(/var/opt/custiso/repodata/comps.xml) ./
然後 createrepo 就會自動針對其下的 Packages/ 內的套件分析, 先後在 repodata/ 內產生新的資料檔.

    如過程中沒有錯誤, 恭喜你, 完成了人生中最重要的一步! 接下來編寫 ks.cfg, 可利用 kickstart 套件, 另外, isolinux/isolinux.cfg 中也需要添加 ks.cfg 的紀錄, 最後轉成 .iso 檔, 它就會是完全自動安裝的客製化光碟.

[註一] 如果套件須持續的保持更新, 那麼接下來, 我們需要另行規劃一支 scrpit 來運行 : 針對原來舊有的套件做更新的動作, 可利用 yumdownloader 來達成, 但過程中我們需要判斷該套件是否有新的套件, 若有則需要將舊有的套件刪除, 但有些套件可能是經由你自己修改後產生的, 可能與原先的會有大大的不同, 此時如果做 update 的話, 很可能會被其他 yum mirror 站台內該新的套件給取代, 這時你原先修改的內容將不復存! 這是我想的到的重要缺失, 同時我也針對該項問題, 想到了解決方案 :

    產生一個 list 檔, 內容是不想更動的套件名稱. 
        ex: php-mbstring-3.3.5-1.i686.rpm , 則紀錄 php-mbstring 該名. 因為這樣的名稱才能在 yumdownloader 指令中找到相對應的套件名稱.

    在 script 中提及 : 只要是套件名稱為 該 list 檔中所列, 則忽略不更新.

2011年7月7日 星期四

ftp auto login

在 home directory 創建 .netrc 檔案, 權限 0600
內容:
machine [remote_ftp_server]
login [username]
password [password]

則我們在 ftp [remote_ftp_server] 時會自動 Login.

如果還要再接下來自動執行 ftp 命令.
則先把需要的命令順序寫到一個檔案中.
再將檔案指定給 ftp 即可.

example:
create test.list
> ls
> exit

ftp 192.168.1.1 < test.list

2011年6月12日 星期日

Linux 的防毒系統

[原出處已遺忘]


clamav安裝與使用


在安裝之前先新增 clamav 使用者及群組
不然下面會有權限的問題產生
到時還要手動修正
依照官方文件先創 clamav群組與使用者
groupadd clamav
useradd -g clamav -s /bin/false -c "Clam AntiVirus" clamav

註:如果使用 clamd 或 freshclam 並無出現權限錯誤問題
則下面設定權限的部份可以跳過


先設定好讓yum可以抓到dries

安裝clamav:
yum -y install clamav clamav-server clamd

設定開放 clamav的log檔屬性:
clamd log檔預設位置在
cd /var/log/clamav/

clamd的部份:
先創個clamd.log出來
touch clamd.log
把屬性打開
1.chmod 600 clamd.log
2.chown clamav clamd.log (把權限指定給clamav)

設定長駐clamd防毒
/etc/rc.d/init.d/clamd start
chkconfig clamd on
freshclam的部份:
cd /var/log/clamav
touch freshclam.log
chmod 600 freshclam.log
chown clamav freshclam.log

注意!! 有兩個目錄的權限要開放給 clamav 使用者
不然無法下載病毒碼
chown clamav /varclamav
chown clamav:clamav /usr/local/share/clamav

開始更新:
freshclam

每日更新:
vi /etc/crontab
幾分 幾點 * * * root /usr/local/bin/freshclam


手動掃描語法:
◎語法:

clamscan [options] [file/directory/-]

◎常用參數:
-d FILE/DIR, --database=FILE/DIR 指定病毒資料庫位址.

-l FILE, --log=FILE 將掃描結果儲存到FILE這個檔案.

-r, --recursive 遞迴掃描.

--bell 發現病毒的時候發出聲響.

--no-summary 完成掃描後,不顯示摘要訊息.

--remove 移除被病毒感染的檔案.

◎常用範例:
(0) 掃描某一檔案: clamscan file

(1) 掃描目前所在的資料夾: clamscan

(2) 遞迴掃描位於/home資料夾下的所有檔案及資料夾: clamscan -r /home

-----------------------------------------------------------------------------------
ClamAV

English Version

[ 最新版本: 0.93.3 ] 為 Fedora 9

注意:如果你要升級 (不是新的安裝) 至 0.93 版本,因為從 0.93 版本開始 ClamAV 的病毒資料庫已經在用不一樣的格式 (.cld) 所以已經不需要 main.inc 和 daily.inc 子目錄。你必須手動刪除這兩個子目錄如下:

    cd /var/lib/clamav
    rm -fr main.inc
    rm -fr daily.inc 

2008/06/24

今天我注意到 freshclam 更新 ClamAV 病毒碼資料庫時它把檔案 /var/lib/clamav/main.cvd 改名為 /var/lib/clamav/main.cld。在這樣的情形之下你必須改 initscript /var/rc.d/init.d/clamd。更改這列:

    if ! [ -f /var/lib/clamav/main.cvd -o -d /var/lib/clamav/main.inc ]; then ==>
    if ! [ -f /var/lib/clamav/main.cld ]; then 

我從來沒有想過要寫如何安裝 ClamAV 這篇文章因為安裝 ClamAV 是一個很容易的事情。但是為了完整﹝完整電子郵件方案: Sendmail + milter-greylist + ClamAV Anti-Virus + SpamAssassin﹞,我決定乾脆把它寫了。

有人可能會問為什麼在一個 Linux 伺服器安裝一個防毒程式?畢竟沒有病毒會攻擊 Linux。相反的,大家知道病毒只攻擊微軟 Windows 這作業系統。對這問題的答案是:雖然電子郵件伺服器是安裝在 Linux 但是電子郵件的使用者很可能是在使用 Windows。為了保護你的使用者,乾脆也安裝了防毒程式。

我在使用 Fedora 9,所以我要安裝的 ClamAV 是 Fedora 9 的版本。我拿 crash-hat 為 CentOS-5.0 所提供的 source rpm,然後重建我自己的 rpm 包裝為 Fedora 9。

當然你自己也可以這樣做。但是如果你無法或不知道如何從 source rpm 建你需要的 rpm 包裝,請你參考 這裡 。我 提供 我在 Fedora 9 所建的 rpm 包裝。

2008/07/09

crash-hat 很慢提供最新版本的 rpm 包裝,所以我自己使用前一個 .src.rpm 來重建最新版本的 rpm 包裝。我現在也提供為 CentOS 5.2 的 rpm 包裝。你在這裡下載。

因為 Fedora 9 也支援 ClamAV,當然你可以使用 Fedora 9 所提供的 rpm 包裝來安裝或更新。我自己喜歡重建我的 rpm 包裝因為我感覺 Fedora 9 負責 ClamAV 的人更新的很慢。

註:如果你不用 Fedora,你可以在 http://www.clamav.net/download/packages下載你 distribution 的 binary package。

安裝/更新這些檔案:

    rpm   -Uvh   clamav-0.93.3-1.i686.rpm   clamav-milter-0.93.3-1.i686.rpm   clamav-server-0.93.3-1.i686.rpm

註:不要安裝/更新 clamav-db-0.93.3-1.i686.rpm。freshclam 會自動下載所需要的病毒碼。

設定檔案:

    /etc/clamd.conf
    /etc/freshclam.conf
    /etc/sysconfig/clamav-milter

除了你有特別的需要,要不然就不需要修改這些設定檔案的設定內容。都沒有問題的。

現在我們可以啟動 clamav-milter 、 clamd 和 freshclam:

    chkconfig   clamav-milter   on
    chkconfig   clamd   on
    chkconfig   freshclam   on
    service   clamav-milter   start
    service   clamd   start
    service   freshclam   start

因為我們使用一個 milter ﹝clamav-milter﹞,在 /etc/mail/sendmail.mc 的 OSTYPE(`linux')dnl 之後我們需要加:

    INPUT_MAIL_FILTER(`clamav-milter',`S=local:/var/run/clamav/clamav-milter.sock,F=, T=S:4m;R:4m')dnl
    define(`ConfINPUT_MAIL_FILTERS', `clamav-milter')dnl

註:如果你也同時使用 milter-greylist,應該先放 milter-greylist 的設定,然後才放 clamav-milter。這樣的,當一封電子郵件到達,Sendmail 會先呼叫 milter-greylist 然後呼叫 clamav-milter。整個設定如下:

    OSTYPE(`linux')dnl
    INPUT_MAIL_FILTER(`greylist',`S=local:/var/milter-greylist/milter-greylist.sock')
    define(`confMILTER_MACROS_CONNECT', `j, {if_addr}')
    define(`confMILTER_MACROS_HELO', `{verify}, {cert_subject}')
    define(`confMILTER_MACROS_ENVFROM', `i, {auth_authen}')
    INPUT_MAIL_FILTER(`clamav-milter',`S=local:/var/run/clamav/clamav-milter.sock,F=, T=S:4m;R:4m')dnl
    define(`ConfINPUT_MAIL_FILTERS', `clamav-milter')dnl

重新建 sendmail.cf 然後重新啟動 sendmail:

    m4   /etc/mail/sendmail.mc   >   /etc/mail/sendmail.cf
    service   sendmail   restart

現在你的使用者可以享受沒有病毒的電子郵件了。

2011年5月31日 星期二

在 Linux 上燒錄CD

在 Linux 上燒錄CD
作者:zhchhui 發表於:2003-08-01 08:30:06


在 Linux 上燒錄 CD

Linux SCSI 仿真冒險
創建 .iso 文件
燒錄盤
複製盤
多段刻錄
結束語

相關內容:

Knoppix 提供了一個可引導的、容量為一張光碟的 Linux
Basic tasks for new Linux developers


命令行上的 mkisofs 和 cdrecord 使這一切成為可能

Carla Schroder(dworks@bratgrrl.com)
負責人,Tux Computing
2003 年 7 月

Linux 為創建 CD 提供了功能強大且靈活的工具。您可以創建在幾乎任何平臺上都可讀的盤,還可以創建 .iso 文件以供下載和分發。
在任何平臺上從命令行燒錄 CD 都是一件令人費解且煩躁的事情,Linux 當然也不例外。不過,由於在各平臺上所用到的命令和術語都十分相似,因此學習一下如何在 Linux 上刻錄 CD 還是十分有用的。許多 Linux 軟體都是通過 .iso 映射分發的,因此如果您知道如何燒錄 CD,就可以下載 .iso 來創建您自己的安裝盤。

Linux 和 Windows 都有可錄 CD 的程式可用,但 Linux 版本比起 Windows 版本來功能更強大通用性也更好。在本文中,我們將研究 Linux CD 刻錄命令中的兩個主力:mkisofs 和 cdrecord。mkisofs 創建預先錄製的映射,來生成 ISO9660/JOLIET/HFS 混合檔系統。它同時創建和填充檔系統。與其他資料存儲介質(如硬碟驅動器和軟碟驅動器)不同,CD 上的檔系統並不是先創建後填充資料的。CD-R 只有一次機會:首先格式化將會創建一個帶有空檔系統的盤。cdrecord 命令在橙皮書(Orange Book) CD-R/RW 上刻錄資料,這差不多就是其全部工作了。

由於採用了諸如 CD 刻錄之類的新興技術,最好使用這些程式的較新版本。mkisofs 和 cdrecord 的版本都應該至少已經達到了 1.10。cdrecord 的最新版本 V2.0 已經被重命名為 cdrtools。要查明機器上所安裝的版本,請輸入:

$ cdrecord --version


$ mkisofs --version
對於那些剛接觸可刻錄 CD 的人而言,在我們繼續之前,有幾樣東西是值得先瞭解一下的:

CD-R:可刻錄 CD(CD-Recordable)。它們是 WORM(寫一次,讀多次,Write Once, Read Many)。
CD-RW:可重寫 CD(CD-Rewritable)。它們是 WMRM(寫多次,讀多次,Write Many, Read Many)。
CD-R 的使用很廣泛,在任何 CD-ROM 驅動器上都應該可讀。
CD-RW 在所有現代驅動器上都應該可讀。驅動器必須是“多格式讀取的(multiread)”,以便能夠讀取 CD-R 和 CD-RW 盤。較老的驅動器會出問題。扔掉那個 4 倍速的舊驅動器,買個新的;用不著發火。
商用 CD 不是用鐳射燒錄成的,而是壓制而成的。
哪一種 CD-R/RW 驅動器最好呢?隨便請教普通的硬體評論員,讓他們給您一些建議。
下面是與文件格式有關的一些術語:

黃皮書(Yellow Book):資料 CD 的物理格式
橙皮書:可刻錄 CD 的物理格式:
第一部分:CD-MO(磁-光,Magneto-Optical)
第二部分:CD-WO(寫一次,Write-Once;包括 PhotoCD 的“混合”規範)
第三部分:CD-RW(可重寫,Re-writable)
ISO-9660:舊的檔佈局標準,它只允許 8.3 格式的檔案名
Rock Ridge:是對 ISO-9660 的擴展,它允許長檔案名和 UNIX 樣式的符號鏈結;保留了所有檔屬性,如所有權和許可權。在 Windows 系統上讀盤時,不會顯示 UNIX 檔的屬性。
Joliet:Microsoft 對 ISO 9660 檔系統的擴展,它允許在檔案名中使用 Unicode 字元,同樣也允許長檔案名。為了與 MS-DOS 相容,它還創建截斷的檔案名(這些看起來怪怪的樣子:FILENA~1.TXT)。它允許檔案名長達 64 個字元(包括空格),Windows 95 或更高版本以及運行 Joliet 卷訪問(Joliet Volume Access)擴展的 Macintosh 電腦都可以讀取它。Macs 不會讀取長度超過 31 個字元的 Joliet 檔案名。
El Torito:可引導 CD-ROM(Bootable CD-ROM)格式規範
HFS(分層檔系統,Hierarchical File System):Macintosh 使用的本機檔系統
多段刻錄(Multisession):允許多次添加檔,而不是只允許在單個段中添加檔。要使盤可讀,就必須“關閉”段。但是,這卻導致不能向盤中添加更多檔。多段刻錄將單個段鏈結起來,然後更新盤的目錄,使得它好象一個目錄一樣。
CD-UDF(通用盤格式,Universal Disk Format):業界標準遞增包寫檔系統(incremental packet-writing filesystem)
對 UDF 的一點簡單說明:UDF 意味著能夠直接將檔放入盤。目前,這是在軟體級別上完成的。讀取該盤需要用來創建該盤的軟體。計畫將 UDF 添加到 Linux 內核(可能是 2.6)。要實現這一點,CD 驅動器需要具有 CD-MRW 電路(“CD Mount Rainier ReWrite”;不要問我他們為什麼取這麼個名字),因此它將是新型驅動器的一項功能。當這一點得到實現時,向 CD-R/RW 中複製檔將和向軟碟中複製檔一樣容易,而且這些盤將普遍可讀。而且,它還被吹捧為古老的 3.5" 軟碟的另一種替代品。我們將拭目以待。(請參閱參考資料以獲取到更多有關 Mount Rainier 的資訊的鏈結。)

Linux SCSI 仿真冒險
如果可以的話,請使用 IDE/ATAPI 或 SCSI CD 燒錄機。並口介面是一種會給您添麻煩的棘手玩意兒,而 USB 驅動器則很慢。在 Linux 中它們都得不到很好的支持(雖然對於較新的 USB 2.0 驅動器,您的運氣可能會好一些)。

IDE/ATAPI 驅動器最為常見,但使用起來卻需要做些調整。那麼,如果 cdrecord 顯示沒有配置任何驅動器,會發生什麼事情呢?要想檢查是否配置有驅動器,請輸入以下命令:

$ cdrecord -scanbus
如果命令顯示了 CD-RW 驅動器(請參閱後面的燒錄盤),那麼您可以跳過這一節的大部分,儘管您可能還是都想流覽一下這些內容,以便有所瞭解。

Linux 使用 SCSI 仿真子系統,因此 IDE/ATAPI CD 燒錄機需要相容性驅動程式。如果同一台 PC 上既有 CD-ROM 也有 CD-R/RW,那麼二者都需要 ide-scsi 偽設備驅動程式來支援盤的複製。在 CD-ROM 上使用 SCSI 仿真沒有什麼不利之處;它同樣能工作;只是名稱會改變。驅動器的名稱將會隨 Linux 的具體分發版而有所不同,其名稱可以是 /dev/cdrom0、/dev/hdc 或 /dev/scd0(要獲得 IDE/ATAPI 設備名列表,請參閱表 1)。

表 1. IDE/ATAPI 設備名名稱 設備
hda IDE 匯流排連接器 0 主設備
hdb IDE 匯流排連接器 0 從屬設備
hdc IDE 匯流排連接器 1 主設備
hdd IDE 匯流排連接器 1 從屬設備


要找到系統上的驅動器,請輸入:

$ dmesg | grep '^hd.:'

hda: IBM-DTLA-305020, ATA DISK drive
hdb: TOSHIBA DVD-ROM SD-M1202, ATAPI CD/DVD-ROM drive
hdc: LITE-ON LTR-24102B, ATAPI CD/DVD-ROM drive
hda: 40188960 sectors (20577 MB) w/380KiB Cache, CHS=2501/255/63, UDMA(66)
大多數現代 Linux 都包含了已編譯進內核的 SCSI 仿真:

$ locate ide-scsi.o

/lib/modules/2.4.19/kernel/drivers/scsi/ide-scsi.o
如果您的系統不是這樣的,那麼您就必須將它編譯到您的內核中。對於這篇篇幅有限的文章來說,那是一個過大的主題,因此請參閱參考資料(當您知道如何做時,您會發現它並不難)。

您需要編輯兩個文字檔案來配置系統,讓它使用 ide-scsi 驅動程式。第一個是 /etc/modules.conf(在 Debian 中是 /etc/modules)。我的系統有一個 CD-ROM 和一個 CD-R/RW 驅動器,設備分別是 hdb 和 hdc。使用適合於您系統的值,將這兩行添加到 /etc/modules.conf(或 /etc/modules):

ide-cd ignore=\"hdb hdc\"
ide-scsi
缺省情況下,IDE 子系統將所有的 ATA 設備聲明為它自己的設備,因此 ignore 這一行使得 SCSI 子系統既能抓取 CD-R/RW 也能抓取 CD-ROM。

接下來,為您的引導裝載程式(GRUB 或 LILO)編輯配置檔。對於 LILO 用戶,請將下面兩行添加到 lilo.conf 的末尾:

append="hdb=ide-scsi"
append="hdc=ide-scsi"
對於 GRUB 用戶,請將下面這行添加到 /etc/grub.conf(或者 Debian 中的 /boot/grub/menu.lst)中 kernel 這行的末尾:

hdb=scsi hdc=scsi
現在重新引導,並驗證它是否已裝入:

$ lsmod
這條命令將返回一個長列表;請查找 ide-scsi。

創建 .iso 文件
一旦選擇了您想複製的檔,對 CD 進行刻錄就只有兩步:用 mkisofs 創建 .iso,然後用 cdrecord 將這些檔燒錄進盤中。使用以下命令來創建 .iso 文件:

$ mkisofs -o test.iso -Jrv -V test_disk /home/carla/
在上面的示例中:

-o 為新的 .iso 映射檔命名(test.iso)
-J 為了與 Windows 相容而使用 Joliet 命名記錄
-r 為了與 UNIX/Linux 相容而使用 Rock Ridge 命名約定,它使所有檔都公共可讀
-v 設置詳細模式,以便在創建映射時獲得運行注釋
-V 提供了卷標識(test_disk);該標識就是出現在 Windows 資源管理器中的盤名
列表中的最後一項是選擇要打包到 .iso 中的文件(都在 /home/carla/ 中)
現在,掛裝 .iso 來進行驗證;我喜歡創建一個測試目錄:

$ mkdir /test_iso
$ mount -t iso9660 -o ro,loop=/dev/loop0 test.iso /test_iso
查看目錄的內容;所有的檔都應該在那堙A並且都可讀。否則,就是映射壞掉了,如果您將它燒錄到盤上,那麼您最終將得到一個刻錄失敗的光碟。

燒錄盤
將映射寫到盤中再簡單不過了。首先,找到 CD-R/RW 的 SCSI 地址:

$ cdrecord -scanbus

Cdrecord 1.10 (i686-pc-linux-gnu) Copyright (C) 1995-2001 Jrg Schilling
Linux sg driver version: 3.1.24
Using libscg version 'schily-0.5'
scsibus0:
0,0,0 0) 'TOSHIBA ' 'DVD-ROM SD-M1202' '1020' Removable CD-ROM
0,1,0 1) 'LITE-ON ' 'LTR-24102B ' '5S54' Removable CD-ROM
0,2,0 2) *
0,3,0 3) *
0,4,0 4) *
0,5,0 5) *
0,6,0 6) *
0,7,0 7) *

每一項的前三個數位分別指 SCSI 匯流排、設備標識和 LUN(邏輯單元號,Logical Unit Number)。(第四個數位也是設備標識。)cdrecord 需要這三個數位。在上面的示例中,CD 燒錄機是 0,1,0。SCSI 匯流排 0 上的設備都可以縮寫為 1,0,即省去頭一個 0。這是一個公共約定。如果有其他匯流排的話,則必須指定 — 沒有快捷方式。

現在向盤中寫內容:

$ cdrecord -v -eject speed=8 dev=0,1,0 test.iso
在上面的示例中:

-v 指詳細方式
-eject 在完成寫任務後彈出盤
-speed 指定寫速度(8)
-dev 是從 cdrecord -scanbus 獲得的設備號(0,1,0)
最後一個是所燒錄的映射的名稱(test.iso)
對於創建用於公用分發的盤,這是一種簡單且可用的方法,因為它創建了可以在任何 Windows 或 Linux 系統上讀取的盤。mkisofs 本身就非常適合於創建供下載的 .iso,而且 mkisofs 可以為許多平臺創建檔系統。請參閱 mkisofs 聯機幫助頁以獲取更多資訊。

在一台運行速度極快且記憶體很大的機器上,您可以在刻錄期間從容地處理非 CPU 密集型任務,但是在燒錄盤期間最好別做別的事情。雷射器不能先停下來,然後從停下來的地方重新開始,所以任何中斷都是致命的。

cdrecord 將試圖以最快速度運行燒錄機,因此不必指定速度,但是,應該根據經驗來判斷如何做。指定較慢的速度對於糾正錯誤和緩衝區欠載運行很有用。採用“burn- proof”技術的新型驅動器(開發這項技術的初衷與它現在的名字正好相反;同樣,誰取的這些名稱呢?)不會有老式驅動器那樣的緩衝區欠載運行煩惱。

複製盤
要直接將內容從源盤複製到可刻錄盤,請使用下面的命令:

$ cdrecord -v dev=0,1,0 speed=4 -isosize /dev/scd0
這條命令直接將 CD-ROM 即 /dev/scd0 的內容“流”入 CD 燒錄機 dev=0,1,0。不要在速度慢的舊機器上這麼做。直接複製速度很快,但卻更容易出錯。更好的做法是:先將源盤的內容複製到硬碟驅動器,再從硬碟驅動器複製到 CD 燒錄機:

$ mount /cdrom
$ dd if=/dev/scd0 of=/tmp/diskfile.iso
$ cdrecord dev=0,1,0 speed=8 fs=8m -v -eject -dummy /tmp/diskfile.iso
請注意兩個新選項 fs=8m 和 -dummy。fs=8m 定義了環形緩衝區的大小:在一定程度上,越大越好。記住,中斷是致命的;如果什麼東西讓資料傳送慢下來了,那麼 fs=8m 將創建一個足夠大的緩衝區來讓燒錄機保持運行。如果 8 MB 還不夠,那麼您可能需要一台更好的 PC。另一方面,超過 8 MB 也不一定更好,因為作業系統重新裝入 MMU(記憶體管理單元,Memory Management Unit)表時會浪費時間。缺省值是 4 MB。

-dummy 是一個了不起的選項,可以用它來先進行一次“排練”,然後在實際的盤上冒險。燒錄機執行一切操作,但是不打開鐳射頭,這使用戶有機會在將內容提交到盤上之前捕獲錯誤。

多段刻錄
CD 由段構建而成,而段由磁軌構成。只有一個段的盤上有一個導入點、一個 TOC(目錄,table of content)、資料和一個導出點,導出點標記著這張盤的終點,並阻止在這張盤上進行進一步的刻錄。mkisofs 將單獨段鏈結在一起。用 GUI 程式(如 X-CD-Roast 或 KonCD)創建多段刻錄盤可能要更容易一些,但這媞t示的是如何用命令行工具完成這一任務。

第一次在盤上刻錄一個段時,請在 cdrecord 中使用 -multi 開關:

$ cdrecord -v -eject speed=8 dev=0,1,0 -multi test.iso
盤將會以某種方式被固定下來,使得盤可讀,也可以添加更多資料。要向這張盤中添加更多段,mkisofs 需要知道起始磁區號和結束磁區號,可以象下面這樣來找到這些號碼:

$ cdrecord dev=0,1,0 -msinfo
0,27139
確保把要添加資料的盤放入了 CD 燒錄機。然後,添加兩個新開關 -C 和 -M:

$ mkisofs -o test2.iso -Jr -V Session2 -C 0,27139 -M 0,1,0 /files/path/
或者更好的辦法是,讓命令 shell 完成這項工作:

$ mkisofs -o test2.iso -Jr -V Session2 -C `cdrecord dev=0,1,0 -msinfo` -M 0,1,0 /files/path/
多段刻錄 CD 驅動器讀取已寫入的最後一個段。上面的命令從最後一個段獲取 TOC,然後將它組合進新 TOC 中。在刻錄盤上的最後一個段時,請省略 -multi 選項。

結束語
Linux 中的 CD 刻錄功能強大且全面。CD 燒錄機可以跨越網路共用,還可用於自動備份;mkisofs 和 cdrecord 也能用於 DVD。雖然有許多優秀的圖形前端程式,但是完整的功能在命令行程式上

Compiler Linux Kernel

作者: Baron. Wan

1.    RedHat Linux kernel source 位置在 /usr/src 中。以版本為例,在 /usr/src/linux-2.4.21-4.EL/ 中的 .config kernel 相關參數值,建議如要修改,請另存別的檔名,不要直接覆蓋!
2.    http://www.kernel.org/pub/linux 中找到 2.4 版本的更新 kernel,我是用 2.4.35.3 版本來更新。
3.    解壓縮完畢後,執行 make menuconfig 來進行 kernel 參數設定;先進入主畫面,load 原舊有的設定檔 è /usr/src/linux-2.4.21-4.EL/.config,調整完畢後 Save 到其他的位置,我是將檔案存放在 linux-2.4.35.3 裡面,檔名為 config-2.4.35.3-1 來表示這是我第一次編輯的設定檔,結束時請再儲存一次。
4.    make dep 來編譯設定資料,用 make bzImage 來編譯成 vmlinuz,完成後會產生 ./vmlinux./System.maparch/i386/boot/bzImage 等檔案。
5.    cp vmlinux /boot/vmlinux-2.4.35.3
cp System.map /boot/System.map-2.4.35.3
cp arch/i386/boot/bzImage /boot/vmlinuz-2.4.35.3
6.    make modules 來編譯 kernel modules
make modules_install
將編譯好的 modules 安裝到 /lib/modules/2.4.35.3 當中。在執行 make modules_install 時,程式會先到 /boot 檢查有無相關的 vmlinuz and System.map,所以第五個步驟一定要在之前完成。
7.    如果以上都編譯無誤,使用 mkinitrd /boot/initrd-2.4.35.3.img 2.4.35.3 來建立 image 檔。
8.    最後,在 /etc/grub.conf or /boot/grub/grub.conf 當中編輯開機資訊,重新開機測試。


==================================================

/usr/src 是 Kernel 安裝路徑, 請將 linux-2.4.xx 目錄整個 copy 到 /usr/src , 然後進入 /usr/src/linux-2.4.xx 開始 compiler kernel 的動作



/* 刪除一些以前留下來的 .o 檔案 */


# make mrproper


/* Makefile 的 config 設定 (.config) */


# make menuconfig


/* 將以前曾經進行過的 .o 檔案刪掉, 才不會產生新舊版本的差別 */


# make clean


/* 開始編譯 


編譯完成後, 應該會看到: …./arch/i386/boot/bzImage , 若有錯誤則請重新編譯 */


# make bzImage


/* 製作相關模組 */


# make modules


/* 若同一個核心模組重複被 Compiler 兩次以上, 那請先將該版的模組 move 掉 */


/* Install Modules , 安裝完成後, 會將模組放在 /lib/modules/ 內 */


# make modules_install


/* 之前執行 make bzImage 成功後, 會在 /arch/i386/boot/ 多個 bzImage 檔案 , 請放入 /boot */


# cp /usr/src/linux-2.4.xx/arch/i386/boot/bzImage /boot/vmlinuz-2.4.xx


# cp /usr/src/linux-2.4.xx/vmlinux /boot/vmlinux-2.4.xx


# cp /usr/src/linux-2.4.xx/System.map /boot/System.map-2.4.xx


# vi /boot/grub/menu.lst


加入一段 TITLE , 並在下一行加入: kernel /vmlinuz-2.4.xx ro root=/dev/hda3 rhgb quiet


或是 kernel /vmlinuz-2.4.xx ro root=LABEL=/ 


注: 後面的寫法可能只能適用在 2.4.21 以前的版本.

2011年5月30日 星期一

SELinux 設定說明

SELinux 的設定檔

* /etc/selinux/config # This file controls the state of SELinux on the system.

# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - SELinux is fully disabled.
SELINUX=enforcing
# SELINUXTYPE= type of policy in use. Possible values are:
#       targeted - Only targeted network daemons are protected.
#       strict - Full SELinux protection.
SELINUXTYPE=targeted
若要停用 SELinux,則把 SELINUX=enforcing 改成 SELINUX=disabled 後重新開機即可

SELinux 的一些相關指令

* sestatus
查看 SELinux 是否啟用及目前狀態如何的指令
如:
1.SELinux Disabled $ sestatus

SELinux status:         disabled
2.SELinux Enabled
mode: enforcing
Policy: targeted $ sestatus

SELinux status:         disabled
SELinux status:         enabled
SELinuxfs mount:        /selinux
Current mode:           enforcing
Mode from config file:  enforcing
Policy version:         18
Policy from config file:targeted

Policy booleans:
...skip...
httpd_builtin_scripting active
httpd_disable_trans     active
httpd_enable_cgi        active
httpd_enable_homedirs   active
httpd_ssi_exec          active
httpd_tty_comm          inactive
httpd_unified           active
...skip...
* system-config-securitylevel
圖形化介面的工具程式,除了可以設定防火牆(iptables)外,也可以設定 SELinux
* setenforce
在 SELinux 啟動為 enforcing 的狀況下,可以執行 “setenforce 0“ 來將 SELinux 暫時停用
* getsebool and setsebool
/etc/selinux/targeted/booleans 這個檔裡面放的就是各個 Policy 的布林值,不過,在 FC5 之後,已經沒有這個檔了,你可以用
$ getsebool -a
來查看所有的 booleans 設定狀況
或是使用如:
$ setsebool -P httpd_disable_trans 1
來將 httpd_disable_trans 停用,這樣其實也就等於是停用 SELinux 對 httpd 的保護了
* chcon
傳統的 chmod 指令是用來設定檔案或目錄的權限的,而同樣的 chcon 指令則是用來設定 SELinux 對檔案或目錄的 content 標籤的
* fixfiles
fixfiles check 指令可以用來檢查檔案或目錄的 SELinux content
fixfiles restore 指令則可以用來修正(還原)檔案或目錄的 SELinux content
fixfiles relabel 則是會重新修正(還原)所有的檔案及目錄的 SELinux content

如何在 SELinux 啟動為 enforcing 的狀況下也讓 Web Server(httpd) 能正常運作?

前面提到,我們可以將 SELinux 停用(disabled) 或是執行 “setsebool -P httpd_disable_trans 1“ 來停用 SELinux 對 httpd 的保護,這樣,httpd 就可以跟平常一樣的運作了
那如果我們要啟用 SELinux 且讓 httpd 也可以正常運作呢?
舉個例子來說: [root@acer:~] pwd

/root
[root@acer:~] echo "< ? phpinfo(); ?>" > index.php
[root@acer:~] mv index.php /var/www/html/
`index.php' -> `/var/www/html/index.php'
[root@acer:~]
在上述的指令中,我在 root 的 $HOME 目錄下產生了一個 index.php 的檔案,內容為顯示 phpinfo
然後把再把這個檔案搬移到 /var/www/html 目錄底下,然後開 browser 來瀏覽 http://localhost/index.php 這個頁面,得到的畫面卻是: Forbidden


You don't have permission to access /index.php on this server.

Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
沒錯,無法存取,我們來看一看到底是怎麼回事: [root@acer:~] ls -Z /var/www/html/index.php

-rw-r--r--  root     root     root:object_r:user_home_t        /var/www/html/index.php
[root@acer:~]
[root@acer:~] ls -Z /var/www/
drwxr-xr-x  root     root     system_u:object_r:httpd_sys_script_exec_t cgi-bin/
drwxr-xr-x  root     root     system_u:object_r:httpd_sys_content_t error/
drwxr-xr-x  root     root     system_u:object_r:httpd_sys_content_t html/
drwxr-xr-x  root     root     system_u:object_r:httpd_sys_content_t icons/
drwxr-xr-x  root     root     system_u:object_r:httpd_sys_content_t manual/
因為 index.php 的 content type 為 user_home_t 而不是 httpd_sys_content_t 所以無法存取
因此,我們可以執行: [root@acer:~] chcon -u system_u -t httpd_sys_content_t /var/www/html/index.php

[root@acer:~] ls -Z /var/www/html/index.php
-rw-r--r--  root     root     system_u:object_r:httpd_sys_content_t /var/www/html/index.php
請再開一次 browser (or reload),現在是不是可以正常存取 index.php 頁面了呢?
再看另一個例子: [root@acer:~] wget http://wordpress.org/latest.tar.gz

--13:36:59--  http://wordpress.org/latest.tar.gz
           => `latest.tar.gz'
Resolving wordpress.org... 72.232.44.122
Connecting to wordpress.org|72.232.44.122|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/octet-stream]

    [                     < =>             ] 505,475       90.49K/s

13:37:07 (90.28 KB/s) - `latest.tar.gz' saved [505475]

[root@acer:~] tar zxf latest.tar.gz
[root@acer:~] mv wordpress /var/www/html/wp
`wordpress' -> `/var/www/html/wp'
瀏覽 http://localhost/wp/ 的結果一樣被拒絕存取,因為 content 的問題 [root@acer:~] ls -dZ /var/www/html/wp

drwxr-xr-x  1025     1011     root:object_r:user_home_t        /var/www/html/wp/
同樣的,我們可以用 chone -R 指令來修正 content [root@acer:~] chcon -R -u system_u -t httpd_sys_content_t /var/www/html/wp/
或是使用 fixfiles restore 指令也可以 [root@acer:~] fixfiles restore /var/www/html/wp/
修正過後的狀況: [root@acer:~] ls -dZ /var/www/html/wp

drwxr-xr-x  apache   apache   system_u:object_r:httpd_sys_content_t /var/www/html/wp/

相關參考文件

Comments are closed. 

Linux: Updating and Rebuilding CentOS 4 Installation CDs


Question:  I found your Fedora Core 2 update page. How can I create new installation CDs for CentOS 4 with the updates already included?
Answer:  As with Fedora Core 2, CentOS comes with all of the tools you need to accomplish this. To be consistent, we've provided our procedure broken down into 5 steps below. (This procedure assumes CentOS 4.1 since this is the latest release at the time of writing.)
Since CentOS 4 seems to have the same problem with the DAC960 RAID controller as Fedora Core 2, we've also included a DAC drive fix in our procedure.

Step 1: Preparation

This procedure is not for the novice. If you find this document confusing, it would be best to find an experienced Linux user to help you through it.
To start, a proper build environment is required.
You'll need a computer with CentOS 4 installed on it and 10GB of free hard disk space.
You'll need to be the super user (root) to proceed from here. Commands are assumed to be executed from a bash shell.
The following packages (As well as any packages these require.) will also need to be installed from the installation CD:
anaconda-10.1.1.19-1
anaconda-help-10.1.0-1
anaconda-runtime-10.1.1.19-1
Find a location on your hard disk which has the necessary space and type the following commands:
export PYTHONPATH=/usr/lib/anaconda
export PATH="$PATH:/usr/lib/anaconda-runtime"
export BUILDBASE=`pwd`
mkdir -p $BUILDBASE/linux/i386/SRPMS
export ARCH=i386
These commands will create a scratchpad area to work from and setup some convenience environment variables.
Next, download all four of the installation ISOs from the CentOS website into the $BUILDBASE/linux directory.
Once the ISO files are downloaded, we will need to extract their contents into our working directory. You can do so with the following commands. (You should place these into a script and execute it.)
#!/bin/bash
for iso in CentOS-4.1-i386-bin1of4.iso CentOS-4.1-i386-bin2of4.iso CentOS-4.1-i386-bin3of4.iso CentOS-4.1-i386-bin4of4.iso; do
mount -o loop $BUILDBASE/linux/$iso /mnt ; cd /mnt ; \
tar -cf - * | ( cd $BUILDBASE/linux/i386/ ; tar -xpf - ) ; \
cd $BUILDBASE ; umount /mnt
done
If all went well, you can erase the installation ISO files. (You may need the space!)

Step 2: DAC960 Fix

The following steps are required ONLY if you are attempting to fix a booting issue with the DAC960 RAID controller. (The installation CD released by CentOS has a bug which does not allow CentOS 4 to be installed on some computers.)
Proceed to Step 3 if you wish to skip this step.
First, retrieve the latest CentOS 4 kernel source update from a CentOS mirror site. (At the time of writing this web page, it was: kernel-2.6.9-11.EL.src.rpm)
Install the RPM by typing:
rpm -i kernel-2.6.9-11.EL.src.rpm
Go to the /usr/src/redhat/SOURCES directory and modify the following line in the kernel-2.6.9-i586.config file:
# CONFIG_X86_UP_APIC is not set
Change it to:
CONFIG_X86_UP_APIC=y
Next, add the following line below this one and save the file:
CONFIG_X86_UP_IOAPIC=y
Go to the /usr/src/redhat directory and rebuild all of the kernel RPMs by typing:
rpmbuild -ba --target=i586 SPECS/kernel-2.6.spec
This will take a while, but if all goes well, there should be a new set of kernel RPMs in this directory:
/usr/src/redhat/RPMS/i586
Replace the kernel in the $BUILDBASE/linux/i386/CentOS/RPMS directory with the corresponding update from the /usr/src/redhat/RPMS/i586 directory. To do this, type the following command:
cp /usr/src/redhat/RPMS/i586/kernel-2.6.9-11.EL.i586.rpm $BUILDBASE/linux/i586/CentOS/RPMS/.

Step 3: Other updates

If desired at this point, you can download any available updates from a CentOS mirror site and replace each RPM package in the $BUILDBASE/linux/i386/CentOS/RPMS directory with its update.

Step 4: Build

First, we need to re-generate the hdlist file. Do so with the following command:
genhdlist $BUILDBASE/linux/i386
Next, create our package order file by issuing the following command:
pkgorder $BUILDBASE/linux/i386 i386 | tee $BUILDBASE/linux/pkgfile.`date +%Y-%m-%d`
Now, update the installation files by entering the following command:
buildinstall --comp dist-4.1 --pkgorder $BUILDBASE/linux/pkgfile.`date +%Y-%m-%d` \
--version 4.1 --product 'CentOS' --release 'CentOS 4.1' \
$BUILDBASE/linux/i386

Step 5: CD creation

Now that we have completed the build, it's time to split up the files into their CDs and make new ISOs. The following commands will do the split and re-create the hdlist files for each CD:
RELEASE="CentOS 4.1 with updates to $(date '+%Y-%M-%d %H:%m')"

rm -rf $BUILDBASE/linux/i386-disc[1-8]
splittree.py --arch=i386 --total-discs=8 --bin-discs=4 --src-discs=4 --release-string="$RELEASE" \
--pkgorderfile=$BUILDBASE/linux/pkgfile.`date +%Y-%m-%d` \
--distdir=$BUILDBASE/linux/i386 \
--srcdir=$BUILDBASE/linux/i386/SRPMS --productpath=CentOS
rm -f $BUILDBASE/i386-disc1/CentOS/base/hdlist*
genhdlist --withnumbers --fileorder \
$BUILDBASE/fedora/pkgfile.`date +%Y-%m-%d` \
$BUILDBASE/linux/i386-disc[1234]
Finally, create a bash script with the commands listed below and execute it. This will create brand new modified ISO images, which you can use to install CentOS Linux!
(You will need to run the following script from the $BUILDBASE/linux directory.)
#!/bin/sh
myname="Joe Blow "
bootimg="isolinux/isolinux.bin"
bootcat="isolinux/boot.cat"
distname="CentOS"
distvers="4.1"
mkisopts="-R -J -T"
bootopts="-no-emul-boot -boot-load-size 4 -boot-info-table"
mydate="$(date '+%d %b %Y')"
mkisofs $mkisopts $bootopts \
-V "CentOS $distver ($distname) UPDATED Disk 1" \
-A "CentOS $distver ($distname) update created on $mydate" \
-P "$myname" \
-p "$myname" \
-b "$bootimg" \
-c "$bootcat" \
-x lost+found \
-o "$distname"-i386-disc1.iso \
i386-disc1
for i in 2 3 4 ; do
mkisofs $mkisopts \
-V "CentOS $distver ($distname) UPDATED Disk $i" \
-A "CentOS $distver ($distname) update created on $mydate" \
-P "$myname" \
-p "$myname" \
-x lost+found \
-o "$distname"-i386-disc${i}.iso \
i386-disc${i}
done 

SMTP 代碼含意說明

一. SMTP 代码:
SMTP 有一组固定的响应代码,表示邮件服务器对于传送邮件要求的响应状况。其中 421、450、451、452、550、551、552、553、554 等 9 组代码表示您要求邮件服务器执行的动作不成功。
·         354
Start Mail input
开始传输邮件正文

·         421
Service not available, closing transmission channel
括号内的主机无法提供正常服务,关闭传送管道,邮件将滞留在主机上

·         440
邮件址错误

·         445
Server Rejected
被封锁

·         450
Client host rejected, Cannot resolve PTR
Temporary Process Error
Resource temporarily unaviable,please try again later
Requested mail action not taken: mailbox unavailable
无法 IP 反查

Requested mail action not taken: mailbox unavailable
所要求的邮件动作无法执行:邮件信箱无法提供服务,邮件将滞留在主机上
·         451
Domain of sender address sender@mail.com.tw does not resolve
qq trouble creating files in queue (#4.3.0)
queuename: Cannot create "qfCAA21081" in "/var/spool/mqueue" (euid=0): No space left on device
Requested action aborted, errno=28.
无法解析寄件者邮件地址

Requested action aborted: local error in processing
要求动作中断:本地端错误

Requested action aborted,errno=28
传送失败,检查网络问题。

·         452
Message for would exceed mailbox quota
Requested action not taken: insufficient system storage
要求动作无法执行:系统空间不足

Insufficient system storage
在使用Esmtp认证的过程中出错,检查一下Esmtp设置,多试几次。

·         454
Client was not authenticated
安全因素,被封锁

·         472
sender@mail.com.tw no DNS A-data returned
无法 IP 反查

·         501
Domain of sender address sender@mail.com.tw does not exist
无法 IP 反查

Mailbox not found
5.1.1 ... User unknown
无此使用者

Syntax error,parameters in command "RCPT TO:min@laohuyatse.com.tw>"unrecognized or missing
no local part
Syntax error in recipient:
"@" or "." expected after "CC"
"@" or "." expected after "fau" :
email格式l错误
·         503
Either sender or receiver must be local account.
安全因素,权限不足
CAT@MAIL.FORTEK.COM.TW
无此使用者,不是本主机转送信件的使用者

error:needmail command
need mail before RCPT
Bad sequence of commands
消息命令顺序出错,一般出现在其他错误之后,先检查之前出现的错误提示。

5.0.0 polite people say HELO first
传输中的语法错误,原因不明
·         505
client was not authenticated
使用263.net和sohu.com的Smtp服务器时,不但要用自身的邮箱发信,而且要加入身份验证,所以即要在"个人信息"中填写正确邮箱地址,又要选中"SMTP服务器需要认证"。

·         521
This system is configured to reject mail from 211.20.70.148
安全因素,被封锁

·         535
Error:authenticatin failed
Authentication unsuccessful
在使用Esmtp认证的过程中出错,检查一下Esmtp设置,多试几次。

·         550
unknown user
User unknown
Invalid User
Recipient unknown
Mailbox disabled for this recipient
Unknown local part
Invalid recipient
Unable to relay for no such user
Recipient unknown
This account is not allowed
recipient unknown
No such mail drop defined,user disabled
I don't know
Relaying is prohibited
Relaying denied
relaying mail to <> is not allowed
<>... relaying denied
5.7.1 relaying not permitted:
REJECT SMTP Protocol Returned a Permanent Error 550 Forwarding percent hack is not permitted
Requested action not taken: mailbox unavailable
无此使用者,所要求动作无法执行:信箱不存在,邮件将退回给寄件者,或者限制了收件人的地址,只能换一个Smtp服务器。

System is busy
邮件系统错误

Subj similar too many!!
太多同主题信件

Relaying denied. IP name lookup failed
IP name lookup failed
DNS FAILURE
cannot route to sender address
无法 IP 反查

Relaying denied
Mailbox unavailable: This site may not be used as a relay agent.
无法转寄

<>:local user only
<>:Invalid User
Invalid recipient
使用163.net,163.com,yeah.net和netease.com之类的Smtp服务器时,只能用自身的信箱发信,所以要在Outlook Express的"帐户属性"中的"个人信息"里面填写正确的邮件地址。

Unable to relay for ...
多出现在用Wingate代理服务器发送邮件时。虽然在Wingate中"POP3 邮箱帐号"要使用"用户名#POP3地址"的格式,但在"帐户属性"中的"个人信息"中还是要填写一般的格式。

·         551
we do not relay ...
delivery not allowed to non-local recipient
无法转寄,使用21cn.com,china.com,371.net,sina.com等大多数信箱的smtp服务器时,只能用自身的信箱发信,所以要在Outlook Express的"帐户属性"中的"个人信息"里面填写正确的邮件地址。

User not local; please try
邮件服务器知道使用者不属于本地端,将尝试括号内的转送路径

·         552
Requested mail action aborted: exceeded storage allocation
所要求的动作中断:超出所分配的储存空间,邮件将退回给寄件者
Sorry, we don't allow mail from your host.
被封锁

·         553
sorry, that domain isn't in my list of allowed rcpthosts
mailbox name not allowed
邮件地址错误
Requested action not taken: mailbox name not allowed
sorry, your envelop sender is in my badmailfrom list
所要求的动作未执行:信箱不允许该动作执行 ,或者服务器限制了收件人的地址,只能换一个smtp服务器发信。

Relay restriction.
From <>, message blocked.
sorry,you are not allow to use this SMTP to relay your eami
sorry, that domain isn't in my list of allowed rcpthosts
使用21cn.com,china.com,371.net,sina.com等大多数信箱的smtp服务器时,只能用自身的信箱发信,所以要在Outlook Express的"帐户属性"中的"个人信息"里面填写正确的邮件地址。

authentication is required to send mail as <>
使用263.net和sohu.com的Smtp服务器时,不但要用自身的邮箱发信,而且要加入身份验证,所以即要在"个人信息"中填写正确邮箱地址,又要选中"SMTP服务器需要认证"。

<>...domain name required
多出现在用Wingate代理服务器发送邮件时。虽然在Wingate中"POP3 邮箱帐号"要使用"用户名#POP3地址"的格式,但在"帐户属性"中的"个人信息"中还是要填写一般的格式。

·         554
delivery error: dd This user doesn't have a yahoo.com account
delivery error: dd Sorry, your message to xxxxyahoo.com cannot be delivered. This account is over quota.
无此使用者

Transaction failed
传送失败,检查网络问题。

·         571
we don't accept junk mail (mail.sysnet.net.tw)
无效的寄件者

二. DSN错误代码解释:
DSN 为 Delivery Status Notification 的简写,为邮件传递状态通知,以三个数字 a.b.c 的形式组成,分别解释邮件是否传递成功、失败的原因,以及进一步详情。
例:
〔DSN〕代码: a . b . c
说明:
a 位置只可能出现三种数字 2、4 或 5 。
2 表示本讯息递送成功
4 暂时传递不成功,邮件服务器每 15 分钟将重试一次,尝试 5 天若仍告失败将退回给寄件者。
5 邮件最终传送失败。

b 和 c 位置有 1-7 七种可能数字,分别代表不同类别的问题。
1 邮件地址 (Address)
2 收件者信箱 (Mailbox)
3 目的地邮件系统 (Mail System)
4 邮件传送系统网络与路由 (Network and Routing)
5 邮件传送协议 (Mail Delivery Protocol)
6 邮件内容或媒介(Message Content or Media)
7 安全或邮件监控规则(Security or Policy)
配合 b 位置的数字,进一步解释邮件传送不成功的原因
注意事项:第一个字符为 4 或 5
4.X.X 代表暂时错误,邮件服务器将稍后再试
5.X.X 代表邮件传送失败
 
1.    X.1.X 表示邮件地址(Address)问题
X.1.0
Other address status
其它邮件地址问题

X.1.1
Bad destination mailbox address
收件地址信箱错误

X.1.2
Bad destination system address
收件地址系统错误

X.1.3
Bad destination mailbox address syntax
收件地址信箱句法错误

X.1.4
Destination mailbox address ambiguous
收件地址信箱不清

X .1.5
Destination mailbox address valid
收件地址信箱无效

X.1.6
Mailbox has moved transcript
信箱已移除

X.1.7
Bad sender's mailbox address syntax
寄件者信箱句法错误

X.1.8
Bad sender's system address
寄件者系统错误

2.    X.2.X 表示收件者信箱(Mailbox)问题
X.2.0
Other or undefined mailbox status
其它或未定义的收件者信箱问题

X.2.1
Mailbox disabled, not accepting messages
信箱无法运作,无法接收信件

X.2.2
Mailbox full
信箱已满

X.2.3
Message length exceeds administrative limit.
邮件长度超出管理者限制

X.2.4
Mailing list expansion problem
此信箱属于特定邮件群组,但群组无法开展

3.    X.3.X 表示目的地邮件系统(Mail System)问题
X.3.0
Other or undefined mail system status
其它或未定义的邮件系统问题

X.3.1
Mail system full
邮件系统储存空间已满

X.3.2
System not accepting network messages
主机无法接收信件,可能暂时关机、维修等

X.3.3
System not capable of selected features
指定的邮件特征无法为收件主机所接收

X.3.4
Message too big for system
邮件大小超出邮件系统限制

X.3.5
System incorrectly configured
系统设定错误,无法接收邮件

4.    X.4.X 表示邮件传送系统网络与路由(Network and Routing)问题
X.4.0
Other or undefined network or routing status
其它或未定义的网络与路邮设定问题

X.4.1
No answer from host
主机无响应

X.4.2
Bad connection
联机错误

X.4.3
Directory server failure
网络系统无法转送邮件,例如无法联机到DNS服务器

X.4.4
Unable to route
邮件系统所需的路由信息不足,无法决定传送路由

X.4.5
Network congestion
网络壅塞

X.4.6
Routing loop detected
邮件因错误的路由设定,多次遶行而无法传送

X.4.7
Delivery time expired
邮件滞留主机过久

5.    X.5.X表示邮件传送协议问题 (Mail Delivery Protocol)问题,可能是寄件方、收信方或是传送邮件系统的问题
X.5.0 Other or undefined protocol status
其它或未定义的通讯协议问题

X.5.1 Invalid command
命令无效

X.5.2 Syntax error
邮件传送协议的句法错误

X.5.3 Too many recipients
太多收件者

X.5.4 Invalid command arguments
命令叙述错误

X.5.5 Wrong protocol version
错误的通讯协议版本

6.    X.6.X表示邮件内容或媒介(Message Content or Media)的问题,收件者与寄件者双方必需支持同样的内容类别(Content Type)
X.6.0
Other or undefined media error
其它或未定义的媒介问题

X.6.1
Media not supported
传送协议或转送邮件的系统不支持该媒介

X.6.2
Conversion required and prohibited
邮件内容在传送之前必需经过转换动作,但该动作不被允许

X.6.3
Conversion required but not supported
邮件内容在转送之前须经过转换动作,但无法执行

X.6.4
Conversion with loss performed
邮件传送成功,但部份内容因无法转换而遗失

X.6.5
Conversion failed
转换动作失败

7.    X.7.X 表示安全或邮件监控规则(Security or Policy) 的问题
X.7.0
Other or undefined security status
其它安全或邮件监控规则问题

X.7.1
Delivery not authorized, message refused
寄件者无授权传送信件

X.7.2
Mailing list expansion prohibited
寄件者无授权寄信予该邮件群组

X.7.3
Security conversion required but not possible
邮件安全协定

X.7.4
Security features not supported
邮件含有安全特征如认证措施,但不为传送协议所接受

X.7.5
Cryptographic failure
经授权得以认证或解密该邮件的系统无法完成该动作,因所需信息不完全

X.7.6
Cryptographic algorithm not supported
经授权得以认证或解密该邮件的系统无法完成该动作,因算法不支持

X.7.7
Message integrity failure
经授权得以认证该邮件的系统无法完成该动作,因邮件已损毁 




SMTP reply codes

See rfc2821 for the basic specification of SMTP; see also rfc1123 for important additional information.
See rfc1893 and rfc2034 for information about enhanced status codes.
Check the RFC index for further mail-related RFCs.
Code
Meaning
200
(nonstandard success response, see rfc876)
211
System status, or system help reply
214
Help message
220
Service ready
221
Service closing transmission channel
250
Requested mail action okay, completed
251
User not local; will forward to
354
Start mail input; end with .
421
Service not available, closing transmission channel
450
Requested mail action not taken: mailbox unavailable
451
Requested action aborted: local error in processing
452
Requested action not taken: insufficient system storage
500
Syntax error, command unrecognised
501
Syntax error in parameters or arguments
502
Command not implemented
503
Bad sequence of commands
504
Command parameter not implemented
521
does not accept mail (see rfc1846)
530
Access denied (???a Sendmailism)
550
Requested action not taken: mailbox unavailable
551
User not local; please try
552
Requested mail action aborted: exceeded storage allocation
553
Requested action not taken: mailbox name not allowed
554
Transaction failed
Command
Code
Description



220
Service ready

421
Service not available, closing transmission channel



250
Requested mail action okay, completed

500
Syntax error, command unrecognised

501
Syntax error in parameters or arguments

504
Command parameter not implemented

521
does not accept mail [rfc1846]

421
Service not available, closing transmission channel



250
Requested mail action okay, completed

550
Not implemented

500
Syntax error, command unrecognised

501
Syntax error in parameters or arguments

504
Command parameter not implemented

421
Service not available, closing transmission channel



250
Requested mail action okay, completed

552
Requested mail action aborted: exceeded storage allocation

451
Requested action aborted: local error in processing

452
Requested action not taken: insufficient system storage

500
Syntax error, command unrecognised

501
Syntax error in parameters or arguments

421
Service not available, closing transmission channel



250
Requested mail action okay, completed

251
User not local; will forward to

550
Requested action not taken: mailbox unavailable

551
User not local; please try

552
Requested mail action aborted: exceeded storage allocation

553
Requested action not taken: mailbox name not allowed

450
Requested mail action not taken: mailbox unavailable

451
Requested action aborted: local error in processing

452
Requested action not taken: insufficient system storage

500
Syntax error, command unrecognised

501
Syntax error in parameters or arguments

503
Bad sequence of commands

521
does not accept mail [rfc1846]

421
Service not available, closing transmission channel



354
Start mail input; end with .

451
Requested action aborted: local error in processing

554
Transaction failed

500
Syntax error, command unrecognised

501
Syntax error in parameters or arguments

503
Bad sequence of commands

421
Service not available, closing transmission channel
received data



250
Requested mail action okay, completed

552
Requested mail action aborted: exceeded storage allocation

554
Transaction failed

451
Requested action aborted: local error in processing

452
Requested action not taken: insufficient system storage



200
(nonstandard success response, see rfc876)

250
Requested mail action okay, completed

500
Syntax error, command unrecognised

501
Syntax error in parameters or arguments

504
Command parameter not implemented

421
Service not available, closing transmission channel



250
Requested mail action okay, completed

552
Requested mail action aborted: exceeded storage allocation

451
Requested action aborted: local error in processing

452
Requested action not taken: insufficient system storage

500
Syntax error, command unrecognised

501
Syntax error in parameters or arguments

502
Command not implemented

421
Service not available, closing transmission channel



250
Requested mail action okay, completed

552
Requested mail action aborted: exceeded storage allocation

451
Requested action aborted: local error in processing

452
Requested action not taken: insufficient system storage

500
Syntax error, command unrecognised

501
Syntax error in parameters or arguments

502
Command not implemented

421
Service not available, closing transmission channel



250
Requested mail action okay, completed

552
Requested mail action aborted: exceeded storage allocation

451
Requested action aborted: local error in processing

452
Requested action not taken: insufficient system storage

500
Syntax error, command unrecognised

501
Syntax error in parameters or arguments

502
Command not implemented

421
Service not available, closing transmission channel



250
Requested mail action okay, completed

251
User not local; will forward to

550
Requested action not taken: mailbox unavailable

551
User not local; please try

553
Requested action not taken: mailbox name not allowed

500
Syntax error, command unrecognised

501
Syntax error in parameters or arguments

502
Command not implemented

504
Command parameter not implemented

421
Service not available, closing transmission channel



250
Requested mail action okay, completed

550
Requested action not taken: mailbox unavailable

500
Syntax error, command unrecognised

501
Syntax error in parameters or arguments

502
Command not implemented

504
Command parameter not implemented

421
Service not available, closing transmission channel



211
System status, or system help reply

214
Help message

500
Syntax error, command unrecognised

501
Syntax error in parameters or arguments

502
Command not implemented

504
Command parameter not implemented

421
Service not available, closing transmission channel



200
(nonstandard success response, see rfc876)

250
Requested mail action okay, completed

500
Syntax error, command unrecognised

421
Service not available, closing transmission channel



221
Service closing transmission channel

500
Syntax error, command unrecognised



250
Requested mail action okay, completed

502
Command not implemented

500
Syntax error, command unrecognised

503
Bad sequence of commands