1 搭建基础环境
JackA1ltman edited this page 2026-04-04 23:24:57 +08:00
This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

搭建基础环境

基础编译 · 第一步

我们基于干净的设备环境进行教学,以 Ubuntu 24.04 为例。

获取 Linux 发行版

推荐使用清华大学镜像源下载(大陆地区):

https://mirrors.tuna.tsinghua.edu.cn/ubuntu-releases/noble/ubuntu-24.04.3-desktop-amd64.iso

校园镜像联合站:https://mirrors.cernet.edu.cn/

或直接从官网下载:https://ubuntu.com/download/desktop

制作启动盘

将 ISO 写入 U 盘,推荐工具:

安装系统

  1. 重启进入 BIOS在启动项中选择 U 盘
  2. 进入 Ubuntu LiveISO 的 GRUB回车进入 Live 模式
  3. 选择清空磁盘自动分区方式安装,等待约 20 分钟后重启进入系统

双系统用户注意:需手动分区,建议用 DiskGenius 拆分至少 300 GB 给 Linux。安装时创建 ≥ 512 MB 的 EFI 分区,其余分给 / 分区。Swap 建议使用文件方式而非独立分区。

安装必要依赖

sudo apt update && sudo apt upgrade -y

sudo apt install nano vim wget curl git ccache \
  automake flex lzop bison gperf build-essential zip \
  curl zlib1g-dev g++-multilib libxml2-utils bzip2 \
  libbz2-dev libbz2-1.0 libghc-bzlib-dev squashfs-tools \
  pngcrush schedtool dpkg-dev liblz4-tool make optipng \
  maven libssl-dev pwgen libswitch-perl policycoreutils \
  minicom libxml-sax-base-perl libxml-simple-perl bc \
  libc6-dev-i386 lib32ncurses5-dev libx11-dev lib32z-dev \
  libgl1-mesa-dev xsltproc unzip device-tree-compiler \
  wget curl cpio p7zip p7zip-full libtinfo5 -y

sudo apt install python3 python-is-python3 -y

git 基础用法

git clone -b <分支名> https://github.com/<用户>/<仓库>.git --depth 1
参数 说明
clone 克隆目标源码
-b <分支名> 指定克隆分支,不加则克隆所有分支
--depth 1 只保留最新提交,压缩大小,适合不需要历史记录的场景