在路由器上跑Debian

首先,你需要知道什麼是Debootstrap
然後閱讀此文檔第一部分:EmDebianCrossDebootstrap
我們可以看到有多種方法可以實現我們的目的。我的路由器CPU是MT7621,是mipsel架構的
我使用的是第二部分的方法:QEMU/debootstrap approach
我使用的是Ubuntu。
按照上面的要求,安裝需要的包:

apt-get install binfmt-support qemu qemu-user-static debootstrap

然後隨便新建個目錄,例如:

mkdir mipsel_debian

然後運行bootstrap,注意arch要改過來,後面Jessie是你想要的版本,再後面mipsel_debian是剛剛新建的目錄,最後是鏡像地址

debootstrap --foreign --arch mipsel jessie mipsel_debian http://ftp.cn.debian.org/debian/

搞定之後接着按文檔教程走。有些地方改一下就行了。

cp /usr/bin/qemu-mipsel-static mipsel_debian/usr/bin
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C LANGUAGE=C LANG=C 
chroot mipsel_debian /debootstrap/debootstrap --second-stage
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C LANGUAGE=C LANG=C
chroot mipsel_debian dpkg --configure -a

然後就完成了。把整個目錄拷到u盤,u盤插到路由器上,ssh進路由器,chroot進去就能用了。
chroot前要做一些工作,參考Debootstrap

mount /dev mipsel_debian/dev
mount /sys mipsel_debian/sys
mount /proc mipsel_debian/proc
cp /proc/mounts mipsel_debian/etc/mtab

最後chroot進去:

chroot mipsel_debian /bin/bash

如果想用ssh,在chroot前可能還需要下面這一步:

mount /dev/pts mipsel_debian/dev/pts
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章