openPLC armhf架构 Ubuntu根文件系统制作过程记录

发布于:2024-03-28 ⋅ 阅读:(14) ⋅ 点赞:(0)

1. ubuntu 根文件系统下载
http://cdimage.ubuntu.com/ubuntu-base/releases/16.04/release/
1.1 解压 
        >> sudo tar -xzf ubuntu-base-22.04-base-armhf.tar.gz -C ubuntu_rootfs/

1.2 安装qemu模拟器
        >> sudo apt-get install qemu-user-static
        >> sudo cp /usr/bin/qemu-arm-static ubuntu_rootfs/usr/bin/   

1.3 DNS 配置文件/etc/resolv.conf 
        >> sudo cp /etc/resolv.conf ./etc/resolv.conf

1.4 制作文件系统挂载脚本ch-mount.sh

#!/bin/bash
 
function mnt() {
    echo "MOUNTING"
    sudo mount -t proc /proc ${2}/proc
    sudo mount -t sysfs /sys ${2}/sys
    sudo mount -o bind /dev ${2}/dev
 
    sudo chroot ${2}
}
 
function umnt() {
    echo "UNMOUNTING"
    sudo umount ${2}/proc
    sudo umount ${2}/sys
    sudo umount ${2}/dev
 
}
 
 
if [ "$1" == "-m" ] && [ -n "$2" ] ;
then
    mnt $1 $2
elif [ "$1" == "-u" ] && [ -n "$2" ];
then
    umnt $1 $2
else
    echo ""
    echo "Either 1'st, 2'nd or both parameters were missing"
    echo ""
    echo "1'st parameter can be one of these: -m(mount) OR -u(umount)"
    echo "2'nd parameter is the full path of rootfs directory(with trailing '/')"
    echo ""
    echo "For example: ch-mount -m /media/sdcard/"
    echo ""
    echo 1st parameter : ${1}
    echo 2nd parameter : ${2}
fi

1.5 挂载文件系统
         >> sudo ./ch-mount.sh   -m    ubuntu-rootfs/

1.6 跟换源 清华 port 源
    具体查看>>https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu-ports/
    使用时把https 改成 http

1.7 下载所需软件包
apt update
apt upgrade
apt install sudo
apt install vim
apt install net-tools
apt install ethtool
apt install ifupdown
apt install wireless-tools
apt install rsyslog
apt install htop
apt install iputils-ping
apt install udhcpc
apt install ssh

1.8 添加用户
    >> adduser wy
    >> 输入密码
    修改密码
    >> passwd wy

1.9 设置本机名称和IP地址
设置主机名称:
        >> echo "mp157" > /etc/hostname
设置本机入口ip:
        >> echo "127.0.0.1 localhost" >> /etc/hosts
        >> echo "127.0.0.1 mp157" >> /etc/host

2.0 退出
    >> exit
    >> sudo ./ch-mount.sh   -u   ubuntu-rootfs/

1.制作根文件系统
        >> dd if=/dev/zero of=ubuntu-rootfs.ext4 bs=1M count=3072
        >> sudo mkfs.ext4 -F ubuntu-rootfs.ext4
        >> sudo mount ubuntu-rootfs.ext4 ubuntu-mount/
        >> sudo cp ubuntu-rootfs/* ubuntu-mount/ -drfp
        >> sudo umount ubuntu-mount

2.配置串口,解决登录输入无效问题
        >> ln –s /lib/systemd/system/serial-getty@.service 
             /etc/systemd/system/getty.target.wants/serial-getty@ttySTM0.service
...@ttySTM0 是打印串口名

3.配置网口自动dhcp并开启eth0问题。
>> sudo apt install ifupdown
>> sudo vim /etc/network/interfaces
添加 
    auto eth0
    iface eth0 inet dhcp
>>  sudo systemctl restart networking


4.清华 armhf 架构软件源地址 
https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu-ports/
使用时把https 改成 http

5.U盘挂载修复问题
sudo mount  /dev/sda1 /media
sudo umount /media/
修复
fsck -C -a /dev/sdb1

本文含有隐藏内容,请 开通VIP 后查看