如何在树莓派 4 上安装 Ubuntu 桌面系统
Ubuntu 树莓派

> 
> 本教程将详细告诉你在树莓派 4 设备上如何安装 Ubuntu 桌面。
> 
> 
> 


![](/data/attachment/album/202109/25/084015z4cfiiy8e1ezmmz0.jpg)


革命性的<ruby> 树莓派 <rt>  Raspberry Pi </rt></ruby>是最受欢迎的单板计算机。它拥有基于 Debian 的操作系统，叫做 <ruby> <a href="https://itsfoss.com/tutorial-how-to-install-raspberry-pi-os-raspbian-wheezy/">  树莓派操作系统 </a> <rt>  Raspberry Pi OS </rt></ruby>（原名 Raspbian）。


还有其他几个 [可用于树莓派的操作系统](https://itsfoss.com/raspberry-pi-os/)，但几乎所有的都是轻量级的，适合于树莓派设备的小尺寸和低端硬件。


随着标榜 8GB 内存和支持 4K 显示的树莓派 4B 的推出，情况发生了变化。其目的是将树莓派作为常规桌面使用，并在更大程度上成功地做到了这一点。


在 4B 型号之前，你可以 [在树莓派上安装 Ubuntu 服务器](https://itsfoss.com/install-ubuntu-server-raspberry-pi/)，但桌面版本却无法使用。然而，**Ubuntu 现在为树莓派 4 提供了官方的桌面镜像**。


在本教程中，我将展示在树莓派 4 上安装 Ubuntu 桌面的步骤。


首先，快速了解一下运行要求。


### 在树莓派 4 上运行 Ubuntu 的要求


![](/data/attachment/album/202109/25/084037n9fe4u93zku3uvll.png)


以下是你需要的东西：


1. 一个能够联网的 Linux 或 Windows 系统。
2. [树莓派镜像工具](https://github.com/raspberrypi/rpi-imager) ：树莓派的官方开源工具，可以在你的 SD 卡上写入发行版镜像。
3. Micro SD 卡：最低使用 16GB 的存储卡，推荐使用 32GB 的版本。
4. 一个基于 USB 的 Micro SD 卡读卡器（如果你的电脑没有读卡器）。
5. 树莓派 4 必备配件，如 HDMI 兼容显示器、[Micro HDMI 连接到标准 HDMI（A/M） 接口的电缆](https://www.raspberrypi.org/products/micro-hdmi-to-standard-hdmi-a-cable/)、[电源（建议使用官方适配器）](https://www.raspberrypi.org/products/type-c-power-supply/)、USB 的有线/无线键盘和鼠标/触摸板。


最好能够提前 [详细阅读树莓派的要求](https://itsfoss.com/things-you-need-to-get-your-raspberry-pi-working/) 。


现在，闲话少叙，让我快速带领你完成 SD 卡的镜像准备。


### 为树莓派准备 Ubuntu 桌面镜像


树莓派提供了一个 GUI 应用程序，用于将 ISO 镜像写入 SD 卡中。**这个工具还可以自动下载兼容的操作系统，如 Ubuntu、树莓派操作系统等**。


![下载并将操作系统放入 SD 卡的官方工具](/data/attachment/album/202109/25/084037rnouujmw2iyjxufz.png)


你可以从官方网站上下载这个工具的 Ubuntu、Windows 和 macOS 版本：


* [下载树莓派镜像工具](https://www.raspberrypi.org/software/)


在 Ubuntu 和其他 Linux 发行版上，你也可以使用 Snap 安装它：



```
sudo snap install rpi-imager

```

安装完毕后，运行该工具。当你看到下面的界面时，选择 “<ruby> 选择操作系统 <rt>  CHOOSE OS </rt></ruby>”：


![镜像工具：选择首选操作系统](/data/attachment/album/202109/25/084038lhbnz52fhflohthf.png)


在“<ruby> 操作系统 <rt>  Operating System </rt></ruby>”下，选择 “<ruby> 其它通用的操作系统 <rt>  Other general purpose OS </rt></ruby>”：


![镜像工具: 其他通用的操作系统](/data/attachment/album/202109/25/084038ps8trseuaj080rrj.png)


现在，选择 “Ubuntu”：


![镜像工具：发行版 - Ubuntu](/data/attachment/album/202109/25/084038a3e6d106t36y4yg0.png)


接下来，选择 “Ubuntu Desktop 21.04（RPI 4/400）”，如下图所示。


![镜像工具：发行版 - Ubuntu 21.04](/data/attachment/album/202109/25/084039etzef3hoo8pqqut7.png)



> 
> **注意：**
> 
> 
> 如果你没有一个稳定的网络连接，你可以 [从 Ubuntu 的网站上单独下载 Ubuntu 的树莓派镜像](https://ubuntu.com/download/raspberry-pi)。在镜像工具中，在选择操作系统时，从底部选择“<ruby> 使用自定义 <rt>  Use custom </rt></ruby>”选项。你也可以使用 Etcher 将镜像写入到 SD 卡上。
> 
> 
> 


将 Micro SD 卡插入读卡器中，等待它挂载。选择“<ruby> 存储设备 <rt>  Storage </rt></ruby>”下的 “<ruby> 选择存储设备 <rt>  CHOOSE STORAGE </rt></ruby>”：


![镜像工具：选择存储设备（SD 卡）](/data/attachment/album/202109/25/084039bb6wkk3zk03wf3sf.png)


你应该可以根据存储空间大小，识别你的 Micro SD 卡。这里，我使用的是 32GB 的卡：


![镜像工具：选择 SD 卡](/data/attachment/album/202109/25/084039pjjcsubajlanc5nn.png)


现在点击“<ruby> 写入 <rt>  WRITE </rt></ruby>”：


![镜像工具：镜像写入](/data/attachment/album/202109/25/084040ya9nms07zscfefzm.png)


如果你已经备份了 SD 卡上的内容或是一张新卡，你可以直接进行：


![镜像工具：镜像写入确认](/data/attachment/album/202109/25/084040wfycajgejfdheyxj.png)


由于这需要 [sudo](https://itsfoss.com/add-sudo-user-ubuntu/) 的权限，你必须输入密码。如果你从终端运行 `sudo rpi-imager`，就不会出现这种情况：


![镜像工具：镜像写入授权需要密码](/data/attachment/album/202109/25/084040feqmvor8mqzq66rr.png)


如果你的 SD 卡有点旧，这将需要一些时间。如果它是一个新的高速 SD 卡，就无需很长时间：


![镜像工具：写入镜像](/data/attachment/album/202109/25/084041vgz0agz1an1ncf5o.png)


为确保镜像写入成功，我不建议跳过验证：


![镜像工具：验证写入](/data/attachment/album/202109/25/084041y6nzkgzng3blcgln.png)


写入结束后，会有以下确认提示：


![镜像工具：写入成功](/data/attachment/album/202109/25/084041m4ixstzkscdqsx6k.png)


现在，从你的系统中安全移除 SD 卡。


### 在树莓派上使用装有 Ubuntu 的 MicroSD 卡


已经成功了一半了。与常规的 Ubuntu 安装不同，无需创建一个临场安装环境。Ubuntu 已经安装在 SD 卡上了，而且几乎可以直接使用了。让我们来看看这里还剩下什么。


#### 第 1 步：将 SD 卡插入树莓派中


对于第一次使用的用户来说，有时会有点困惑，不知道那个卡槽到底在哪里？不用担心。它位于电路板背面的左手边。下面是一个插入卡后的倒置视图。


![树莓派 4B 板倒置，插入 Micro SD 卡](/data/attachment/album/202109/25/084042gpeq6wyl20ww2ljl.jpg)


按照这个方向将卡慢慢插入板子下面的卡槽，轻轻地插，直到它不再往前移动。你可能还会听到一点咔嚓声来确认。这意味着它已经完美地插入了。


![树莓派 SD 插槽在板子背面的左侧](/data/attachment/album/202109/25/084042dr8drqr8df2ei82o.png)


当你把它插进去的时候，你可能会注意到在插槽中有两个小针脚调整了自己的位置（如上图所示），但这没关系。一旦插入，卡看起来会有一点突出。这就是它应该有的样子。


![树莓派 SD 卡插入时有一小部分可见](/data/attachment/album/202109/25/084042qz0ott7qok57o6t0.png)


#### 第 2 步：设置树莓派


我无需在这里详细介绍。


保证电源线接头、微型 HDMI 线接头、键盘和鼠标接头（有线/无线）都牢固地连接到树莓派板的相关端口。


确保显示器和电源插头也已正确连接，然后再去打开电源插座。我不建议把适配器插到带电的插座上。参考 [电弧](https://www.electricianatlanta.net/what-is-electrical-arcing-and-why-is-it-dangerous/)。


确认了以上两个步骤后，你就可以 [打开树莓派设备的电源](https://itsfoss.com/turn-on-raspberry-pi/)。


#### 第 3 步：在树莓派上 Ubuntu 桌面的首次运行


当你打开树莓派的电源，你需要在初次运行时进行一些基本配置。你只需按照屏幕上的指示操作即可。


选择你的语言、键盘布局、连接到 WiFi 等：


![选择语言](/data/attachment/album/202109/25/084042ccqqevihj6hq8l8v.jpg)


![选择键盘布局](/data/attachment/album/202109/25/084043jfnrlttmcufffcdn.jpg)


![选择 WiFi](/data/attachment/album/202109/25/084043zb6gnbsjxlbznuru.jpg)


你可以根据需求选择时区：


![选择时区](/data/attachment/album/202109/25/084043ubdd1bmwvctdv060.jpg)


然后创建用户和密码：


![输入所需的用户名和密码](/data/attachment/album/202109/25/084044ifn0u0u0nvuu03ud.jpg)


之后的步骤将配置一些东西，这个过程需要一些时间：


![完成 Ubuntu 设置](/data/attachment/album/202109/25/084044hbi8ds7n71rnq1xd.jpg)


![完成 Ubuntu 设置](/data/attachment/album/202109/25/084045e5ssf5a2smvwwefv.jpg)


系统会重新启动之前需要一些时间，最终，你将会来到 Ubuntu 的登录界面：


![Ubuntu 的登录界面](/data/attachment/album/202109/25/084045txz3ppsfbcg9cf4p.jpg)


现在，你可以开始享受树莓派上的 Ubuntu 桌面了：


![树莓派上的 Ubuntu 桌面](/data/attachment/album/202109/25/084045t9ag4aawym5y5awv.png)


### 总结


我注意到**一个暂时的异常情况**。在进行安装时，我的显示器左侧有一个红色的闪烁边界。这种闪烁（也有不同的颜色）在屏幕的随机部分也能注意到。但在重启和第一次启动后，它就消失了。


很高兴能够看到它在树莓派上运行，我非常需要 Ubuntu 开始为树莓派等流行的 ARM 设备提供支持。


希望这个教程对你有所帮助。如果你有问题或建议，请在评论中告诉我。




---


via: <https://itsfoss.com/install-ubuntu-desktop-raspberry-pi/>


作者：[Avimanyu Bandyopadhyay](https://itsfoss.com/author/avimanyu/) 选题：[lujun9972](https://github.com/lujun9972) 译者：[wxy](https://github.com/wxy) 校对：[turbokernel](https://github.com/turbokernel)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
*Brief: This thorough tutorial shows you how to install Ubuntu Desktop on Raspberry Pi 4 device.*

The revolutionary Raspberry Pi is the most popular single board computer. It has its very own Debian based operating system called [Raspbian](https://itsfoss.com/tutorial-how-to-install-raspberry-pi-os-raspbian-wheezy/).

There are several other [operating systems available for Raspberry Pi](https://itsfoss.com/raspberry-pi-os/) but almost all of them are lightweight. This was appropriate for the small factor and low end hardware of the Pi devices.

This changes with the introduction of Raspberry Pi 4B that flaunts 8 GB RAM and supports 4K display. The aim is to use Raspberry Pi as a regular desktop and it succeeds in doing so to a larger extent.

Before the 4B model, you could [install the Ubuntu server on Raspberry Pi](https://itsfoss.com/install-ubuntu-server-raspberry-pi/) but the desktop version was not available. However, **Ubuntu now provides official desktop image for Pi 4 models**.

In this tutorial, I am going to show the steps for installing Ubuntu desktop on Raspberry Pi 4.

First, a quick look at the prerequisites.

## Prerequisites for running Ubuntu on Raspberry Pi 4

![ubuntu desktop raspberry pi](https://itsfoss.com/content/images/wordpress/2021/09/ubuntu-desktop-raspberry-pi.png)

Here’s what you need:

- A Linux or Windows system with active internet connection.
[Raspberry Pi Imager](https://github.com/raspberrypi/rpi-imager): The official open source tool from Raspberry that gets you the distro image on your SD card.- Micro SD Card: Consider using at least a 16 GB storage for your card, albeit a 32 GB version is recommended.
- A USB based Micro SD Card Reader (if your computer does not have a card reader).
- Essential Raspberry Pi 4 accessories such as an HDMI compatible display,
[Micro HDMI to Standard HDMI (A/M) Cable](https://www.raspberrypi.org/products/micro-hdmi-to-standard-hdmi-a-cable/),[Power Supply (Official Adapter Recommended)](https://www.raspberrypi.org/products/type-c-power-supply/), USB Wired/Wireless Keyboard and Mouse/Touchpad.

It is good practice to [read in detail about the Pi requirements](https://itsfoss.com/things-you-need-to-get-your-raspberry-pi-working/) beforehand.

Now, without further delay, let me quickly walk you through the image preparation for the SD Card.

## Preparing the Ubuntu Desktop image for Raspberry Pi

Raspberry Pi provides a GUI application for writing the ISO image to the SD Card. **This tool can also download compatible operating systems like Ubuntu, Raspbian etc automatically**.

![raspberry pi imager tool](https://itsfoss.com/content/images/wordpress/2021/09/raspberry-pi-imager-tool.webp)

You can download this tool for Ubuntu, Windows and macOS from the official website:

On Ubuntu and other Linux distributions, you can also install it with Snap:

`sudo snap install rpi-imager`


Once installed, run the imager tool. When you see the screen below, select “CHOOSE OS”:

![pi imager choose os](https://itsfoss.com/content/images/wordpress/2021/09/pi-imager-choose-os.webp)

Under “Operating System”, select “Other general purpose OS”:

![pi imager other general purpose os](https://itsfoss.com/content/images/wordpress/2021/09/pi-imager-other-general-purpose-os.webp)

Now, select “Ubuntu”:

![pi imager os ubuntu](https://itsfoss.com/content/images/wordpress/2021/09/pi-imager-os-ubuntu.webp)

Next, select “Ubuntu Desktop 21.04 (RPI 4/400)” as shown below:

![pi imager os ubuntu 21 04](https://itsfoss.com/content/images/wordpress/2021/09/pi-imager-os-ubuntu-21-04.webp)

Note

If you do not have a good, consistent internet collection, you can [download the Ubuntu for Raspberry Pi image separately from Ubuntu’s website](https://ubuntu.com/download/raspberry-pi). In the Imager tool, while choosing the OS, go to the bottom and select “Use custom” option. You can also use Etcher for writing the image to the SD card.

Insert the micro SD card inside your Card reader and wait for it to mount. Select “CHOOSE STORAGE” under “Storage”:

![pi imager choose storage](https://itsfoss.com/content/images/wordpress/2021/09/pi-imager-choose-storage.webp)

You should be seeing only your micro SD card storage and you’d recognize it instantly based on the size. Here, I’ve used a 32 GB card:

![pi imager choose sd card](https://itsfoss.com/content/images/wordpress/2021/09/pi-imager-choose-sd-card.webp)

Now click on “WRITE”:

![pi imager image write](https://itsfoss.com/content/images/wordpress/2021/09/pi-imager-image-write.webp)

I’ll assume you have the contents of the SD card backed up. If it’s a new card, you can just proceed:

![pi imager image write confirm](https://itsfoss.com/content/images/wordpress/2021/09/pi-imager-image-write-confirm.webp)

Since this is a [sudo](https://itsfoss.com/add-sudo-user-ubuntu/) privilege, you must enter your password. If you run `sudo rpi-imager`

from a terminal, this would not appear:

![pi imager image write password](https://itsfoss.com/content/images/wordpress/2021/09/pi-imager-image-write-password.webp)

If your SD card is a bit old, it would take some time. But if it is a recent one with high speeds, it wouldn’t take long:

![pi imager writing image](https://itsfoss.com/content/images/wordpress/2021/09/pi-imager-writing-image.webp)

I also wouldn’t recommend skipping verification. Make sure the image write went successful:

![pi imager verifying changes](https://itsfoss.com/content/images/wordpress/2021/09/pi-imager-verifying-changes.webp)

Once it is over, you will get the following confirmation:

![pi imager write successful](https://itsfoss.com/content/images/wordpress/2021/09/pi-imager-write-successful.webp)

Now, safely-remove the SD card from your system.

## Using the micro SD card with Ubuntu on Raspberry Pi

Half of the battle is won. Unlike the regular Ubuntu install, you have not created a live environment. Ubuntu is already installed on the SD card and is almost read to use. Let’s see what remains here.

### Step 1: Insert the SD card into Pi

For first time users, it can take a bit confusing sometimes to figure out where on earth is that card slot! Not to worry. It is located below the board on the left-hand side. Here’s an inverted view with a card inserted:

![pi inverted micro sd card inserted](https://itsfoss.com/content/images/wordpress/2021/09/pi-inverted-micro-sd-card-inserted-800x572.webp)

Keep sliding the card in this orientation slowly into the slot below the board, gently until it no longer goes any further. This means it has just fit in perfectly. There won’t be any click sound.

![raspberry pi sd slot left side middle below board](https://itsfoss.com/content/images/wordpress/2021/09/raspberry-pi-sd-slot-left-side-middle-below-board.webp)

You might notice two little pins adjusting themselves in the slot (shown above) as you put it inside, but that’s ok. Once inserted, the card would look like a bit protruded. That’s how it is supposed to look like:

![pi sd card inserted](https://itsfoss.com/content/images/wordpress/2021/09/pi-sd-card-inserted.webp)

### Step 2: Setting Up the Raspberry Pi

I do not need to go in detail here, I presume.

Ensure that the power cable connector, micro HDMI cable connector, keyboard and mouse connectors (wired/non-wired) are securely connected to the Pi board in the relevant ports.

Make sure the display and power plug are properly connected as well, before you go ahead and turn on the power socket. I wouldn’t recommend plugging in the adapter to a live electrical socket. Look up [electrical arcing](https://www.electricianatlanta.net/what-is-electrical-arcing-and-why-is-it-dangerous/).

Once you’ve ensured the above two steps, you can [power on the Raspberry Pi device](https://itsfoss.com/turn-on-raspberry-pi/).

### Step 3: The first run of Ubuntu desktop on Raspberry Pi

Once you power on the Raspberry Pi, you’ll be asked to some basic configuration on your first run. You just have to follow the onscreen instructions.

Select your language, keyboard layout, connect to WiFi etc.

Select language Select keyboard layout Select WiFi

You’ll be asked to select the time zone:

![ubuntu raspberry pi first run 4](https://itsfoss.com/content/images/wordpress/2021/09/ubuntu-raspberry-pi-first-run-4.webp)

And then create the user and password:

![ubuntu raspberry pi first run 5](https://itsfoss.com/content/images/wordpress/2021/09/ubuntu-raspberry-pi-first-run-5.webp)

It will configure a couple of things and may take some time in doing so.

Finishing Ubuntu setup Finishing Ubuntu setup

It may take some time after this, your system will reboot and you’ll find yourself at the Ubuntu login screen:

![ubuntu raspberry pi login screen](https://itsfoss.com/content/images/wordpress/2021/09/ubuntu-raspberry-pi-login-screen.webp)

You can start enjoying Ubuntu desktop on Raspberry Pi now.

![ubuntu 21 04 post setup desktop](https://itsfoss.com/content/images/wordpress/2021/09/ubuntu-21-04-post-setup-desktop-800x450.webp)

## Conclusion

I noticed **a temporary anomaly**: A red flickering border on the left-hand side of my display while doing the installation. This flickering (also of different colors) was noticeable on random parts of the screen as well. But it went away after restarting and the first boot.

It was much needed that Ubuntu to start providing support for popular ARM devices like Raspberry Pi and I am happy to see it running on a Raspberry Pi.

I hope you find this tutorial helpful. If you have questions or suggestions, please let me know in the comments.