# AOS assignment1 ## Hardware and software specification | Category | Hardware Specification | |---|---| | - CPU | Intel® Core™ i7-13650HX | | - RAM channel A | Samsung DDR5 4800 SODIMM 16GBx1 | - RAM channel B |Micron DDR5 4800 SODIMM 32GBx1 | - Storage | WD SN560 1TB | | - Network | Intel® WiFi 6 AX201 160Mhz | | Category | Virtual Machine | |---|---| |- Type | VirtualBox with Ubuntu 20.04.1| |- CPU Cores | 2 CPU cores allocated| |- RAM | 4GB RAM allocated| |- Storage |40GB Size of the virtual disk| | Category | Linux Kernel Environment | |---|---| | - Version |Linux 5.15.0-121 generic | | - Distribution | Ubuntu | | Category | Compiled Linux Kernel Target | |---|---| | - Version |Linux 6.10.9 | | - Distribution | Ubuntu | | Category | Used Packages | |---|---| | - Key Packages | build-essential, flex, bison, libncurses-dev, libelf-dev, elfutils, libssl-dev, bc| ## Steps of compile 6.10.9 kernel source code and run | Steps | Operation | |---|---| | 1 | Install VirtualBox下載一下ubuntu的系統,我用的是`ubuntu 20.04.1 LTS`| | 2 | 用`wget+網址`來下載想要的Linux kernel source code,我這邊要編譯的kernel是下載stable `6.10.9` tarball的版本 !| | 3 | 用ls來確定檔案是否已經下載到現在的路徑裡面了 | | 4 | 用`tar -xf linux-6.10.9.tar.xz`來解壓縮 這邊可以看到解壓完後檔案分布!| | 5 | 現在進入了解壓縮的source code的檔案目錄了,開始安裝tool `sudo apt install build-essential flex bison libncurses-dev bc libelf-dev elfutils libssl-dev`| | 6 | 為了可以執行`make menuconfig` 來配置內核 第五步驟packages是需要安裝的或是沒什麼需要設定就直接用 `make defconfig`| | 7 | then `sudo apt install gedit && sudo make -j$(nproc) >/dev/null && sudo make modules_install`,然後去以下位置看有沒有bzImage | | 8 | 先`make install` 後 `sudo apt install grub2 && sudo gedit /etc/default/grub`| | 9 |把style, timeout數值改成menu, -1且儲存 <div style="page-break-after: always;"></div> | Steps | Operation | |---|---| | 10 | 並且更新grub `sudo update-grub2` 重開reboot -n後就看到結果啦,這邊因為我編譯了兩次所以有兩個一樣的版本  | > **_NOTE:_** 會因為版本問題產生很多bug,例如ubuntu 20,24版本用VMWare會進入initramfs,我是換個VirtualBox解決 ## 遇到的困難 為了可以使用`make menuconfig`用選項式菜單來配置kernel,我們需要先下載很如下的packages,若config配置完還是一堆bug,最後先用menuconfig生成.config檔之後,改用`make defconfig`,然後VMware Workstation問題會使我一直找不到efi啟動,會卡在initramfs的畫面,網路上找不太到這部分的解決方式,所以我就直接換VirtualBox重新上述步驟就可以開機了。 ### build-essential ``` `build-essential`套件通常包含了 GCC、make、binutils 等基本編譯工具來提供編譯環境 ``` ### libncurses-dev ``` 讓 menuconfig 能夠在終端中呈現一個彩色的、互動式的選單界面,方便使用者進行配置。 使用者互動: ncurses 提供了處理鍵盤輸入、移動游標、繪製視窗等功能, 後來發現還需要`flex`,`bison`等等的tool,才可以執行config的動作 ``` ### flex ```產生詞法分析器: flex 用於生成詞法分析器的工具。 在 menuconfig 中,它用於詞彙分析 生成的詞法分析器可以將配置檔案中的關鍵字、值等詞彙 提取出來,以便解析器進行進一步的處理。 ``` ### bison ``` 產生解析器: bison 是一個用於生成解析器的工具。 在 menuconfig 中用於生成一個解析器,用來解析内核配置檔案的語法。 解析配置選項根據指定的語法規則,正確地解析使用者所做的配置選擇。 ``` <div style="page-break-after: always;"></div> ## Reference [The Linux Kernel Archives](https://www.kernel.org/) [How to compile Linux kernel code on Windows? - Stack Overflow](https://stackoverflow.com/questions/19572548/how-to-compile-linux-kernel-code-on-windows) [在解壓縮linux kernel archive檔案會用到的指令](https://note.drx.tw/2008/04/command.html) [Linux kernel development book 3rd edition chapter 2]
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up