设为首页 加入收藏

TOP

Hi3798MV200 恩兔N2 NS-1 (四): 制作 Debian rootfs(一)
2023-08-26 21:10:25 】 浏览:97
Tags:Hi3798MV200 恩兔 NS-1 制作 Debian rootfs

目录

关于 Debian rootfs

Debian 没有像 Ubuntu 提供 Ubuntu-Base 那样提供打包好的 rootfs, 但是 Debian 提供了一个制作 rootfs 的工具 debootstrap. 以下介绍使用 debootstrap 制作 Debian rootfs 的过程.

debootstrap 初始化一阶段

安装 debootstrap

sudo apt install debootstrap

准备一个工作目录, 例如 workroot, 初始化. 注意一定要加 mirror, 否则会非常慢

sudo debootstrap --arch=arm64 --foreign buster workroot/ http://mirrors.ustc.edu.cn/debian/

复制 qemu-aarch64-static 到目标系统, 如果没有的话要先安装一下sudo apt install qemu-user-static

sudo cp /usr/bin/qemu-aarch64-static workroot/usr/bin/

检查一下是否能正常执行

sudo chroot workroot/ /usr/bin/qemu-aarch64-static /bin/ls

准备 resolv.conf

echo "nameserver 127.0.0.53" | sudo tee workroot/etc/resolv.conf

debootstrap 初始化二阶段

chroot 到目标系统下

sudo chroot workroot/

第二阶段的初始化

/debootstrap/debootstrap --second-stage http://mirrors.ustc.edu.cn/debian/ 

初始化成功的话, 能看到I: Base system installed successfully

安装设置

安装基础软件

添加 Debian apt source

cat <<EOT > /etc/apt/sources.list
# 依次输入以下内容
deb http://mirrors.ustc.edu.cn/debian buster main contrib non-free
deb-src http://mirrors.ustc.edu.cn/debian buster main contrib non-free
deb http://mirrors.ustc.edu.cn/debian-security/ buster/updates main contrib non-free
deb-src http://mirrors.ustc.edu.cn/debian-security/ buster/updates main contrib non-free
deb http://mirrors.ustc.edu.cn/debian buster-updates main contrib non-free
deb-src http://mirrors.ustc.edu.cn/debian buster-updates main contrib non-free
EOT

检查是否正确

cat /etc/apt/sources.list

最后执行 apt update 更新, apt upgrade 升级

安装一些基础软件, 这一步之后系统大小为 434M

apt install locales dialog

配置 locales, 选择 en_US.UTF-8 UTF-8, en_US.UTF-8

dpkg-reconfigure locales

继续安装一些软件

apt install vim-tiny openssh-server sudo ifupdown net-tools udev iputils-ping sysstat smartmontools

添加驱动文件

仅使用kernel自带的驱动可以启动rootfs, 但是一些板载的外设, 例如SATA硬盘和USB, 会因为没有驱动而无法识别. 需要手动将这些驱动放到rootfs中.

通过uname -r可以看到目标系统的架构为4.4.35-hi3798mv2x, 由此可以确定驱动的路径为

/lib/modules/4.4.35-hi3798mv2x/

将系统中这部分文件提取后放到rootfs的对应目录下, 结构类似于

modules
└── 4.4.35-hi3798mv2x
    ├── kernel
    │   ├── crypto
    │   ├── drivers
    │   ├── fs
    │   ├── lib
    │   └── net
    ├── modules.alias
    ├── modules.alias.bin
    ├── modules.builtin
    ├── modules.builtin.alias.bin
    ├── modules.builtin.bin
    ├── modules.dep
    ├── modules.dep.bin
    ├── modules.devname
    ├── modules.order
    ├── modules.softdep
    ├── modules.symbols
    └── modules.symbols.bin

基础设置

设置主机名

echo n2ns1 > /etc/hostname

设置网络

cat << EOT > /etc/network/interfaces.d/10-eth0
# 依次输入
auto eth0
iface eth0 inet dhcp
EOT

设置 vim

nano /etc/vim/vimrc.tiny

# 修改compatible为nocompatible
set nocompatible
# 增加这行修复backspace键
set backspace=2

重要 给 root 用户设置密码, 否则刷完没法登录

passwd

开启 root 用户 ssh 访问, 编辑 /etc/ssh/sshd_config, 找到

#PermitRootLogin prohibit-password

替换为

PermitRootLogin yes

配置登录的串口, 修改文件 /etc/systemd/system/getty.target.wants/getty@tty1.service

vi /etc/systemd/system/getty.target.wants/getty\@tty1.service

ConditionPathExists=/dev/tty0

修改为实际的名称

ConditionPathExists=/dev/ttyAMA0

添加欢迎界面, 新建 /etc/update-motd.d/60-welcome, 内容如下, 属性设为可执行

#!/bin/sh
#
IP=$(ifconfig eth0 | grep '\<inet\>'|
首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Hi3798MV200 恩兔N2 NS-1 (二): H.. 下一篇机器人编程教程2探索机器人-代码..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目