|
|
@ -1,13 +1,13 @@ |
|
|
|
\chapter{制作 ubuntu 文件系统} |
|
|
|
在 主机的 Ubuntu 系统里面,可以制作 aarch64 的文件系统,这里介绍一下步骤。 |
|
|
|
\section{ 安装依赖软件} |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash} |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash} |
|
|
|
sudo apt install qemu-user-static debootstrap |
|
|
|
\end{minted} |
|
|
|
|
|
|
|
\section{下载基础系统} |
|
|
|
这里以安装 Ubuntu 22.04 为例: |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash} |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash} |
|
|
|
mkdir ubuntu |
|
|
|
sudo debootstrap --arch=arm64 --foreign jammy ubuntu |
|
|
|
sudo cp /usr/bin/qemu-aarch64-static ubuntu/usr/bin |
|
|
@ -21,7 +21,7 @@ sudo chroot ubuntu /usr/bin/qemu-aarch64-static /bin/sh \ |
|
|
|
给目标系统安装常用程序: |
|
|
|
\begin{enumerate}[(1)] |
|
|
|
\item 进入目标系统: |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash} |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash} |
|
|
|
sudo mount -o bind /sys ubuntu/sys |
|
|
|
sudo mount -o bind /proc ubuntu/proc |
|
|
|
sudo mount -o bind /dev ubuntu/dev |
|
|
@ -29,7 +29,7 @@ sudo mount -o bind /dev/pts ubuntu/dev/pts |
|
|
|
sudo chroot ubuntu /usr/bin/qemu-aarch64-static /bin/bash -i |
|
|
|
\end{minted} |
|
|
|
\item 修改 /etc/apt/sources.list 如下: |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash} |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash} |
|
|
|
deb http://ports.ubuntu.com/ jammy main universe |
|
|
|
deb-src http://ports.ubuntu.com/ jammy main universe |
|
|
|
deb http://ports.ubuntu.com/ jammy-security main universe |
|
|
@ -38,54 +38,54 @@ deb http://ports.ubuntu.com/ jammy-updates main universe |
|
|
|
deb-src http://ports.ubuntu.com/ jammy-updates main universe |
|
|
|
\end{minted} |
|
|
|
\item 更新系统: |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash} |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash} |
|
|
|
apt-get update |
|
|
|
apt-get dist-upgrade |
|
|
|
\end{minted} |
|
|
|
\item 安装常用软件: |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash} |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash} |
|
|
|
apt-get install -y vim-nox build-essential gdb u-boot-tools rsync \ |
|
|
|
socat jq tcpdump ifupdown minicom i2c-tools lrzsz tftp-hpa \ |
|
|
|
net-tools dosfstools pciutils memtool ethtool unzip python3-pip |
|
|
|
\end{minted} |
|
|
|
\item 设置 root 密码: |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash} |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash} |
|
|
|
passwd root |
|
|
|
\end{minted} |
|
|
|
\item 设置时区: |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash} |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash} |
|
|
|
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime |
|
|
|
\end{minted} |
|
|
|
\item 设置 hostname: |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash} |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash} |
|
|
|
echo sytc > /etc/hostname |
|
|
|
echo "127.0.0.1 sytc" >> /etc/hosts |
|
|
|
\end{minted} |
|
|
|
\item 设置bash为默认shell: |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash} |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash} |
|
|
|
dpkg-reconfigure dash |
|
|
|
\end{minted} |
|
|
|
选择{\kx “}NO{\kx ”}。 |
|
|
|
\item 配置 locals: |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash} |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash} |
|
|
|
dpkg-reconfigure locales |
|
|
|
\end{minted} |
|
|
|
至少选择 en\_US.UTF-8 和 zh\_CN.UTF-8。 |
|
|
|
\item 配置/etc/fstab,例如: |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash} |
|
|
|
# <file system> <mount pt> <type> <options> <dump> <pass> |
|
|
|
/dev/root / auto rw,noauto 0 1 |
|
|
|
tmpfs /tmp tmpfs mode=1777 0 0 |
|
|
|
tmpfs /run tmpfs mode=0755,nosuid,nodev 0 0 |
|
|
|
#PARTLABEL=oem /oem ext2 defaults 0 2 |
|
|
|
PARTLABEL=userdata /userdata ext4 defaults 0 0 |
|
|
|
proc /proc proc defaults 0 0 |
|
|
|
devtmpfs /dev devtmpfs defaults 0 0 |
|
|
|
devpts /dev/pts devpts mode=0620,ptmxmode=0666,gid=5 0 0 |
|
|
|
tmpfs /dev/shm tmpfs nosuid,nodev,noexec 0 0 |
|
|
|
sysfs /sys sysfs defaults 0 0 |
|
|
|
debugfs /sys/kernel/debug debugfs defaults 0 0 |
|
|
|
pstore /sys/fs/pstore pstore defaults 0 0 |
|
|
|
# <file system> <mount pt> <type> <options> <dump> <pass> |
|
|
|
/dev/root / auto rw,noauto 0 1 |
|
|
|
tmpfs /tmp tmpfs mode=1777 0 0 |
|
|
|
tmpfs /run tmpfs mode=0755,nosuid,nodev 0 0 |
|
|
|
#PARTLABEL=oem /oem ext2 defaults 0 2 |
|
|
|
PARTLABEL=userdata /userdata ext4 defaults 0 0 |
|
|
|
proc /proc proc defaults 0 0 |
|
|
|
devtmpfs /dev devtmpfs defaults 0 0 |
|
|
|
devpts dev/pts devpts mode=0620,ptmxmode=0666,gid=5 0 0 |
|
|
|
tmpfs /dev/shm tmpfs nosuid,nodev,noexec 0 0 |
|
|
|
sysfs /sys sysfs defaults 0 0 |
|
|
|
debugfs /sys/kernel/debug debugfs defaults 0 0 |
|
|
|
pstore /sys/fs/pstore pstore defaults 0 0 |
|
|
|
\end{minted} |
|
|
|
\item 修改 getty 服务,使 root 自动登录。修改文件 /usr/lib/systemd/system/serial-getty@.service 的 ExecStart 对应的值: |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{ini} |
|
|
@ -116,47 +116,47 @@ echo "source-directory /etc/network/interfaces.d"> /etc/network/interfaces |
|
|
|
\end{enumerate} |
|
|
|
\subsection{安装 ssh server} |
|
|
|
\noindent 安装软件: |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash} |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash} |
|
|
|
apt-get install openssh-server |
|
|
|
\end{minted} |
|
|
|
配置允许root登陆,将/etc/ssh/sshd\_config中的: |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash} |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash} |
|
|
|
#PermitRootLogin prohibit-password |
|
|
|
\end{minted} |
|
|
|
改为: |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash} |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash} |
|
|
|
PermitRootLogin yes |
|
|
|
\end{minted} |
|
|
|
|
|
|
|
\subsection{安装 rockchip 硬解码器} |
|
|
|
添加软件源: |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash} |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash} |
|
|
|
apt-get install software-properties-common |
|
|
|
add-apt-repository ppa:george-coolpi/multimedia |
|
|
|
apt update |
|
|
|
\end{minted} |
|
|
|
安装 gstreamer : |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash} |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash} |
|
|
|
apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \ |
|
|
|
libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-base \ |
|
|
|
gstreamer1.0-plugins-good gstreamer1.0-plugins-bad \ |
|
|
|
gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-tools \ |
|
|
|
libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-base \ |
|
|
|
gstreamer1.0-plugins-good gstreamer1.0-plugins-bad \ |
|
|
|
gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-tools \ |
|
|
|
gstreamer1.0-alsa gstreamer1.0-pulseaudio ffmpeg |
|
|
|
\end{minted} |
|
|
|
安装插件gstreamer1.0-rockchip |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash} |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash} |
|
|
|
apt-get install gstreamer1.0-rockchip |
|
|
|
\end{minted} |
|
|
|
|
|
|
|
\subsection{打包成 ext4 文件系统} |
|
|
|
|
|
|
|
清理并退出 chroot 环境: |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash} |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash} |
|
|
|
apt-get clean |
|
|
|
exit |
|
|
|
\end{minted} |
|
|
|
执行命令,打包成 ext4 的文件系统文件: |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash} |
|
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash} |
|
|
|
IMAGE_SIZE_MB=$(( $(sudo du -sh -m ubuntu | cut -f1) + 300 )) |
|
|
|
dd if=/dev/zero of=ubuntu.img bs=1M count=0 seek=${IMAGE_SIZE_MB} |
|
|
|
sudo mkfs.ext4 -d ubuntu ubuntu.img |
|
|
|