顯示具有 Raspberry-Pi 標籤的文章。 顯示所有文章
顯示具有 Raspberry-Pi 標籤的文章。 顯示所有文章

2020-05-16

Raspberry Pi 4 model B 安裝 Ubuntu 64-bit

Raspberry Pi 4 model B 安裝 Ubuntu 64-bit

Raspberry Pi 4 B 的 CPU 為 ARMv7l,是 32-bit 的 CPU,一般只會安裝 32-bit 的 OS。

但有些軟體已經不再支援 32-bit 的環境,此時使用 64-bit 變成一個基本需求。可喜的是 Ubuntu 官方已經提供 64-bit for Raspberry Pi 的 OS,不需要再到網路上找複雜的處理方式。

先到 Ubuntu 官網 下載 for Raspberry Pi 的 image 檔,現在可以選 Ubuntu 20.04 64-bit 的版本。雖然 R-Pi 官方的 Imager 裡已經有提供 Ubuntu 64-bit 的選項,但是還是建議先下載再使用 Imager,因為下載速度真的很慢。

接著再依照 How to install Ubuntu on your Raspberry Pi 安裝即可。

我個人是直接接實體網路線,所以 wifi 的設定都省了。

查看目前系統中可以安裝的 nodejs 和 mongodb 版本:

ubuntu@ubuntu:~$ apt-cache policy nodejs nodejs: Installed: (none) Candidate: 10.19.0~dfsg-3ubuntu1 Version table: 10.19.0~dfsg-3ubuntu1 500 500 http://ports.ubuntu.com/ubuntu-ports focal/universe arm64 Packages ubuntu@ubuntu:~$ apt-cache policy mongodb mongodb: Installed: (none) Candidate: 1:3.6.9+really3.6.8+90~g8e540c0b6d-0ubuntu5 Version table: 1:3.6.9+really3.6.8+90~g8e540c0b6d-0ubuntu5 500 500 http://ports.ubuntu.com/ubuntu-ports focal/universe arm64 Packages

如果沒有要太新的功能 nodejs 10 是可以接受的,安裝 nodejs 和 npm:

sudo apt install nodejs sudo apt install npm

也可以直接裝 MongoDB 3.6。若要安裝 MongoDB 4.2 可以參考這篇 Install Node.js and Npm on Raspberry Pi

2020-05-14

在 Raspbian 上安裝 Node.js

在 Raspbian 上安裝 Node.js

參考 Install Node.js and Npm on Raspberry Pi

先在 terminal 上查看 Raspberry Pi 的 CPU 型號:

uname -m

我的機器是 Pi 4 model B,CPU 是 ARMv7l。

Node.js 下載頁面 找到 Linux Binaries (ARM) 的版本,目前 LTS 12.16.3 版提供 ARMv7 和 ARMv8。若要找支援 ARMv6 就要找比較舊的版本。複製連結,並使用 wget 下載。

wget https://nodejs.org/dist/v12.16.3/node-v12.16.3-linux-armv7l.tar.xz

解壓縮檔案:

# tar -xvf 檔名.tar.xz tar -xvf ./node-v12.16.3-linux-armv7l.tar.xz

將檔案複製到 /usr/local/ 裡:

cd node-v12.16.3-linux-armv7l/ sudo cp -R * /usr/local/

最後查看版本,沒問題的話就完成安裝了:

node -v npm -v

這種安裝方式的缺點是,如果要移除 Node.js,由於沒有記錄複製的檔案,會無法移除所有檔案。

另一種安裝方式是使用 NodeSource Distributions,這個工具是由 NodeSource 這家公司所提供。

目前支援 Debian OS 的版本中,對 Raspberry Pi 支援的 CPU 只有 ARMv7 和 ARMv8,舊的 ARMv6 就不適合使用 NodeSource 的方案。以下是安裝的步驟:

先更新系統套件:

sudo apt-get update sudo apt-get dist-upgrade

NodeSource Distributions 查看支援 Debian 的版本,以下是安裝 12.x 的範例:

# Using Debian, as root curl -sL https://deb.nodesource.com/setup_12.x | bash - apt-get install -y nodejs

最後查看 Node 版本確認即可。

2020-05-13

透過 mac 安裝 Raspbian

透過 mac 安裝 Raspbian

首先到 Raspberry Pi 官網 下載 Raspberry Pi Imager for macOS,將 Raspberry Pi Imager.app 裝起來。

啟動 Imager 後,可以先格式化 SD 卡。

  1. Operating System 選 Erase
  2. SD Card 選讀卡設備
  3. 點選「Write」

安裝 Raspbian,也是同樣的步驟,不過下載檔案需要一些時間:

  1. Operating System 選「Raspbian」
  2. SD Card 選讀卡設備
  3. 點選「Write」

用我的老 mac mini 花了快一個小時... 後來發現是下載速度過慢的問題。 之後就可以裝 SD Card 試開機,一開始接比較舊的電視發現沒有畫面,換一般電腦螢幕就正常了。

一開始設定最重要的是開啟 SSH 和 VNC。有 SSH 才可以遠端登入 terminal,VNC 則是遠端桌面。 經常還是會發生設定上的問題,那可以用 ssh 登入:

ssh pi@192.168.1.108

輸入密碼後即可操作 Raspian 的 terminal。使用下式來設定:

sudo raspi-config

首頁畫面的 Interfacing Options 進入後可以啟動 SSH 和 VNC。 首頁畫面的 Advanced Options > Resolution,可以調整使用的解析度。有時 VNC 連線有狀況時,可以設定一個較小的模式,方便 VNC 呈現畫面。(CEA 模式比較接近電視,DMT 則是比較接近電腦螢幕)

FB 留言