Install Ubuntu Server on Raspberry Pi 4

安装Ubuntu

官网下载Ubuntu Server 20.04.1 LTS bit-bit for Raspberry Pi 4。然后使用balenaEtcher烧录镜像到sd卡中。

将sd卡插入到树莓派,用网线连接网络(如果用无线网络请参考这里)。上电,等树莓派的绿灯闪烁,说明正常运行。

获取树莓派的IP地址,使用SSH客户端连接。默认用户名和密码都是ubuntu, 第一次登陆后系统会要求你修改密码。修改后使用新密码重新登录。

换apt源

sudo cp /etc/apt/sources.list /etc/apt/sources.list_bak
sudo vim /etc/apt/sources.list

替换为:

deb https://mirrors.ustc.edu.cn/ubuntu-ports/ focal main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu-ports/ focal main main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu-ports/ focal-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu-ports/ focal-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu-ports/ focal-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu-ports/ focal-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu-ports/ focal-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu-ports/ focal-security main restricted universe multiverse
# deb https://mirrors.ustc.edu.cn/ubuntu-ports/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.ustc.edu.cn/ubuntu-ports/ focal-proposed main restricted universe multiverse
sudo apt-get update
sudo apt-get upgrade
sudo reboot

安装桌面

重新登录,然后:

sudo apt install ubuntu-desktop

允许root登陆[1]

sudo passwd root #设置root密码
sudo vim /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf #编辑此文件

添加下列两行到50-ubuntu.conf

greeter-show-manual-login=true
allow-guest=false

Raspberry Pi 4超频

sudo /boot/firmware/config.txt

添加:

# 提升额定电压,0.025V步进的递减/递增降低或增加最大电压
over_voltage=10
# CPU 超频
arm_freq=2147
# GPU 超频
gpu_freq=750
# GPU 显存分配
gpu_mem=512

重启。

显示cpu信息:

lscpu

Architecture:                    aarch64
CPU op-mode(s):                  32-bit, 64-bit
Byte Order:                      Little Endian
CPU(s):                          4
On-line CPU(s) list:             0-3
Thread(s) per core:              1
Core(s) per socket:              4
Socket(s):                       1
Vendor ID:                       ARM
Model:                           3
Model name:                      Cortex-A72
Stepping:                        r0p3
CPU max MHz:                     2200.0000
CPU min MHz:                     628.5710
BogoMIPS:                        108.00
Vulnerability Itlb multihit:     Not affected
Vulnerability L1tf:              Not affected
Vulnerability Mds:               Not affected
Vulnerability Meltdown:          Not affected
Vulnerability Spec store bypass: Vulnerable
Vulnerability Spectre v1:        Mitigation; __user pointer sanitization
Vulnerability Spectre v2:        Vulnerable
Vulnerability Srbds:             Not affected
Vulnerability Tsx async abort:   Not affected
Flags:                           fp asimd evtstrm crc32 cpuid

最大cpu频率变为2200.0000。

显示cpu当前频率:

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq

显示cpu当前温度:

cat /sys/class/thermal/thermal_zone0/temp

固件更新(rpi-update)[2]

sudo curl -L --output /usr/bin/rpi-update https://raw.githubusercontent.com/Hexxeh/rpi-update/master/rpi-update && sudo chmod +x /usr/bin/rpi-update

sudo rpi-update
sudo reboot

安装库和软件

sudo apt-get install cmake
sudo apt-get install build-essential
sudo apt install python3-pip
sudo apt install ubuntu-software
sudo apt-get install chromium-browser
安装nomachine

这里下载最新版,

sudo  dpkg  -i  nomachine_7.0.211_1_arm64.deb
安装vscode

这里下载最新版,

sudo  dpkg  -i  code_1.52.1-1608136325_arm64.deb

  1. https://www.bilibili.com/video/BV1AC4y1x7hz/?spm_id_from=333.788.videocard.0)

  2. https://github.com/Hexxeh/rpi-update