2017年8月19日 星期六

樹莓派 3(Raspberry Pi 3) CentOS 7 ARM 安裝與配置


http://www.smalljacky.com/linux/centos/raspberry-pi-3-centos7-arm-install-setup/



樹莓派 3(Raspberry Pi 3) CentOS 7 ARM 安裝與配置




終於可以在「樹莓派 3」上使用 CentOS 了。本篇文章將詳細說明如何在「樹莓派 3」安裝 CentOS 7 ARM 系統,與首次使用的一些設定,如系統更新、自動調整分割區容量、驅動 wifi、時區設定、語系設定...

下載與燒錄映像檔

至 CentOS 官網下載連結 下載「樹莓派 3」的壓縮檔版本(支援樹莓派 2、樹莓派 3)。

先將壓縮檔裡的 .img(映像檔)解壓縮,並參考 Win32 Disk Imager 備份與燒錄 SD 卡 這篇文章將檔案燒錄至「Micro SD 記憶卡」,燒錄完成後:
  1. 將「Micro SD 記憶卡」插入「樹莓派 3」
  2. 接上網路線(網路設備必須支援 DHCP,且須與電腦同一網段)
  3. 「樹莓派 3」開機
接著進入網路設備查看「CentOS 7 ARM」DHCP 分配的網址(或使用網路網段掃描軟體,如 SoftPerfect Network Scanner)。

連結 CentOS 7 ARM

開啟 PieTTY 軟體 > [主機名稱或IP位址(N)] 輸入 IP > [Port] SSH 預設為 22 Port > 點擊 [連線]。
 PieTTY 軟體,可至 PieTTY (pputty) 下載

第一次使用 SSH 連線的主機,會提示是否儲存憑證,點擊 [是(Y)] 即可。

登入「CentOS 7 ARM」預設的帳戶:
  • 帳戶:root
  • 密碼:centos
login as: root
root@192.168.0.156's password: ******
[root@centos-rpi3 ~]#

CentOS 7 ARM 初始設置

系統更新

先更新所有套件、軟體與核心:
 100 多個更新,約 10 幾分才完成…
[root@centos-rpi3 ~]# yum -y update

CentOS 7 ARM README(說明文件)

在 root 家目錄下有一個 README 檔案:
[root@centos-rpi3 ~]# ll
total 4
-rw-r--r--. 1 root root 548 Dec  5 16:28 README
查看該檔案,說明使用「樹莓派 3」要做的兩件事:
  • 自動調整分割區容量
  • 驅動「樹莓派 3」的 wifi
[root@centos-rpi3 ~]# cat README
== CentOS 7 userland ==

If you want to automatically resize your / partition, just type the following (as root user):
/usr/local/bin/rootfs-expand

For wifi on the rpi3, just proceed with those steps :

curl --location https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.bin > /usr/lib/firmware/brcm/brcmfmac43430-sdio.bin

curl --location https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.txt > /usr/lib/firmware/brcm/brcmfmac43430-sdio.txt

systemctl reboot

自動調整分割區容量

先查看目前的容量:
[root@centos-rpi3 ~]# fdisk -l

Disk /dev/mmcblk0: 15.9 GB, 15931539456 bytes, 31116288 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0006dc70

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1            2048     1026047      512000    c  W95 FAT32 (LBA)
/dev/mmcblk0p2         1026048     2074623      524288   82  Linux swap / Solaris
/dev/mmcblk0p3         2074624     6268927     2097152   83  Linux

