catalogue
Download the Ubuntu root file system and the firefly root file system
Extract and create root file system
Copy the official peripheral driver file
This paper refers to the following disclosure:
How to make rootfs file of ubuntu arm64_ Elastic China community official blog - CSDN blog
Download the Ubuntu root file system and the firefly root file system
Ubuntu:
http://cdimage.ubuntu.com/ubuntu-base/releases/18.04/release/ubuntu-base-18.04.5-base-arm64.tar.gz
firefly:
Firefly | make technology simpler and life smarter
PS: I use the whole machine of firefly. Downloading the root file system made by firefly is to use the official peripheral driver
Installing virtual machines
apt-get install qemu-user-static
Extract and create root file system
mkdir ubuntu-rootfs tar -xpf ubuntu-base-18.04.5-base-arm64.tar.gz -C ubuntu-rootfs
Copy the running environment of the virtual machine
cp -b /etc/resolv.conf ubuntu-rootfs/etc/resolv.conf cp /usr/bin/qemu-aarch64-static ubuntu-rootfs/usr/bin/
Copy the official peripheral driver file
Mount the root file system of firefly and copy the three folders / vendor, / system, / lib/firmware to our own file system.
Mount root file system
Create ch mount SH file, write the following script
#!/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 mount -o bind /dev/pts ${2}dev/pts echo "CHROOT..." sudo chroot ${2} echo "Success!" } function umnt() { echo "UNMOUNTING" sudo umount ${2}proc sudo umount ${2}sys sudo umount ${2}dev/pts 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
Perform mount
./ch-mount.sh -m ubuntu-rootfs/
Configure root file system
Here are some configurations I made and some pits I encountered, which can be selectively made according to needs
- Change the source (after changing the source, it may not be updated due to the problem of certificate. Just change all https in the source to http)
- Configure the root account password (sometimes an error is reported during configuration. If sudo is installed, use sudo passwd root)
- Add personal account and configure password
useradd -s '/bin/bash' -m -G adm,sudo alex
- Install some basic packages
apt-get install language-pack-en-base ca-certificates sudo ssh net-tools ethtool wireless-tools network-manager iputils-ping rsyslog bash-completion vim
- Set host name
echo 'alex-gateway' > /etc/hostname
- In the step of setting resolvconf (decompressing and creating the root file system), resolv.conf is copied, but it is copied from the vmware virtual machine. Therefore, the problem of WiFi connection but no internet access will appear in the box. It will appear when ping baidu.com Temporary failure in name resolution)
apt-get install resolvconf dpkg-reconfigure resolvconf yes #Edit configuration vi /etc/resolvconf/resolv.conf.d/head #Add nameserver nameserver 114.114.114.114 nameserver 8.8.8.8
- To be added
Make root file system
After configuration, exit the virtual machine and cancel the mount
exit ./ch-mount.sh -u ubuntu-rootfs/
Create mkrootfs SH file and write the following script. 2048 depends on the actual size of your root file system. For example, if the size exceeds 2048M after installing the desktop environment, it should be larger
#!/bin/bash # dd if=/dev/zero of=linuxroot.img bs=1M count=2048 sudo mkfs.ext4 linuxroot.img rm -r rootfs mkdir rootfs sudo mount linuxroot.img rootfs/ sudo cp -rfp ubuntu-rootfs/* rootfs/ sudo umount rootfs/ e2fsck -p -f linuxroot.img resize2fs -M linuxroot.img
Executive production
./mkrootfs.sh
-Over -