LILO, Linux Crash Rescue HOW-TO 中譯版 <!-- chapt change LILO, Linux Crash Rescue HOW-TO 中譯版 --> <author>作者:Al Dev (Alavoor Vasudevan) <htmlurl url="mailto:alavoor[AT]@yahoo.com" name="alavoor[AT]@yahoo.com"><newline> 譯者:黃國偉 <htmlurl url="mailto:u4561055@cc.ncu.edu.tw" name="u4561055@cc.ncu.edu.tw"> <date>v10.8, 25 Jan 2003 翻譯日期:04 Feb 2003 <abstract> 這份文件探討從 Linux 系統當機中回復的方法。 造成 Linux 系統當機的各種原因可能是 - LILO 毀損、 linux 無法開機、 硬碟主開機記錄(Master Boot Record, MBR)損壞、 或是安裝其他作業系統例如 Windows NT 而將 LILO 或 MBR 蓋寫掉所造成 linux 無法開機。 </abstract> <!-- Table of contents --> <toc> <!-- Begin the document --> <sect>簡介 <p> <bf> (此文件的最新版本位於 <url url="http://www.milkywaygalaxy.freeservers.com">。 您可以從那裡得到版本的變動情形。) </bf> 您無法避免意外的發生;如果意外發生在 linux 系統, 這可能會損害到硬碟主開機記錄 (MBR) 或是 LILO (Linux boot Loader)。 當 linux 由於硬碟故障而導致無法開機時,意外就會發生。 假如您不小心重新劃分磁碟,或是在 linux 系統的電腦上安裝其他作業系統, 例如:Windows 98/NT,LILO 也可能會失效。 這份文件給您一些建議、秘訣、和快速的指引來快速回復系統, 而不必費心地研讀上百頁有關 LILO 或 Linux 的文件。 <sect1> 小型軟碟 Linux 系統 <label id="tiny"> <p> 為了回復任何作業系統如 Windows 95/NT/2000、OS/2、BeOS、或 Linux, 您可能需要裝在一片軟碟片的小型 linux 系統。 請參考以下所列出的小型軟碟 linux 系統 - <itemize> <item> 最佳 <url name="Tomsrtbt" url="http://www.toms.net/~toehser/rb"> <item> 次佳的軟碟 linux 系統 <url name="MuLinux" url="http://sunsite.dk/mulinux"> <item> <url name="Trinux" url="http://www.trinux.org"> <item> <url name="DLX" url="http://www.wu-wien.ac.at/usr/h93/h9301726/dlx.html"> <item> <url name="FloppyFW" url="http://www.zelow.no/floppyfw"> <item> <url name="Linux Router Proejct floppy" url="http://www.psychosis.com/linux-router"> <item> <url name="Tiny Linux distributions" url="http://www.txdirect.net/users/mdfranz/tinux.html"> <item> <url name="TINYLinux" url="http://tiny.seul.org/en"> </itemize> <sect1> 小型 CDROM Linux 系統 <label id="tinycdrom"> <p> <itemize> <item> Linuxcare Bootable Toolbox <url url="http://lbt.linuxcare.com"> <item> LNX-BBC <url url="http://lnxbbc.org"> <item> Tom's Root and Boot "the most GNU/Linux on one floppy disk" <url url="http://www.toms.net/rb"> <item> "Innominate-Linux-Rescue-System" - a CD-based rescue system <url url="http://innominate.org/projects/rescueCD"> <item> Irish Linux Users Group (ILUG) BBC: A bootable CD ISO <url url="ftp://ftp.blackstar.co.uk/pub/ILUG/"> <item> Lubbock: Meant to be the "Tom's Root Boot" of CDs <url url="http://lubbock.sourceforge.net"> <item> Repairlix: a networked Linux distribution/bootable system intended to fit in 12MB of media. <url url="http://repairlix.sourceforge.net"> <item> SuperRescue: a Red Hat-based bootable CD <url url="http://www.kernel.org/pub/dist/superrescue"> <item> Timo's Rescue CD Set: an easy way of generating el Torito Boot Cd's <url url="http://rescuecd.sourceforge.net"> </itemize> <sect> 當機回復<label id="crash"> <p> <sect1> 準備工作建議 <label id="tips"> <p> 在您使用下個章節的 Tomsrtbt 軟碟或使用 RedHat 開機光碟 (使用救援選項) 登入之後, 您最好先備分重要的系統檔案,像 /etc/fstab、/etc/lilo.conf。 如此在當機時或系統檔案發生問題時是、活B菕B楚﹛BBB磽野峈滿C <code> bash# cp /etc/fstab /etc/fstab.orig bash# cp /etc/lilo.con etc/lilo.c,,,.orig bash# cp /etc/hosts /etc/hosts.orig bash# cp /etc/hosts.allow /etc/hosts.allow.orig bash# cp /etc/hosts.deny /etc/hosts.deny.orig bash# cp /etc/inetd.conf /etc/inetd.conf.orig bash# cp /etc/inittab /etc/inittab.orig bash# cp /etc/networks /etc/networks.orig </code> <sect1>使用 Linux 光碟的救援模式 <p> 大部份的 Linux 發行套件像是 RedHat、SUSE、Debian, 皆有提供具有救援功能的光碟。 您應當設定電腦的 BIOS ,使電腦能以 IDE 光碟機為第一開機裝置,以便使用這類光碟。 設定 BIOS 時 (在開機時按 F8 鍵),以光碟機為第一開機裝置; 軟碟機為第二開機裝置;硬碟為第三開機裝置。 將 Linux 光碟片放入光碟機,並重開機。 Linux 套件將會被讀取。在提示符號 (prompt) 下選擇「救援操作」。 在救援操作模式下,掛上 (mount) 硬碟並嘗試修復它。 <code> # chroot /mnt/SYSIMAGE # df </code> 使用 chroot 後,整個系統看起來就像是從硬碟開機一樣。 您可以看到硬碟上的所有分割區,並且可以修復或回復檔案。 <sect1> 回復系統的快速步驟 <p> 循著這些步驟執行,以便從 LILO 或系統當機中回復。 <enum> <item> <bf>狀況 1:</bf> 假如系統無法開機 - <p> 取得並建立 tomsrtbt 開機磁片 <url url="http://www.toms.net/rb">, 或 MuLinux 開機磁片 (請參考 <ref name="Tiny Linux" id="tiny">)。 並使用 tomsrtbt 開機磁片開機。 使用 fdisk 指令找出分割區(partitions)。 試著找出 root 和 boot 分割區。注意! root 分割區自己需擁有 /boot 檔案。 Linux 的 root 分割區包含下列資料夾 <bf>bin</bf>, <bf>boot</bf>, <bf>etc</bf>, <bf>usr</bf>. Linux 的 boot 分割區則包含以下的資料夾: <bf>vmlinuz</bf>, <bf>boot.b</bf>, <bf>chain.b</bf>, <bf>map</bf>. 使用以下步驟找出 root 分割區: <code> bash# fdisk /dev/hda Command (m for help): m (顯示指令的輔助選單) Command (m for help): p (列出硬碟分割區) Command (m for help): q bash# mkdir /test bash# mount /dev/hda1 /test bash# ls /test 您應該會看到 root 分割區顯示如下 - bin fd lib mnt proc sbin usr boot dev etc home lost+found opt root tmp var </code> 如果此分割區並非 root 分割區,試試下個分割區 /dev/hda2 。 持續嚐試 hda3, hda4, hda5 等,直到找出 root 分割區為止。 如果您在 <bf>hda</bf> 上沒有找到 root 分割區, 則重覆以上步驟尋找其他硬碟,像是 <bf>hdb</bf>、<bf>hdc</bf>、<bf>hdd</bf>等。 接下來您應找出 /boot、/usr、和 /var 分割區。 在建立新的 lilo 配置時,這些分割區的位置是必需的。 以我的系統為例,root 分割區是在 /dev/hda4: <code> bash# mkdir /rootpart bash# mount /dev/hda4 /rootpart bash# cat /rootpart/etc/fstab 閱讀 fstab 的內容,並且按照 fstab 檔案掛上 (mount) 分割區。像下面這樣 - bash# mount /dev/hda5 /rootpart/boot bash# mount /dev/hda6 /rootpart/usr bash# mount /dev/hda7 /rootpart/var bash# mount /dev/hda8 /rootpart/opt bash# mount /dev/hda9 /rootpart/root bash# mount /dev/hda10 /rootpart/home </code> 以我的系統為例,按照 fstab 所顯示,hda5 是 <bf>boot</bf>、hda6 是 <bf>usr</bf>, hda7 是 <bf>var</bf>、hda8 是 <bf>opt</bf>、 hda9 是 <bf>root</bf>、hda10 是 <bf>home</bf>、而 hda11 是 windows95 (FAT16 分割區)。 編輯 /etc/fstab (不是 /rootpart/etc/fstab) 並且加入(以下程式碼範例) <code> /dev/hda4 /rootpart ext2 defaults 1 1 /dev/hda5 /rootpart/boot ext2 defaults 1 1 /dev/hda6 /rootpart/usr ext2 defaults 1 1 /dev/hda7 /rootpart/var ext2 defaults 1 1 /dev/hda8 /rootpart/opt ext2 defaults 1 1 /dev/hda9 /rootpart/root ext2 defaults 1 1 /dev/hda10 /rootpart/home ext2 defaults 1 1 /dev/hda11 /rootpart/win95part vfat defaults 1 1 在我的電腦中,hda4 為 linux 的 root 分割區、hda5 為 boot 分割區、 hda11 則為 windows 95 的 vfat 系統。 bash# mkdir /rootpart/win95part bash# mount /rootpart/win95part 使用 fsck 或 e2fsck 指令修復有問題的分割區。 bash# man fsck bash# man e2fsck </code> <p> <item> <bf>狀況 2:</bf> 如果 LILO 是無效的.. <p> 依照狀況 1 的步驟來排除問題。如果無法解決,則參照以下步驟。 在執行狀況 1 的步驟之後,您應該已經掛載上 /rootpart 並且已經建立好 /etc/fstab 檔案。 注意:在進行以下步驟時,觀察 chroot 如何運作是很重要的。 chroot 所使用的 <bf>/sbin/lilo</bf> 檔案的正確位置是在 <bf>/rootpart/sbin/lilo</bf>, 而<bf>不是</bf>在 /sbin!!因此請不要混淆。 <code> bash# mount -a bash# chroot /rootpart /sbin/lilo -q bash# man chroot bash# chroot /rootpart /sbin/lilo </code> 注意:使用 chroot 的新手可能會被混淆。如果 chroot 抱怨它找不到 /boot/map 檔案, 這種情形實際上代表著它無法找到 /rootpart/boot/map。因為您使用 /rootpart 當作 chroot 的第一引數 (first argument),所有的化身 (references) 都指向 /rootpart。 您也可以選擇直接使用 /sbin/lilo 以代替 chroot。 lilo 加選項 -r 實際上就和 chroot 指令是一樣的。 <bf>強烈建議</bf>您使用 chroot,而不要使用 lilo -r, 因為使用 chroot 比較方便,且較容易找出錯誤。 <code> bash# man lilo bash# /sbin/lilo -r /rootpart </code> <p> <item> <bf>狀況 3:</bf> 如果 LILO 是無效的.. <p> 如果使用狀況 1 和狀況 2 的步驟均無法解決, 假如您有使用 'mkbootdisk' 製作過開機片(於安裝時或參考 'man mkbootdisk'自行建立),則使用您的開機磁片來開機並修復分割區。 mkbootdisk 存在於 mkbootdisk*.rpm 的套件,您必須安裝它。 (譯注:隨不同發行套件而有所差異;請洽詢您的發行套件廠商或組織) 或者從 <url url="http://www.bootdisk.com/"> 取得 Linux/NT/Windows/DOS/Mac 的開機磁片。 其他選擇 - 找 Linux 安裝光碟來使用。 每個 Linux 套件會在光碟裡提供救援磁片的 image file,在 Linux 環境下,鍵入 "dd if=/cdrom/disks/rescue of=/dev/fd0" 來建立救援磁片。在 DOS 環境下, 使用 rawrite.exe (包含在 Linux 光碟裡),鍵入 "rawrite image-name a:" 來建立救援磁片。 <p> <item> <bf>狀況 4:</bf> 如果以上狀況 1、2、3 的步驟皆無法解決問題,且您也沒有開機磁片 <p> 假如您有其他 linux 系統的電腦,以 root 身份登入並且執行 - 注意:如果您編譯您自己的核心(kernel)為 bzImage (例如 bzImage-2.4.4), 您應當使用以下方法對 vmlinuz-2.4.4 建立硬連結(hard link)。(注意 vmlinuz 的 z,而非 vmlinux) 如果您並未做此步驟, 則 mkbootdisk 指令可能會失敗。 <code> bash# cd /boot bash# ls -l vmlinuz* bash# ln /boot/bzImage-2.4.4 /boot/vmlinuz-2.4.4 </code> 現在您已有 bzImage 和 vmlinuz,執行下列指令 - <code> bash$ man mkbootdisk bash# cp /etc/lilo.conf /etc/lilo-original.conf </code> 編輯 /etc/lilo.conf 並將您在 '狀況 1' 所獲得的 root 分割區格式填入;之後插入空白磁碟片並執行 - <code> bash# mkbootdisk --device /dev/fd0 2.2.12-20 (譯注:2.2.12-20 為核心版本編號,請自行依照您的 linux 核心版本作改變。) </code> mkbootdisk 存在於 mkbootdisk*.rpm 的套件,您必須安裝它。 (譯注:隨不同發行套件而有所差異;請洽詢您的發行套件廠商或組織) 您必須確保將 /etc/lilo-original.conf 更改回原來的檔名 /etc/lilo.conf!! 再以此開機磁片進行狀況 3 的步驟。 <p> <item> <bf>狀況 5: </bf> 這是最壞的情況,希望您不會走到這個地步。 狀況 1 到 4 已包含了絕大多數的案例,但是如果連狀況 1、2、3、和 4 的步驟都無法解決 - <p> <it><bf>第一步: </bf></it> 使用 tomsrtbt 開機磁片開機, (請參考 <ref name="Tiny Linux" id="tiny">) 掛上分割區, 並且使用以下指令備份 root 分割區至其他還有磁碟空間的分割區 - <code> 編輯 /etc/fstab 並且寫入(以下的程式碼範例, 您可能必須按照您的磁碟機實際狀況作改變) - /dev/hda4 /rootpart ext2 defaults 1 1 /dev/hda11 /b1 vfat defaults 1 1 bash$ mkdir /rootpart; mount /rootpart bash$ mkdir /b1; mount /b1 bash$ cd / bash$ df 查看 /b1 是否有足夠的磁碟空間,以便使用 tar 來備份 root 分割區。 bash$ tar cvf /b1/root-hda4.tar /rootpart </code> <p> <it><bf>第二步: </bf></it> 放入 Linux 光碟片,重開機並安裝 redhat linux (譯注:或安裝其他 linux 發行套件) 在 /dev/hda4 (但<bf>千萬不要</bf>安裝任何多餘的套件, 您只需要安裝 root、boot 系統,和 LILO 管理者。 也就是說,選擇最小安裝即可)。 安裝程式也將會安裝 LILO 在您的硬碟裡。 現在重新啟動 linux,以 root 身份登入,並且執行 - <code> bash$ man mkbootdisk bash# cp /etc/lilo.conf /etc/lilo-original.conf </code> 注意:您<bf>必須</bf>記得將 lilo-original.conf 複製回 lilo.conf!! 編輯 /etc/lilo.conf 並將您在 '狀況 1' 所獲得的 root 分割區格式填入;之後插入空白磁碟片並執行 - <code> bash# mkbootdisk --device /dev/fd0 2.2.12-20 (譯注:2.2.12-20 為核心版本編號,請自行依照您的 linux 核心版本作改變。) bash# cp /etc/lilo-original.conf /etc/lilo.conf </code> 測試此開機磁片,檢視其是否能運作, 並將第一步中利用 tar 作備分的檔案 /b1/root-hda4.tar 回復。 (譯注:您可使用 tar xvf 來回復。詳見 tar manpage) </enum> <sect1> 預防性措施 <p> 您應當採取下列的預防性措施來處理未來可能發生的問題。 <itemize> <item> 您<bf>一定要</bf>偶爾製作救援開機磁片,且在您改變分割區時一定要製作。 插入空白磁碟片並執行 - <code> bash$ man mkbootdisk mkbootdisk 存在於 mkbootdisk*.rpm 的套件,您必須安裝它。 (譯注:隨不同發行套件而有所差異;請洽詢您的發行套件廠商或組織) bash$ mkbootdisk --help bash$ mkbootdisk --device /dev/fd0 2.2.12-20 (譯注:2.2.12-20 為核心版本編號,請自行依照您的 linux 核心版本作改變。) </code> <p> <item> 您<bf>必須</bf>將分割表設定 (partition tables setup) 備份至磁片和硬碟裡。 您也應將此設定列印並貼至電腦機殼上。 <code> bash$ su - root bash# man fdisk bash# fdisk -l /dev/sda > partition_table_backup.txt </code> 如果您需要重新分割硬碟,這樣做是非常有幫助的。 從列印出來的分割表資料,您將會了解分割區磁柱的起始。 回復系統時,在重新分割與格式化硬碟後,您可以利用備份資料回復原先的分割設定。 <p> <item> 您手邊必須擁有 tomsrtbt 的開機磁片。詳見 <url url="http://www.toms.net/rb"> (請參考 <ref name="Tiny Linux" id="tiny">) <p> <item> 您手邊必須擁有 Yard 救援和開機磁片。詳見 <url url="http://www.linuxlots.com/~fawcett/yard"> <p> <item> 備分 /root 與 /boot 目錄。使用 Tomsrtbt 開機磁片開機, (請參考 <ref name="Tiny Linux" id="tiny">) 並且執行 <code> bash# vi /etc/fstab 加入以下數行 - /dev/hda1 /a1 vfat defaults 1 1 /dev/hdb1 /b1 vfat defaults 1 1 以我的系統為例, hda1 為 linux 之 root 分割區 '/' bash# cd / bash# tar cvf /b1/linux-root-partition-hda1.tar a1 bash# tar cvf /b1/linux-boot-partition-hda1.tar a1/boot </code> </itemize> <sect1> 移除 LILO <p> 您可以使用 DOS 啟動載入程式(boot loader)載入啟動磁區,並以之取代 LILO。 在 MS DOS 提示符號下輸入以下指令: <code> FDISK /MBR </code> 此處的 MBR 代表 "硬碟主開機記錄(Master Boot Record)"。 請參考 LILO 文件,取得其他移除 LILO 的方法;這些文件通常放在 linux 系統上的 /usr/doc/lilo* (譯注:或者是 /usr/share/doc/lilo*)。也請參考 'man lilo'。 <sect1> 常犯錯誤 <p> 在您更改 /etc/lilo.conf 之後,您<bf>必須執行 lilo </bf>,使您的改變生效。 忘了執行是 linux 初學者很常犯的錯誤。執行 - <code> bash# lilo -v -v -v </code> <sect> 相關網站 <p> 請參閱以下位址,可取得 LILO、Linux 救援、當機回復的相關資訊 - <itemize> <item> Mini Lilo HOWTO at <url url="http://www.linuxdoc.org/HOWTO/mini/LILO.html"> <item> Bootdisk-HOWTO at <url url="http://www.metalab.unc.edu/LDP/HOWTO/Bootdisk-HOWTO/index.html"> <p> <item> Pre-made boot disks at <url url="http://www.linuxdoc.org/HOWTO/Bootdisk-HOWTO/"> <item> Boot disks for Linux/NT/Windows/DOS/Mac at <url url="http://www.bootdisk.com"> <item> Tomsrtbt boot floppy disk <url url="http://www.toms.net/rb"> (請參閱 <ref name="Tiny Linux" id="tiny">) <item> Yard rescue and boot floppy disk <url url="http://www.linuxlots.com/~fawcett/yard"> <p> <item> BootPrompt-HOWTO at <url url="http://www.linuxdoc.org/HOWTO/BootPrompt-HOWTO.html"> <item> Multiboot with LILO mini HOWTO at <url url="http://www.linuxdoc.org/HOWTO/mini/Multiboot-with-LILO.html"> <item> Linux+WinNT mini HOWTO at <url url="http://www.linuxdoc.org/HOWTO/mini/Linux+WinNT.html"> <p> <item> Linux goodies main site <url url="http://www.milkywaygalaxy.freeservers.com"> 映射站如下 - <url url="http://aldev0.webjump.com">, <url name="angelfire" url="http://www.angelfire.com/country/aldev0">, <url name="geocities" url="http://www.geocities.com/alavoor/index.html">, <url name="virtualave" url="http://aldev0.virtualave.net">, <url name="50megs" url="http://aldev0.50megs.com">, <url name="theglobe" url="http://members.theglobe.com/aldev1/index.html">, <url name="NBCi" url="http://members.nbci.com/alavoor">, <url name="Terrashare" url="http://aldev.terrashare.com">, <url name="Fortunecity" url="http://members.fortunecity.com/aldev">, <url name="Freewebsites" url="http://aldev.freewebsites.com">, <url name="Tripod" url="http://members.tripod.lycos.com/aldev">, <url name="Spree" url="http://members.spree.com/technology/aldev">, <url name="Escalix" url="http://www.escalix.com/freepage/aldev">, <url name="Httpcity" url="http://www.httpcity.com/aldev/index.html">, <url name="Freeservers" url="http://aldev.freeservers.com">. <item> Vim color text editor for C++, C <url url="http://metalab.unc.edu/LDP/HOWTO/Vim-HOWTO.html"> </itemize> <sect> 此份文件的其他格式 <p> 此份文件是以 14 種不同的格式所發行的 - DVI, Postscript, Latex, Adobe Acrobat PDF, LyX, GNU-info, HTML, RTF(Rich Text Format), Plain-text, Unix man pages, single HTML file, SGML (Linuxdoc format), SGML (Docbook format), MS WinHelp format. 此份 howto 文件是在 - <itemize> <item> <url url="http://www.linuxdoc.org"> 按下 HOWTOs 連結, 並且在網頁瀏覽器上使用 CTRL+F 或 ALT+f 來搜尋 howto 文件名稱。 </itemize> 您也可從以下的映射站找到此份文件 - <itemize> <item> <url url="http://www.caldera.com/LDP/HOWTO"> <item> <url url="http://www.linux.ucla.edu/LDP"> <item> <url url="http://www.cc.gatech.edu/linux/LDP"> <item> <url url="http://www.redhat.com/mirrors/LDP"> <item> 其他較靠近您的映射站 (網址智慧辨識,network-address-wise) 可以在此找到 <url url="http://www.linuxdoc.org/mirrors.html"> 選擇一個映射站,並且進入目錄 /LDP/HOWTO/xxxxx-HOWTO.html </itemize> <itemize> <item> 您可以從下列連結得到 HTML、DVI、Postscript、或 SGML 格式的 HOWTO 文件單一 tar ball 檔案 - <url url="ftp://www.linuxdoc.org/pub/Linux/docs/HOWTO/other-formats/"> 與 <url url="http://www.linuxdoc.org/docs.html#howto"> <p> <item>純文字格式是在: <url url="ftp://www.linuxdoc.org/pub/Linux/docs/HOWTO"> 與 <url url="http://www.linuxdoc.org/docs.html#howto"> <p> <item>Single HTML 檔案格式是在: <url url="http://www.linuxdoc.org/docs.html#howto"> <p> Single HTML 檔案可以使用下列指令來建立 (參見 man sgml2html) - sgml2html -split 0 xxxxhowto.sgml <p> <item>其他語言之文件翻譯,像是法文、德文、西班牙文、 中文、日文等是在 <url url="ftp://www.linuxdoc.org/pub/Linux/docs/HOWTO"> 與 <url url="http://www.linuxdoc.org/docs.html#howto"> 歡迎您幫忙翻譯成其他語言的版本。 </itemize> 此份文件是以 "SGML-Tools" 工具軟體所撰寫的,您可以在下面的連結得到此軟體 - <url url="http://www.sgmltools.org"> 您可使用以下指令編譯原始檔,例如: <itemize> <item>sgml2html xxxxhowto.sgml (獲取 html 檔案) <item>sgml2html -split 0 xxxxhowto.sgml (獲取 single page html 檔案) <item>sgml2rtf xxxxhowto.sgml (獲取 RTF 檔案 ) <item>sgml2latex xxxxhowto.sgml (獲取 latex 檔案) </itemize> (譯注:中譯版使用者請至 ftp.linux.org.tw/pub/CLDP/src 下載 zh-sgmltools-1.x-x.tar.gz 並安裝之,再以 bg5sgml2html、bg5sgml2rtf、 bg5sgml2latex 或 gbsgml2html、gbsgml2rtf、gbsgml2latex 指令編譯原始檔。詳見 SGMLtools 中文套件使用說明 <url url="http://www.linux.org.tw/CLDP/zh-sgmltools.html">) <sect1> Acrobat PDF 格式 <label id="acrobatpdf"> <p> PDF 檔案可以從 postscript 檔案使用 acrobat <bf>distill</bf> 或 <bf>Ghostscript</bf> 來取得。 而 postscript 檔案是從 LaTex 檔案先轉成 DVI, 再轉成 postscript 而取得。 您可以從 <url url="http://www.adobe.com"> 下載 distill。 如以下範例所示: <code> bash$ man sgml2latex bash$ sgml2latex filename.sgml bash$ man dvips bash$ dvips -o filename.ps filename.dvi bash$ distill filename.ps bash$ man ghostscript bash$ man ps2pdf bash$ ps2pdf input.ps output.pdf bash$ acroread output.pdf & </code> 或者您可使用 Ghostscript 的指令 <bf>ps2pdf</bf>。 ps2pdf 是個與 Adobe's Acrobat Distiller 產品作用相似並擁有其大部分功能的指令: 它將 PostScript 檔案轉換成可攜式文件格式(Portable Document Format, PDF)檔案。 <bf>ps2pdf</bf>是被一個包含在 Ghostscript 的指令稿 (command script) (批次檔 batch file),且選擇一種名叫 <bf>pdfwrite</bf> 的特殊 "輸出裝置 (output device)" 來執行。為了要使用 ps2pdf, 當 Ghostscript 在安裝編譯時,pdfwrite 裝置必須要包含在 makefile 裡; 詳見安裝 Ghostscript 的文件。 <sect1> 將 Linuxdoc 轉換成 Docbook 格式 <label id="linuxdoc2docbook"> <p> 這份文件是以 linuxdoc SGML 格式所撰寫。Docbook SGML 格式 較 linuxdoc 格式更強大,且擁有更多特色。 linuxdoc 非常簡單且易用。我們使用 <bf>ld2db.sh</bf> 程式和一些 perl scripts 來將 linux SGML 檔案轉換成 Docbook SGML。 ld2db 的輸出結果並非 100% 完美,您需要使用 <bf>cleanup_ld2db.pl</bf> 這個 perl script。您可能必須手動更改文件中的數行。 <itemize> <item> 從 <url url="http://www.dcs.gla.ac.uk/~rrt/docbook.html"> 或從 <url name="Milkyway Galaxy site" url="http://www.milkywaygalaxy.freeservers.com"> 下載 ld2db 程式 <item> 從 <url name="Milkyway Galaxy site" url="http://www.milkywaygalaxy.freeservers.com"> 下載 cleanup_ld2db.pl 這個 perl script。 </itemize> ld2db.sh 並非 100% 完美,您在執行以下指令時將會得到許多錯誤 <code> bash$ ld2db.sh file-linuxdoc.sgml db.sgml bash$ cleanup.pl db.sgml > db_clean.sgml bash$ gvim db_clean.sgml bash$ docbook2html db.sgml </code> 而您可能必須在執行完 perl script 後, 手動編輯一些小錯誤的地方。例如: 您可能需要 < /Para>在每個 < Listitem> 寫入封閉標記 (closing tag) <sect1> 轉換成 MS WinHelp 格式 <label id="mswinhelp"> <p> 您可以將 SGML howto 文件轉換成 Microsoft Windows Help 檔案。 首先使用以下指令將 sgml 轉換成 html: <code> bash$ sgml2html xxxxhowto.sgml (獲取 html 檔案) bash$ sgml2html -split 0 xxxxhowto.sgml (獲取 single page html 檔案) </code> 然後使用 <url name="HtmlToHlp" url="http://javadocs.planetmirror.com/htmltohlpe.html">. 您也可使用 sgml2rtf,然後使用 RTF 檔案以獲取 winhelp 檔案。 <sect1> 讀取各種不同的格式 <label id="readformats"> <p> 要閱讀 dvi 格式的文件,必須使用 xdvi 程式。xdvi 程式在 Redhat Linux 是存在於 tetex-xdvi*.rpm (譯注:隨不同發行套件而有所差異;請洽詢您的發行套件廠商或組織)。 您可以從控制面板(ControlPanel) | 應用程式(Applications) | 出版(Publishing) | Tex 的選單按鈕開啟之。 要讀取 dvi 格式文件,請執行以下指令 - <tscreen><verb> xdvi -geometry 80x90 howto.dvi man xdvi </verb></tscreen> 並且使用滑鼠來重新設定視窗大小。 使用方向鍵、Page Up、Page Down 來導引, 您也可使用 'f', 'd', 'u', 'c', 'l', 'r', 'p', 'n' 字母鍵 來上移、下移、置中、至下一頁、回上一頁等。 要關閉專家選單,請按 'x'。 您可以使用 'gv' (ghostview) 或 'ghostscript' 來閱讀 postscript 格式的文件。 在 Redhat Linux 裡,ghostscript 存在於 ghostscript*.rpm 套件;gv 則存在於 gv*.rpm 套件裡。(譯注:隨不同發行套件而有所差異;請洽詢您的發行套件廠商或組織) 您可以從控制面版(ControlPanel) | 應用程式(Applications) | 美工繪圖(Graphics) 的選單按鈕開啟之。gv 遠比 ghostscript 更人性化。 ghostscript 和 gv 也有其他平台的版本,像是 OS/2、 Windows 95 和 NT,您甚至在那些平台也可以觀看此份文件。 <itemize> <item>您可從以下網址獲得 Windows 95、OS/2、 和所有作業系統平台的 ghostscript <url url="http://www.cs.wisc.edu/~ghost"> </itemize> 要閱讀 postscript 格式的文件,執行以下指令 - <tscreen><verb> gv howto.ps ghostscript howto.ps </verb></tscreen> 您可以使用 Netscape Navigator、Microsoft Internet explorer、 Redhat Baron Web browser 或任何其他的 10 種瀏覽器來閱讀 HTML 格式的文件 您可以使用 LyX -- 一種 latex 在 X-Windows 的前端界面,來閱讀 latex 格式的文件。 <sect> 版權 Copyright <p> 版權政策按照 LDP (Linux 文件計劃) 為 GNU/GPL。 LDP 是 GNU/GPL 計劃之一。 額外的請求為您在所有的複製文件中保留作者的姓名、電子郵件信箱位址、 和此份版權聲明。假如您對這份文件進行修改或增添, 那麼請您告知此份文件的所有作者。 在這份文件上所登載的姓名為其各自所有人的所有權 <p> 原文 (如中譯有誤,以原文為主) <p> Copyright policy is GNU/GPL as per LDP (Linux Documentation project). LDP is a GNU/GPL project. Additional requests are that you retain the author's name, email address and this copyright notice on all the copies. If you make any changes or additions to this document then you please intimate all the authors of this document. Brand names mentioned in this document are property of their respective owners. </article>