發表文章

目前顯示的是 8月, 2016的文章

PC Booting 簡介

基於 BIOS 的開機流程簡介 描述基於 linux 的開機流程步驟, 適用於有 BIOS 的機器 開機的時候會執行 BIOS, BIOS 先對硬體做檢測. 在根據設定所指定的開機 device 去讀取 MBR(Master Boot Record). MBR 處於 device 的第一個 sector, 裡面包含了基本的 boot loader 與 partition table 資訊. 礙於 MBR 大小的限制(512 bytes = 446(basic boot loader code, e.g. boot.img) + 64(partition table)), boot loader 的會再去其他 sector 讀取完整的 boot loader 程式(e.g. core.img). 程式依據 MBR 或 GPT 來判斷放 boot loader 的位置[3][4]. (1) 為MBR時候, 通常 boot loader 安裝於 MBR 與第一個 partition 之間. (2) 當為GPT, 則使用一個 Boot Partition 來存放 boot loader 當 boot loader 被執行後, 會去讀取 /boot/grub 裡面的設定來決定所要讀取的 OS 核心檔案 (kernel.img 和 initrd.img) initrd.img 裡面包含 kernel 所需的基本模組(mod), 當被掛載後 kernel 便可以去讀取外接裝置, 並視設定來決定是否有需要重掛載檔案系統 接著就執行第一支程式 e.g. initd or systemd 範例 範例1 [6] Stage 1 : boot.img is stored in the master boot record (MBR) or optionally in any of the volume boot records (VBRs), and addresses the next stage by an LBA48 address (thus, the 1024-cylinder limitation of GRUB legacy is avoided); at installation time it is