simplefs 學習紀錄與疑惑

測試環境

Ubuntu 19.10 -> ubuntu 18.04.4 LTS
kernel version: 5.3.0-29-generic -> 4.9.102

Build and Test 結果

$ ls mount/
$ cat mount/vanakkam

以上兩個指令需要 sudo 權限。

$ echo "Hello World" > mount/hello

以上指令失敗,權限不足。

$ cat mount/hello

推測無法創建 hello 這個 file,自然透過 cat 也無法印出任何東西。

執行 simple-test.sh

得到以下錯誤:

simple-test.sh: line 18: /sys/module/jbd2/parameters/jbd2_debug: No such file or directory

根據 https://cateee.net/lkddb/web-lkddb/JBD2_DEBUG.html 看起來應該是沒打開 CONFIG_JBD2_DEBUG,有待驗證。

透過 $ cat /boot/config-5.3.0-29-generic | grep CONFIG_JBD2_DEBUG 確認,確實沒打開。

如果要打開這個 config,只能夠重新編 linux kernel 了。

打開 CONFIG_JBD2_DEBUG

  1. 第一步必須重新編譯 linux kernel
  2. 根據 ubuntu-wiki來重新編譯 kernel
    $ apt-get source linux-image-$(uname -r)
    $ cd linux-signed-5.3.0/
    $ chmod a+x debian/rules
    
  1. 途中遇到問題
haogroot@haogroot-TP:~/linux-signed-5.3.0$ fakeroot debian/rules editconfigs
dh editconfigs
dh: Unknown sequence editconfigs (choose from: binary binary-arch binary-indep build build-arch build-indep clean install install-arch install-indep)
make: *** [debian/rules:37: editconfigs] Error 255

google 到看來有許多人照著這個 wiki 都碰到類似問題

  1. 根據這篇教學,升級 kernel 到 stable version 5.4.17,並打開 JBD2 (ext4) debugging support

更新完後開機,卡在紫色畫面 google 有看到一些討論,有可能是硬體 bios 的問題或是 intel microcode 的問題,再看到 ubuntu 目前官方最新支援到 5.3.0.29,先暫時放棄升級到 5.4.17,之後應該會選擇低於 5.3.0.29 的版本

  1. customize linux kernel

參考此篇,以原本的 kernel version 來重新編譯

root@haogroot-TP:/usr/src/linux# fakeroot make-kpkg --initrd --append-to-version=-custom kernel_image kernel_headers

編譯失敗,因為硬碟空間不足

  1. 決定直接虛擬機開下去就好
    參考這篇成功打開該 config。
    環境為:
    Ubuntu 18.04.4 LTS
    Kernel 4.9.102

再次 build and test

Intall linux headers 失敗,但我透過 $ sudo apt-get install linux-headers-generic 安裝,顯示安裝了 linux-headers-4.15.0-76-generic

執行 $ echo "Hello World" > mount/hello

權限不足

給予 /mount 權限後 (chmod 777 mount),再度執行$ echo "Hello World" > mount/hello,顯示以下錯誤。

bash: echo: write error: Read-only file system

可以成功建立檔案,但無法寫入。

$ ls -lR

執行 simple-test.sh

  • 要有 root 權限

觀察 simple-test.sh

set -x     // 執行指令後會顯示所有指令

[ -d "$test_mount_point" ] // test_mount_point 是不是 directory
dd bs=4096 count=100 if=/dev/zero of="$1" ./mkfs-simplefs "$1"
  • /dev/zero: when you read this special file, it will provies you null character
  • Create a 409600 Bytes file, called $1. The first 100 bytes contains null character.

loop device

loop device is a pseudo-device that makes a file accessible as a block device.

Select a repo