1.拉取并安装镜像
docker pull arm32v7/alpine
docker run -it --name armv7alpine --net=host -v /tmp/my-rootfs:/my-rootfs arm32v7/alpine
docker run --rm --privileged multiarch/qemu-user-static --reset --persistent yes
2.镜像操作
docker restart armv7alpine
docker rm armv7alpine
docker exec -it armv7alpine /bin/sh
3.环境配置及应用安装
3.1安装基础服务
apk add openrc
rc-update add devfs boot
rc-update add procfs boot
rc-update add sysfs boot
apk add openntpd
3.2修改网络
nano /etc/network/interfaces
# /etc/network/interfaces.d/eth0
auto eth0
iface eth0 inet static
address 192.168.123.59
netmask 255.255.255.0
gateway 192.168.123.1
自动获取IP地址的网口配置
auto eth0
iface eth0 inet dhcp
3.3修改DNS
nano /etc/resolv.conf
添加解析服务器
nameserver 8.8.8.8
nameserver 8.8.4.4
重启网络服务
/etc/init.d/networking restart
rc-update add networking default
3.4安装SSH服务
apk add openssh
rc-update add sshd default
nano /etc/ssh/sshd_config
# Authentication:
#LoginGraceTime 2m
PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
#PubkeyAuthentication yes
# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication yes
3.5自动校时
nano /etc/ntp.conf #新建校时服务器配置文件
代码如下
erver ntp.aliyun.com iburst
server ntp0.aliyun.com iburst
server ntp1.aliyun.com iburst
server ntp2.aliyun.com iburst
将自动校时添加到自启脚本
ntpd -d -q
3.6时间自动同步
apk add chrony
mkdir -p /var/run/chrony
chmod 0755 /var/run/chrony
/etc/init.d/chronyd start
4.目录文件操作
rm -r /tmp/my-rootfs/*
rm -r /home/ding/luckfox-pico/output/out/rootfs_uclibc_rv1106/
rm -r /home/ding/luckfox-pico/sysdrv/custom_rootfs/*
rm -r /home/ding/luckfox-pico/output/image/*
- 打包rootfs
for d in bin etc lib root sbin usr; do tar c "$d" | tar x -C /my-rootfs; done
for dir in dev proc run sys var; do mkdir /my-rootfs/${dir}; done
cd /my-rootfs/ && tar czf alpine.tar.gz *
5.生成镜像
- 退出容器
exit
cp /tmp/my-rootfs/alpine.tar.gz /home/ding/luckfox-pico/sysdrv/custom_rootfs/
/home/ding/luckfox-pico/project//build.sh
6.其他
安装内核
apk add linux-lts
cp /lib/modules/6.6.28-0-lts/kernel/drivers/net/tun.ko my-rootfs
cp /tmp/my-rootfs/alpine.tar.gz /home/ding/luckfox-pico/sysdrv/custom_rootfs/
./build.sh lunch
./build.sh
镜像源
https://dl-cdn.alpinelinux.org/alpine/v3.17/main
https://dl-cdn.alpinelinux.org/alpine/v3.17/community
#/media/cdrom/apks
http://mirrors.sjtug.sjtu.edu.cn/alpine/v3.14/main
http://mirrors.sjtug.sjtu.edu.cn/alpine/v3.14/community
http://mirrors.sjtug.sjtu.edu.cn/alpine/edge/main
http://mirrors.sjtug.sjtu.edu.cn/alpine/edge/community
http://mirrors.sjtug.sjtu.edu.cn/alpine/edge/testing
相关命令
rc-status #查看运行中的系统服务
rc-status -a #查看所有系统服务
apk info -L frp-openrc #查看应用安装相关目录
rc-service -list #查看自启动服务列表
lsof /etc/init.d/Npc #查看启动中的服务进程
定时启动程序crontab
crontab -l #查看当前用户的定时任务
crontab -e #编辑当前用户的定时任务
crontab -r #删除当前用户的定时任务
crontab -l > mycronjob.txt #将定时任务输出到文件
crontab mycronjob.txt #从文件中导入定时任务
0 1 * * * /path/to/your/script.sh
0 1 * * * /path/to/your/script.sh #添加每天的凌晨 1 点运行一个脚本
安装校时应用
apk add tzdata
cp /usr/share/zoneinfo/Asia/Bangkok /etc/localtime
echo "Asia/Bangkok" > /etc/timezon
apk del tzdata