--- hackpadID: v388MYVKAIn hackpadWorkspace: tossug tags: hackpad-import, tossug --- # Linux Container (lxc) 與 QEMU 搭配使用 ## 在 Ubuntu 14.04 上面的安裝步驟 1. 安裝 lxc 以及 qemu-user-static * sudo apt-get install lxc qemu-user-static:i386 debian-archive-keyring debian-ports-archive-keyring 1. 修改 /usr/share/lxc/templates/lxc-debian (workaround) 1. 將 36 行附近的變數改成 MIRROR=${MIRROR:-[](http://download.si-linux.co.jp/debian-sh/wheezy-sh4/)[http://download.si-linux.co.jp/debian-sh/wheezy-sh4/](http://download.si-linux.co.jp/debian-sh/wheezy-sh4/)} 2. 將 190 行附近的 `debootstrap --verbose` 改成 `qemu-debootstrap --verbose --no-check-gpg` 3. 將 163 行附近的 download_debian() 裡面的 packages 變數中的 dialog 那行移除掉 # 因為目前 si-linux 沒有提供 dialog 這個套件 2. 產生 Linux Container * sudo lxc-create -t debian -n wheezy -- -a sh4 -r wheezy -c 2>&1 | tee sh4-debug.log 1. 啟動 Linux Container * sudo lxc-start -n wheezy 1. 修改 /etc/apt/sources.list * deb [](http://download.si-linux.co.jp/debian-sh/wheezy-sh4/)[http://download.si-linux.co.jp/debian-sh/wheezy-sh4/](http://download.si-linux.co.jp/debian-sh/wheezy-sh4/) wheezy main contrib non-free * deb-src [](http://free.nchc.org.tw/debian/)[http://free.nchc.org.tw/debian/](http://free.nchc.org.tw/debian/) wheezy main contrib non-free * deb [](http://people.linux.org.tw/~fourdollars/debian/)[http://people.linux.org.tw/~fourdollars/debian/](http://people.linux.org.tw/~fourdollars/debian/) wheezy main contrib non-free * deb-src [](http://people.linux.org.tw/~fourdollars/debian/)[http://people.linux.org.tw/~fourdollars/debian/](http://people.linux.org.tw/~fourdollars/debian/) wheezy main contrib non-free 1. 設定 Linux Container 的網路 * ifconfig eth0 10.0.3.2 # 指定 Static IP * route add default gw 10.0.3.1 # 設定 Gateway * echo "nameserver 8.8.8.8" > /etc/resolv.conf # 設定 DNS 1. 更新 apt index * apt-get update 1. 關掉 gpg signature checks * echo ’APT::Get::AllowUnauthenticated "true";’ > /etc/apt/apt.conf # 因為 si-linux 沒有 sign deb 所以乾脆關掉 1. 接下來就是跟使用一般的 Debian 系統一樣了。 Have fun. :D ## 建立 Debian package repository 的方法 建立 Debian package repository 的工具很多,請參考 [](https://wiki.debian.org/HowToSetupADebianRepository)https://wiki.debian.org/HowToSetupADebianRepository,以下將說明 reprepro 的使用方式。 1. 首先產生一個設定檔 conf/distributions * Origin: Debian * Label: Debian * Suite: stable * Codename: wheezy * Version: 6.0 * Architectures: source sh4 * Components: main non-free contrib * Description: Debian Archive for wheezy/sh4 1. 然後就可以將 Debian binary package 給拉進來 * reprepro -Vb . includedeb wheezy hello.deb 1. 當然也可以將 Debian source package 給拉進來 * reprepro -Vb . includedsc wheezy hello.dsc 1. 接下來就可以將 repo 放到網路上面給別人使用了 * rsync -Cavz pool your_public_web_site/debian * rsync -Cavz dists your_public_web_site/debian