歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> Linux安裝 >> 詳解Linux的ISO鏡像安裝是如何開始進行的

詳解Linux的ISO鏡像安裝是如何開始進行的

日期:2017/4/19 13:59:53   编辑:Linux安裝

詳解Linux的ISO鏡像安裝是如何開始進行的

1. 首先光盤鏡像也就是iso文件采用的是“ISO 9660 ”文件系統 。

cd上的文件都存在這個簡單的iso文件系統裡,linux可以用mount -o loop 直接把*.iso文件mount到一個目錄查看。

2. CD ROM 另支持一個叫做“El Torito Bootable CD Specification” 的標准允許用戶在cd上指定啟動的引導程序。

電腦開機啟動時候,BIOS就會去檢查cd/dvd上是否有這個啟動標志,然後加載引導程序。

在Linux系統,使用mkisofs命令一個iso文件時,可以指定引導程序,例如

mkisofs -o <isoimage> \ -b isolinux/isolinux.bin -c isolinux/boot.cat \ -no-emul-boot -boot-load-size 4 -boot-info-table \ <root-of-iso-tree> 更多的iso文件相關選項可以參考mkisofs的help

3. Linux的光盤安裝的話,使用的一般是ISOLINUX 引導程序,也就是用這個ISOLINUX是被寫到上面那個EI Torito擴展裡面去的。 系統啟動時就自動加載ISOLINUX引導程序了。

ISOLINUX是 SYSLINUX項目的一系列引導程序中的一個,簡單的說就是類似GRUB的一個東西,就是啟動然後引導內核。ISOLINUX的特點如其名,區別於 GRUB LILO等的地方,就是他可以認出iso9660文件系統,所以可以讀出cd上的內核鏡像和inird 鏡像,然後引導。

ISOLINUX啟動後,默認會去讀出cd光盤根目錄的一個isolinux.cfg 文件,isolinux.cfg 類似grub的menu.lst,指定的內核鏡像位置等。這個isolinux.cfg的語法可以參考syslinux的文檔。 這裡有一個

比如 指定顯示終端可以使用這個選項

---------------------------------------------

SERIAL port [[baudrate] flowcontrol]

Enables a serial port to act as the console. "port" is a number (0 = /dev/ttyS0 = COM1, etc.) or an I/O port address (e.g. 0x3F8); if "baudrate" is omitted, the baud rate defaults to 9600 bps. The serial parameters are hardcoded to be 8 bits, no parity, 1 stop bit. "flowcontrol" is a combination of the following bits: 0x001 - Assert DTR 0x002 - Assert RTS 0x008 - Enable interrupts 0x010 - Wait for CTS assertion 0x020 - Wait for DSR assertion 0x040 - Wait for RI assertion 0x080 - Wait for DCD assertion 0x100 - Ignore input unless CTS asserted 0x200 - Ignore input unless DSR asserted 0x400 - Ignore input unless RI asserted 0x800 - Ignore input unless DCD asserted All other bits are reserved. Typical values are: 0 - No flow control (default) 0x303 - Null modem cable detect 0x013 - RTS/CTS flow control 0x813 - RTS/CTS flow control, modem input 0x023 - DTR/DSR flow control 0x083 - DTR/DCD flow control For the SERIAL directive to be guaranteed to work properly, it should be the first directive in the configuration file. NOTE: "port" values from 0 to 3 means the first four serial ports detected by the BIOS. They may or may not correspond to the legacy port values 0x3F8, 0x2F8, 0x3E8, 0x2E8. Enabling interrupts (setting the 0x008 bit) may give better responsiveness without setting the NOHALT option, but could potentially cause problems with buggy BIOSes. NOHALT flag_val If flag_val is 1, don't halt the processor while idle. Halting the processor while idle significantly reduces the power consumption, but can cause poor responsiveness to the serial console, especially when using scripts to drive the serial console, as opposed to human interaction. CONSOLE flag_val If flag_val is 0, disable output to the normal video console. If flag_val is 1, enable output to the video console (this is the default.) Some BIOSes try to forward this to the serial console and sometimes make a total mess thereof, so this option lets you disable the video console on these systems.

-----------------------------------------------------------------

SYSLINUX不知道是被封了還是怎麼樣,主頁打不開,這裡有個源碼目錄

可以在裡面找到些簡單的文檔和看看代碼什麼的,SYSLINUX包括了用於網絡引導PXELINUX等程序,可以自己去看一下。

4. isolinux引導加載Linux內核遵循一個叫做 “Multiboot Specification ” 的標准

這個Multiboot 定義了isoLinux如何去按照指定格式被內核文件加載到內存裡面來,還有可以指定模塊怎麼加載等。

isolinux先去加載自己的mboot.c32模塊 以支持multiboot模式,然後mboot32.c32在去根據配置加載內核和模塊。

比如一個 isolinux.cfg 是這樣的

LABEL Xen KERNEL mboot.c32 APPEND xen.gz dom0_mem=15000 nosmp noacpi --- linux.gz console=tty0 root=/dev/hda1 --- initrd.img

mboot的代碼

在get_modules 函數中就會解析各個模塊和參數,然後加載。APPEND 後面的字符串傳給mboot.c32 後, mboot.c32 以 “---” 作為分界線, xen.gz dom0_mem=15000 nosmp noacpi 就是把 “dom0_mem=15000 nosmp noacpi ” 傳給 xen.gz模塊作為參數。 “console=tty0 root=/dev/hda1 ”傳給 linux.gz 模塊作為參數。 linux.gz這些就是位於 cd 鏡像裡面的位置了,一般跟目錄下吧。

linux.gz這些加載運行後,自然可以根據multiboo格式,讀到 console=tty0 這些參數了。

至此系統引導成功,切換到linux環境,比如指定inird.img 文件系統的某個python程序,然後開始顯示界面,提示用戶安裝。

Copyright © Linux教程網 All Rights Reserved