[root@centos-rpi3 ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       2.0G  995M  839M  55% /
devtmpfs        459M     0  459M   0% /dev
tmpfs           463M     0  463M   0% /dev/shm
tmpfs           463M   12M  451M   3% /run
tmpfs           463M     0  463M   0% /sys/fs/cgroup
/dev/mmcblk0p1  500M   49M  452M  10% /boot
tmpfs            93M     0   93M   0% /run/user/0
 
依 README 執行如下指令,來自動調整分區容量:
[root@centos-rpi3 ~]# /usr/local/bin/rootfs-expand
查看調整後的容量,增加了不少:
[root@centos-rpi3 ~]# fdisk -l

Disk /dev/mmcblk0: 15.9 GB, 15931539456 bytes, 31116288 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0006dc70

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1            2048     1026047      512000    c  W95 FAT32 (LBA)
/dev/mmcblk0p2         1026048     2074623      524288   82  Linux swap / Solaris
/dev/mmcblk0p3         2074624    31116287    14520832   83  Linux

[root@centos-rpi3 ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        14G  999M   13G   8% /
devtmpfs        459M     0  459M   0% /dev
tmpfs           463M     0  463M   0% /dev/shm
tmpfs           463M   12M  451M   3% /run
tmpfs           463M     0  463M   0% /sys/fs/cgroup
/dev/mmcblk0p1  500M   49M  452M  10% /boot
tmpfs            93M     0   93M   0% /run/user/0

驅動「樹莓派 3」的 wifi

查看目前啟用的網路介面只有一個 eth0 有線網路裝置,wifi 並沒有驅動:
[root@centos-rpi3 ~]# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 100                                                                                  0
    link/ether b8:27:eb:04:29:8a brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.156/24 brd 192.168.0.255 scope global dynamic eth0
       valid_lft 6580sec preferred_lft 6580sec
    inet6 fe80::ba27:ebff:fe04:298a/64 scope link
       valid_lft forever preferred_lft forever 
依 README 執行如下指令,來安裝 wifi 的驅動:
[root@centos-rpi3 ~]# curl --location https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.bin> /usr/lib/firmware/brcm/brcmfmac43430-sdio.bin
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   172  100   172    0     0     84      0  0:00:02  0:00:02 --:--:--    84
100  360k  100  360k    0     0  87259      0  0:00:04  0:00:04 --:--:--  170k

[root@centos-rpi3 ~]# curl --location https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.txt > /usr/lib/firmware/brcm/brcmfmac43430-sdio.txt
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   172  100   172    0     0     92      0  0:00:01  0:00:01 --:--:--    92
100  1108  100  1108    0     0    388      0  0:00:02  0:00:02 --:--:--  1631
重啟系統:
[root@centos-rpi3 ~]# systemctl reboot
再查看目前啟用的網路介面多了一個 wlan0,也就是 Wireless Lan:
[root@centos-rpi3 ~]# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether b8:27:eb:04:29:8a brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.156/24 brd 192.168.0.255 scope global dynamic eth0
       valid_lft 6107sec preferred_lft 6107sec
    inet6 fe80::ba27:ebff:fe04:298a/64 scope link
       valid_lft forever preferred_lft forever
3: wlan0:  mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
    link/ether 7a:d5:ba:e9:57:fb brd ff:ff:ff:ff:ff:ff

時區設定

查看目前系統的預設時區為 UTC,會比我們台灣的時間快 4 小時:
[root@centos-rpi3 ~]# timedatectl
      Local time: 六 2017-03-25 12:11:17 UTC
  Universal time: 六 2017-03-25 12:11:17 UTC
        RTC time: n/a
       Time zone: UTC (UTC, +0000)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a
先查看與“Asia”相關的時區有哪些:
[root@centos-rpi3 ~]# timedatectl list-timezones | grep "Asia"
... 以上省略 ...
Asia/Srednekolymsk
Asia/Taipei
Asia/Tashkent
... 以下省略 ...
設定時區,並查看:
[root@centos-rpi3 ~]# timedatectl set-timezone "Asia/Taipei"
[root@centos-rpi3 ~]# timedatectl
      Local time: 六 2017-03-25 20:19:23 CST
  Universal time: 六 2017-03-25 12:19:23 UTC
        RTC time: n/a
       Time zone: Asia/Taipei (CST, +0800)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a 

語系設定

查看目前設定的語系,可以看到「CentOS 7 ARM」並沒有指定語系:
[root@centos-rpi3 ~]# localectl
   System Locale: n/a

       VC Keymap: n/a
      X11 Layout: n/a
查看所有支援的語系:
[root@centos-rpi3 ~]# localectl list-locales
or 查看與“TW”相關的語系:
[root@centos-rpi3 ~]# localectl list-locales | grep "TW"
nan_TW.utf8@latin
nan_TW@latin
zh_TW
zh_TW.big5
zh_TW.euctw
zh_TW.utf8
設定台灣使用的“zh_TW.utf8”語系,並查看:
[root@centos-rpi3 ~]# localectl set-locale LANG=zh_TW.utf8
[root@centos-rpi3 ~]# localectl
   System Locale: LANG=zh_TW.utf8
       VC Keymap: n/a
      X11 Layout: n/a
重啟系統:
[root@centos-rpi3 ~]# systemctl reboot

其它

自動帶出相關指令;直接完成指令

在命令列輸入指令開頭 1 或多個字母後 [TAB][TAB] 鍵即可:
  • 自動帶出相關指令:有匹配多個
  • 直接完成:匹配一個
先安裝相關套件:
[root@centos-rpi3 ~]# yum install -y bash-completion
登出並重新登入後測試:
[root@centos-rpi3 ~]# logout
login as: root
root@192.168.0.156's password: ******
[root@centos-rpi3 ~]# systemctl res[TAB][TAB]
rescue        reset-failed  restart

沒有留言:

張貼留言

2007 to 2023 HP and Dell Servers Comparison

  HP Gen5 to Gen11  using ChatGPT HP ProLiant Gen Active Years CPU Socket Popular HP CPUs Cores Base Clock Max RAM Capacity Comparable Dell ...