1,制作ubuntu 20.04.5纯净版的rootfs
全ubuntu 20.04.5官网制作的纯净版,只带vi、网络、openssh等软件,也可以自己在增加。
https://cdimage.ubuntu.com/ubuntu-base/releases/20.04/release/ubuntu-base-20.04.5-base-armhf.tar.gz
下载官方包
$mkdir ubuntu
$sudo tar -xpf ubuntu-base-20.04.5-base-armhf.tar.gz -C ubuntu/
$sudo apt-get install qemu-user-static
$sudo cp /etc/resolv.conf ubuntu/etc/resolv.conf
$sudo cp /usr/bin/qemu-arm-static ubuntu/usr/bin/
修改ubuntu/etc/apt/sources.list内容如下:
deb http://repo.huaweicloud.com/ubuntu-ports/ focal main restricted
deb http://repo.huaweicloud.com/ubuntu-ports/ focal-updates main restricted
deb http://repo.huaweicloud.com/ubuntu-ports/ focal universe
deb http://repo.huaweicloud.com/ubuntu-ports/ focal-updates universe
deb http://repo.huaweicloud.com/ubuntu-ports/ focal multiverse
deb http://repo.huaweicloud.com/ubuntu-ports/ focal-updates multiverse
deb http://repo.huaweicloud.com/ubuntu-ports/ focal-backports main restricted universe multiverse
deb http://repo.huaweicloud.com/ubuntu-ports/ focal-security main restricted
deb http://repo.huaweicloud.com/ubuntu-ports/ focal-security universe
deb http://repo.huaweicloud.com/ubuntu-ports/ focal-security multiverse
$sudo mount -o bind /proc ubuntu/proc
$sudo mount -o bind /dev ubuntu/dev
$sudo chroot ubuntu
~# apt update
~# apt install rsyslog systemd
~# apt install sudo htop vim bash-completion
~# apt install ssh net-tools ethtool ifupdown iputils-ping network-manager
~# touch /etc/network/interfaces.d/eth0
如果dhcp,eth0内容如下:
auto eth0
iface eth0 inet dhcp
pre-up ifconfig eth0 hw ether 10:10:10:10:10:10
如果固定ip,eth0内容如下:
auto eth0
iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 223.5.5.5
dns-nameservers 223.6.6.6
pre-up ifconfig eth0 hw ether 10:10:10:10:10:20
ip地址根据自己情况修改。
~#echo "hi3798mv100" > /etc/hostname
~#echo "127.0.0.1 localhost" >> /etc/hosts
~#echo "127.0.0.1 hi3798mv100" >> /etc/hosts
~#ln -s /lib/systemd/system/rc-local.service /etc/systemd/system/rc-local.service
~#echo [Install] >> /etc/systemd/system/rc-local.service
~#echo WantedBy=multi-user.target >> /etc/systemd/system/rc-local.service
~#echo Alias=rc-local.service >> /etc/systemd/system/rc-local.service
~#systemctl enable rc-local.service
~#systemctl stop motd-news.timer
~#systemctl mask motd-news.timer
~#systemctl stop motd-news.service
~#systemctl mask motd-news.service
~#systemctl stop networkd-dispatcher
~#systemctl mask networkd-dispatcher
修改root密码
~#passwd
允许root远程ssh
~#echo PermitRootLogin yes >> /etc/ssh/sshd_config
~#exit
$sudo umount ubuntu/dev
$sudo umount ubuntu/proc
2,把自己做好的rootfs拷入u盘启动img镜像。
查看原img镜像分区
$ fdisk -l usb.img
Disk usb.img: 1.84 GiB, 1973420032 bytes, 3854336 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xa3008cac
Device Boot Start End Sectors Size Id Type
usb.img1 * 2048 206847 204800 100M c W95 FAT32 (LBA)
usb.img2 206848 3854335 3647488 1.7G 83 Linux
mount img内的rootfs分区
$sudo mkdir /mnt/usb
$sudo mount -o loop,offset=xxxxx usb.img /mnt/usb
xxxxx为上面第二个分区start值206848*512=105906176
把刚才制作好的rootfs拷贝到img里面
$sudo rm -rf /mnt/usb/*
$ sudo cp -R ubuntu/* /mnt/usb/
$ sudo umount /mnt/usb
再把usb.img 写入 U盘,,再用u盘启动华为ec6109高安版,等待几分钟后就可以ssh到ec6109,
ec6109的网卡灯有可能不亮。可以ping看系统是否启动完成。