在路由器上跑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
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值