由於目前 Utilite 只有提供 Ubuntu 的 image (而且似乎是 armel 的版本), 所以打算自己動手裝上習慣的 Debian 版本. 不過... 由於目前 Debian Wheezy 並沒有提供 Utilite 的 installer, 所以就只能自己打造了.
首先, 你要有一台 Debian 的開發主機 (用 Ubuntu 也可以, 不過... 都要把 Utilite 由 Ubuntu 改裝成 Debian 了, 會在自己的原本環境是用 Ubuntu 嗎?).
- 開發主機
加入 emdebian
echo deb http://www.emdebian.org/debian/ wheezy main >> /etc/apt/sources.list.d/emdebian.list
apt-get install emdebian-archive-keyring
apt-get update
安裝所需要的工具
apt-get install libc6-armel-cross libc6-dev-armel-cross
apt-get install binutils-arm-linux-gnueabi
apt-get install gcc-4.7-arm-linux-gnueabi
apt-get install g++-4.7-arm-linux-gnueabi
apt-get install uboot-mkimage
apt-get install libncurses5-dev
apt-get install git bc curl
apt-get install debootstrap dpkg-dev
安裝 QEMU
apt-get install qemu binfmt-support qemu-user-static dpkg-cross
基本上, 開發主機上頭有上面的東西就可以了.
- 製作 rootfs
使用 debootstrap 產生基礎的環境
mkdir -p /usr/src/armhf-root
cd /usr/src/armhf-root
debootstrap --foreign --arch armhf wheezy .
複製 qemu-arm-static 的該環境中 (因為一般的開發主機應該不會是 armhf 的機器, 要這樣才可以正常的 chroot)
cp /usr/bin/qemu-arm-static usr/bin
debootstrap 的第二階段
LC_ALL=C LANGUAGE=C LANG=C chroot . /debootstrap/debootstrap --second-stage
LC_ALL=C LANGUAGE=C LANG=C chroot . dpkg --configure -a
原則上, 到這邊結束, 就應該有一個可以 chroot 的 armhf 環境了.
- 設定 Utilite 使用的 rootfs
mkdir -p lib/modules
mkdir -p lib/firmware
cp -a /ubuntu_rootfs/lib/modules/3.0.35-cm-fx6-4 lib/modules/
cp -a /ubuntu_rootfs/lib/firmware/* lib/firmware/
cp -a /ubuntu_rootfs/etc/modules etc/
cp -a /ubuntu_rootfs/etc/udev/rules.d/* etc/udev/rules.d/
更改 root 密碼
chroot . passwd
設定 hostname
echo utilite > etc/hostname
設定 DNS 解析
cat <<END > etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4
END
將網卡設定為 DHCP (要設成固定 IP 請自己改)
cat <<END >> etc/network/interfaces
# eth0
auto eth0
allow-hotplug eth0
iface eth0 inet dhcp
# eth1
auto eth1
allow-hotplug eth1
iface eth1 inet dhcp
END
設定 apt 要用的 source
cat <<END > etc/apt/sources.list
deb http://ftp.debian.org.tw/debian wheezy main
deb-src http://ftp.debian.org.tw/debian wheezy main
deb http://security.debian.org/ wheezy/updates main
deb-src http://security.debian.org/ wheezy/updates main
END
console 設定 (Utilite 是用 ttymxc3 當成 serial console)
echo T0:23:respawn:/sbin/getty -L ttymxc3 115200 vt100 >> etc/inittab
設定 locale
chroot . apt-get update
LC_ALL=C LANGUAGE=C LANG=C chroot . apt-get install dialog locales dpkg-dev
LC_ALL=C LANGUAGE=C LANG=C chroot . dpkg-reconfigure locales
設定 timezone
LC_ALL=C LANGUAGE=C LANG=C chroot . dpkg-reconfigure tzdata
安裝其他你需要的軟體 (如 sshd, 當然你也可以不裝, 等把 rootfs 放上去時, 使用 serial console 連上去裝)
LC_ALL=C LANGUAGE=C LANG=C chroot . apt-get install openssh-server dosfstools ntp ntpdate
更新並清除 cache
LC_ALL=C LANGUAGE=C LANG=C chroot . apt-get upgrade
chroot . apt-get clean
如果需要其他的設定, 可以這時候 chroot 進去處理, 當然, 基本的 rootfs 算是完成, 也可以裝上後再連到機器上去使用.
如果不需要再 chroot 了, 就可以把 qeum-arm-static 移除
rm usr/bin/qemu-arm-static
打包..
tar zcvf ../debian_wheezy_armhf_rootfs.tar.gz ./
接著依據官方 Ubuntu 的安裝方式, 把上面的 rootfs 放到 SSD 上 (/dev/sda2), 或放在 MicroSD (/dev/mmcblk0p2) 上頭. 記得不要動到 /boot (/dev/sda1 或 /dev/mmcblk0p1) 的部份 (那是個 vfat 的 partition, 放上所需要的 uImage 給 u-boot 來啟動).