玩 Raspberry Pi 最好用官方 Raspbian 為作業系統,那是基於 Debian 改出來,本人慣的 Ubuntu 也是從 Debian 改出來,屬同一個祖宗,因此用起上來,不會感到難上手。
流程︰
- 下載及安裝 Raspbian
- 設定及更新 Raspbian ( Part 1 / 3 )
- 設定及更新 Raspbian ( Part 2 / 3 )
- 設定及更新 Raspbian ( Part 2 / 3 )
- 微調個人 Raspberry Pi
下載及安裝 Raspbian
下載 Raspbian
我會拿作小型伺服器用,閒時看 Youtube 及網頁,因此 下載 Raspbian 全功能版,並解壓 zip 檔。
安裝 Raspbian
官網已有 詳細教學,這裡只是搬紙過字般,翻譯及實作。
- 不要插 TF 卡,首先用 lsblk 看看現在有甚麼 device,然後插入 TF 卡,對比一下多了甚麼。
- 以我情況為例,多了 /dev/sdf,要 umount 所有 sdf 底下所有 partition ( sdf1 及 sdf2 ),在 Ubuntu 很好認,多數會掛在 /media/<USER>/sdx。
umount /media/<USER>/boot
umount /media/<USER>/rootfs
- cd 去下載位置,執行指令 ( 我的 TF 是 /dev/sdf,請跟據自身情況更改指令 ),把 Raspbian image 灌進 TF 卡。
cd Downloads
dd bs=4M if=<RASPBIAN-VERSION>.img of=/dev/sdf status=progress conv=fsync
lsblk
———————————簡易的分隔線————————————
設定及更新 Raspbian ( Part 1 / 3 )
把 Raspbian 灌進 TF 卡後,拔出再插入 TF,等待桌面顯示 mount 到的設備,進去 boot 做設定,這種設定方法叫 Headless setup,可以用這個關鍵字 Google 更多資訊。本教學假設沒有 mon 也沒有 keyboard、mouse 及 lan 線,只有 wifi,以 Headless 設定及連線 Raspberry Pi。
註︰全部設定檔都用 Ubuntu 開啟及儲存,Windows 換行與 Linux 不同,在 Windows上不要用 notepad 改,要用 IDE ( 如 Eclipse ) 開啟及儲存檔案。
config.txt
Raspbian Stretch Headless Setup Procedure
Setting up a Raspberry Pi headless
設定顯示器
這一步不必跟住做,因為用 7" LCD 才需要這樣設定,可跳過,如果插 HDMI 去顯示器沒有畫面,可以調整這個設定。其餘步驟,例如 WIFI、SSH 等設定,可以進去 Raspbian 後,以 GUI 設定 ( Raspberry Pi 有連接顯示器、keyboard、mouse 情況下 )。
設定 WIFI 及 SSH
完成後,退出 TF 卡並插進 Raspberry Pi,接上電源。
SSH 連線 Raspberry Pi
以下是預設資訊︰
- hostname : raspberrypi
- ID : pi
- PW : raspberry
知道以上三項又怎用?
偷看 DHCP 找 IP
所以偷偷接上 HDMI 到顯示器,直接看 IP。正常情況下,不需要這樣做!因為 WIFI AP 太多太密,估不到 Raspberry Pi 接去那隻 AP,無法縮小範圍找 IP 才出此下策,無法做到完全 Headless 感到遺憾。
SSH 連線
SSH reference
https://www.raspberrypi.org/documentation/remote-access/ssh/
———————————簡易的分隔線————————————
設定及更新 Raspbian ( Part 2 / 3 )
SSH 登入後,輸入指令 sudo raspi-config
- 改 password!
- 更改 hostname
- 設定 local、time-zonez、keyboard及 wifi
Securing your Raspberry Pi
———————————簡易的分隔線————————————
設定及更新 Raspbian ( Part 3 / 3 )
更新系統及軟件
( Raspberry 3B+ 版本)
sudo apt-get update
sudo apt-get upgrade
( Raspberry 4B 版本 )
sudo apt update
sudo apt full-upgrade
安裝 xrpc
sudo apt-get -y install xrdp
註︰防火牆要開啟 3389
安裝字型 ( 中文字 )
sudo apt-get -y install fonts-arphic*
安裝輸中文入法及其他元件
sudo apt-get -y install scim scim-tables-zh scim-gtk-immodule im-switch
安裝字型 ( 日文 )
sudo apt-get fonts-ipafont-gothic
安裝日文輸入法
sudo apt-get -y install scim-anthy
重新開機
sudo reboot
參考︰
http://atceiling.blogspot.com/2017/03/raspberry-pi_26.html
https://www.raspberrypi.org/documentation/raspbian/updating.md
———————————簡易的分隔線————————————
微調個人 Raspberry Pi
這是給 Windows 用家的指南,Linux 要 GUI 可以用 VNC viewer,下回 Raspberry Pi 減肥、備份、重灌及技巧 補回使用 VNC viewer 教學。
VNC Viewer Download ( Linux )
https://www.realvnc.com/en/connect/download/viewer/linux/
於 Windows 以 mstsc 進入 Raspberry Pi 做最終設定及測試。
到系統設定輸入法為 SCIM via IM_MODULE ( scim-immodule )。
重新開機後,右上角會多了一個 Keyboard icon,右鍵 icon 做 setting。
scim-tables-zh 套件包含最齊全輸入法,選自己會用到的輸入法。可以 "Ctrl + Space" 轉換輸入法,然後開 LibreOffice 測試打中文是否正常。
用來上網看網頁,可以把常看網頁 bookmark,還有刪除不需要軟件,下一回會詳解怎減肥。
———————————簡易的分隔線————————————
總結︰
可以拿來用,但不要心急,先造一個 Image 出來,方便日後重灌。下一回說廋身 TF 卡,由 32 GB,壓到 7.2 GB image,以及一些技巧及運用方法。
【下一回】Raspberry Pi 減肥、備份、重灌及技巧