Linux, 工作, 生活, 家人

Gentoo, Linux

User mode linux 懶人包.

前一陣子想要 Try User Mode Linux,
不過萬事起頭難, 怎麼樣弄 console 就是不會出來, 最後努力查了一下資料
試了一下, 終於可以從 console 看到 Linux 啟動的畫面.
其實 User mode linux 不難, 只是… 要多設一點東西
這邊將個人的經驗, 統統包成一包了, 這樣可以方便大家進入 User Mode Linux

在玩 User mode linux 的前提是, 多多少少要會重編自己的 kernel.
首先先 check 有沒有載入 tun device.

#dmesg | grep tun

如果沒有, 試試看載入 modules

#modprobe tun
#dmesg | grep tun

再來是 check iptables 的 NAT modules , eth0 是對外連線的 Device

# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Check 一下有沒有錯誤訊息,
如果你 tun device 和 iptables MASQUERADE modules 都在,
那就可以直接下載懶人包了 uml-lazy.tar.bz2

下載完以後, 請切到 root 身份, 到 /home 下面解壓縮
# cd /home
# tar xf uml-lazy.tar.bz2

接下來, 進到 /home/uml 目錄, 依序執行以下的 shell script
# cd /home/uml
# sh host.sh
# sh run.sh
就可以看到 console , 然後 root 帳號沒有密碼.

/home/uml 目錄下檔案說明

  • host.sh : 在 Host 端要跑的 Shell Script
  • kmtest : 測試用的 kernel modules source code (直接用 kdevelop 做出來的)
  • linux-2.6.20.4 : Linux kernel 2.6.20.4 + uml patch
  • localfs : Root File System, 我是放在一包, 你也可以解出來用. 這是 Gentoo 的 Root File System, 可能和其他(Ubuntu), 並不會差很多.
  • rootfs : mount Root File System 的目錄
  • run.sh : 執行 User Mode Linux
  • uml2.patch : Linux kernel Patch File.

到 /home/uml/kmtest 內
就是一個可以 Compile 的 Kernel Module, 只要打 # make ; make install
就會將 module install 到 User Mode Linux 的目錄/lib/modules/2.6.20.4/kernel/drivers/misc 下.
在 User Mode Linux 內可以使用 insmod kmtest-driver 測試.

如果你並不需要 Root File System 及 Linux Kernel , 我也有準備一包只有 configure file 的壓縮檔, 內有需要的 Configure File 及 Shell Script
uml-config.tar.bz2
裡面有

  • demo-dot-config : Linux kernel Configure File.
  • host.sh
  • run.sh
  • uml2.patch

這樣應該就夠用了.

祝 UML 順利…. 🙂

Ref.

[Tags] User Mode Linux [/Tags]

2 留言

  1. JLS

    最後一個 Gentoo Linux Developer’s guide to system testing with User-Mode Linux 的連結有誤

    應該是 http://www.gentoo.org/doc/en/uml.xml 才對喔 :D:D:D

  2. 文章作者的留言

    richliu

    那是被 Auto-Link 這個 Modules 改的, Gentoo 會自動導到 http://www.gentoo.org 去, 這樣會蓋掉原來的 URL ,
    只要將 Gentoo 拿出來就 OK 了.

回覆留言對象 取消回覆