樹莓派4b安裝ubuntu-18.04.3教程(2019.8.17)

注:本文由本人於2019.08.17 20:19:58 發佈在簡書:犬夜叉寫作業,現通過整理,貼到下面。
截止到2020/3/29,已經有能夠直接安裝到樹莓派4b上的ubuntu鏡像,樹莓派的精神在於折騰,想體驗一波通過修改配置文件啓動樹莓派的,可以嘗試一下。

時間節點:2019.8.17
最新版的樹莓派4b今年6月末發佈,目前只有官方的Raspbian-Buster系統支持,其他系統均只支持到樹莓派3b+,這對於樹莓派4b的玩家非常不方便,所以下面教大家如何修改配置文件,使得ubuntu也能夠在樹莓派4b上運行。

一、安裝

本文用的是32G內存卡,安裝ubuntu-18.04.3-preinstalled-server-armhf+raspi3系統,是32位系統,64位系統安裝之後會有內存限制,所以目前還沒有去安裝。

下載鏡像,選擇 ubuntu-18.04.3-preinstalled-server-armhf+raspi3.img.xz 的鏡像進行下載
從官方下載鏡像:https://wiki.ubuntu.com/ARM/RaspberryPi
或者從這裏下載: http://cdimage.ubuntu.com/releases/18.04/release/

從官方下載樹莓派4b的Boot引導:https://github.com/raspberrypi/firmware

以上的文件都已經上傳到百度網盤:

鏈接:https://pan.baidu.com/s/1N4qG6ZZNE18GFhYcaj85hA
提取碼:x572

工具準備:

  • 大於8G的內存卡
  • Win32DiskImager
  • ubuntu-18.04.3-preinstalled-server-armhf+raspi3.img
  • firmware-master.zip

首先把下載好的鏡像用Win32DiskImager燒錄到準備好的U盤裏面,用其它燒錄軟件都可以。

在這裏插入圖片描述

燒錄完成之後,打開U盤,把裏面的文件全部刪除,再將從firmware-master.zip中解壓得到的Boot文件夾裏面的所有文件複製到U盤裏面,這樣樹莓派3b+的boot文件被替換成樹莓派4b的boot文件,
替換前:
在這裏插入圖片描述

替換後

在這裏插入圖片描述

在U盤根目錄下創建兩個文件(cmdline.txt和config.txt在這裏插入代碼片),並分別複製相應的內容,寫入文件並保存,也可以將百度網盤已經寫好的文件下載後拷貝到U盤根目錄。
創建cmdline.txt ,將下面的內容複製到文件裏面並保存

dwc_otg.fiq_fix_enable=2 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait rootflags=noload net.ifnames=0

創建config.txt,將下面的內容複製到文件裏面並保存

# Enable audio (loads snd_bcm2835)
dtparam=audio=on

[pi4]

[all]

同時,記得創建一個空文件,改名爲SSH(不要有文件後綴名.txt),放到U盤根目錄,開啓SSH遠程登錄,如果安裝之後沒法進入系統,沒關係,用遠程登錄即可。

到目前爲止,就可以將內存卡插入到你的樹莓派4b,啓動系統了,首次啓動時間比較長,需要2-3分鐘,請耐心等待。

默認的登陸用戶名和密碼都爲:ubuntu

其他具體內容可以參考來源:https://jamesachambers.com/raspberry-pi-ubuntu-server-18-04-2-installation-guide/

二、換源

先執行一下sudo apt-get update看是否能夠成功,如果成功,等待更新完成,不會太久,確定能構正常更新,就執行一下步驟進行換源

sudo nano /etc/apt/sources.list
## Note, this file is written by cloud-init on first boot of an instance
## modifications made here will not survive a re-bundle.
## if you wish to make changes you can:
## a.) add 'apt_preserve_sources_list: true' to /etc/cloud/cloud.cfg
## or do the same in user-data
## b.) add sources in /etc/apt/sources.list.d
## c.) make changes to template file /etc/cloud/templates/sources.list.tmpl

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic main restricted
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic-updates main restricted
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic universe
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic universe
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic-updates universe
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic-updates multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic-backports main restricted universe multiverse

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic-security main restricted
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic-security main restricted
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic-security universe
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic-security universe
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic-security multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports bionic-security multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu bionic partner
# deb-src http://archive.canonical.com/ubuntu bionic partner

換源之後記得更新一下

sudo apt update
sudo apt upgrade

如果安裝更新的的時候出現錯誤:dpkg returned an error code (1)
執行下面的語句
進入目錄

cd /var/lib/dpkg

刪除文件

sudo mv info info.baksudo

重新創建,到此解決錯誤問題

sudo mkdir info

然後再重新執行上面的更新

一定要保證源的替換是正確的,不能缺少,否則會出現找不到安裝包的問題哦,小編之前就是源的替換少了一個,所以安裝軟件的時候會出現找不到合適的安裝包

安裝桌面的時候,會出現依賴的問題,先安裝aptitude,用aptitude能夠自動安裝所缺失的依賴

sudo apt-get install aptitude

喜歡桌面操作的可以安裝官方推薦的桌面,以下三個安裝其中一個即可:

sudo aptitude install xubuntu-desktop
sudo aptitude install lubuntu-desktop
sudo aptitude install kubuntu-desktop

三、使用xrdp遠程桌面連接

sudo apt-get install tightvncserver xrdp

安裝完後,執行以下指令

echo xfce4-session >~/.xsession

將xfce4-session寫入到文件.xsession中

修改 /etc/xrdp/startwm.sh 文件

sudo nano /etc/xrdp/startwm.sh

在 /etc/X11/Xsession 上邊添加 xfce4-session

在這裏插入圖片描述
修改配置文件 /etc/X11/Xsession

sudo nano /etc/X11/Xsession

在文件最上面添加 xfce4-session

在這裏插入圖片描述
重新啓動xrdp服務

sudo service xrdp restart

然後我們就可以使用Windows的mstsc登錄了,界面如下

在這裏插入圖片描述
在這裏插入圖片描述

在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章