N1 安装 armbian 简单教程

发布时间 2023-06-14 10:18:50作者: zwyyy456

制作镜像

选择Armbian_23.02.0_amlogic_s905d_bullseye_6.0.11_server_2022.12.08.img.gz,下载好之后,解压,利用rufus刷入u盘。

安装

由于盒子在刷入armbian前为安卓系统,已开启adb,mac的终端执行adb connect 192.168.123.193连接无线adb192.168.123.193修改成N1的实际的ip地址,然后执行adb reboot update(这些过程最好都在N1外接显示器的环境下进行),在显示器黑屏的瞬间将前一步的u盘插入到靠近hdmi的usb接口;

接下来显示器会跑一系列starting xxx的服务,直到最后让login的时候,应该是要先输入用户名root,再输入1234(默认密码),然后输入两次重复的自定义密码(如x12x12);

然后会让你创建用户,可以按Ctrl+C跳过;

当显示已经启动完成,让你再登录之后,输入用户名root和前一步的自定义密码x12x12,即可进入命令行,然后执行nand–sata-install命令将系统刷写进N1的emmc中。

安装好后的配置

网络配置

由于本人在实验室,无法进入路由器后台查看,这里只能考虑设定静态ip,然而设置好了静态ip之后,无法联网,只能先使用dhcp,如果是家中,可直接进入路由器后台管理界面绑定和mac和ip;

刷好了armbian的N1在每次重启之后,mac会发生变化,因此首先执行ip addr,然后执行ifconfig | grep ether,其中一个是wan口的mac,另一个是lan口的mac,记下lan口的mac,我这里是9e:61:65:69:d7:aa;

执行adduser zwyyyadduser zwyyy sudo创建用户并执行usermod -aG sudo username添加到sudo用户组,之后的命令都在zwyyy用户下执行;

执行sudo cp /etc/network/interfaces bak/network_interfaces.bak备份文件,将文件内容修改为

source /etc/network/interfaces.d/*

# Network is managed by Network manager
# You can choose one of the following two IP setting methods:
# Use # to disable another setting method


# 01. Enable dynamic DHCP to assign IP
#auto eth0
#iface eth0 inet dhcp
hwaddress ether 9E:61:A6:2B:7C:AA


# 02. Enable static IP settings(IP is modified according to the actual)
auto eth0
allow-hotplug eth0
iface eth0 inet static
address 192.168.6.103
netmask 255.255.255.0
gateway 192.168.6.1
dns-nameservers 192.168.6.1


# 03. Docker install OpenWrt and communicate with each other
#allow-hotplug eth0
#no-auto-down eth0
#auto eth0
#iface eth0 inet manual
#
#auto macvlan
#iface macvlan inet dhcp
#        hwaddress ether 9E:61:A6:2B:7C:AA
#        pre-up ip link add macvlan link eth0 type macvlan mode bridge
#        post-down ip link del macvlan link eth0 type macvlan mode bridge
#
#auto lo
#iface lo inet loopback

固定ip和mac地址

本机mac: 9e:61:81:68:8f:aa,每次重启之后mac会发生变化,因此考虑固定住mac地址;

更换清华源

首先执行sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak进行备份,然后执行echo > /etc/apt/sources.list清空sources.list文件,然后执行sudo vi /etc/apt/sources.list,按下i进入INSERT模式,复制以下内容到sources.list中,然后执行:wq保存并退出;

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free

deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free

然后执行sudo touch /etc/apt/sources.list.d/armbian.list,再用vim编辑该文件,添加

deb https://mirrors.tuna.tsinghua.edu.cn/armbian bullseye main bullseye-utils bullseye-desktop

最后执行sudo apt update

docker

安装docker

参照tuna docker镜像源使用帮助 首先安装依赖:

sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common

创建/etc/apt/keyrings文件夹,然后信任DockerGPG公钥:

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

添加软件仓库:

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/debian \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

执行安装:

sudo apt update
sudo apt install docker-ce

建立docker用户组:

sudo groupadd docker
sudo usermod -aG docker $USER

设置docker hub中科大镜像源

sudo vim /etc/docker/daemon.json

文件中加入:

{
  "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn/"]
}

安装portainer

docker volume create portainer_data
docker run -d -p 9000:9000 --name portainer -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/portainer_data portainer/portainer:linux-arm64

容器配置

docker中配置openwrt作旁路由,由于实验室有线和Wi-Fi不在一个ip段,暂时放弃

armbian配置kvm虚拟openwrt

docker里的passwall似乎要注释掉iptables -t nat -I POSTROUTING -j MASQUERADE 要修改dns,不能是默认,阿里云是否可以?

kvm安装openwrt

armbian安装依赖包

参照unifreq大佬的教程在 KVM 虚拟机中安装使用 OpenWrt 的说明,首先安装KVM依赖包,虽然unifreq提供的是基于ubuntu jammy的依赖列表,尽管我是基于debian的,但还是都装上这些依赖吧:

sudo apt-get install -y gconf2 qemu-system-arm qemu-utils qemu-efi ipxe-qemu libvirt-daemon-system libvirt-clients bridge-utils virtinst virt-manager seabios vgabios gir1.2-spiceclientgtk-3.0 xauth at-spi2-core

确定armbian上ssh服务端开启了X11Forwarding功能:

# vi /etc/ssh/sshd_config 文件
X11Forwarding yes
# 如果之前未开启,保存配置文件后重启sshd
sudo systemctl restart sshd

这里armbian已经默认开启

将用户添加到libvirt

# root 用户下
groupadd libvirt
usermod -aG libvirt zwyyy

安装服务端和客户端

windows安装VcXsrv、putty,启动Xlaunch和putty,putty启动时,勾选ssh-x11-enable x11 forwarding,ssh连接到加入了libvirt用户组的用户:

# -X 选项开启X11 Forwarding
ssh -X zwyyy@host
# 运行远程GUI程序,界面将在windows电脑上显示出来
virt-manager

armbian配置桥接网络

参照debian10使用kvm虚拟机并配置桥接网络,另外可以参照debian-kvm-wiki

brctl命令创建桥接接口并管理桥接接口:

sudo brctl addbr br0 # 创建一个名为br0的桥接接口
sudo brctl show # 列出系统上所有桥接接口

将armbian的网卡接口加入到刚刚创建的br0桥接接口中:

sudo brctl addif br0 eth0

删除物理网卡接口的ip地址,把物理网卡接口的ip地址配置到桥接接口上,并开启桥接接口,然后添加默认网关:

sudo ip addr del dev eth0 10.80.17.82/24
sudo ip addr add 10.80.17.82/24 dev br0
sudo ip link set up br0
sudo route add default gw 10.80.17.1

如果要恢复原来的状态,只需要将桥接接口关闭,然后从桥接接口中删除物理网卡接口即可:

sudo ip link set br0 down
sudo brctl delif br0 eth0
sudo ip link set eth0 down
sudo ip link set up eth0 #重启物理网卡

安装过程截图

上传qemu固件镜像op.qcow2(下载自unifreq的tg频道,解压后改名为op.qcow2):

scp Downloads/openwrt/op.qcow2  zwyyy@10.80.17.82:/home/zwyyy/op_kvm

安装过程截图参照unifreq

安装好之后,列出虚拟机列表

sudo virsh list --all # 或者root用户执行,否则只有空