# 初始化設定

## 將檔案燒到sd卡中

* Etcher
* MacOS X – ApplePi Baker

## 建立ssh檔

燒完後，再sd卡中的/boot中加入一個ssh檔，然後退出，放到Raspberry Pi 中開機執行

切換到sd卡中的boot資料夾中`cd /Volume/boot`，再使用`touch ssh`建立一個ssh檔

```
allen-mbp:~ allen$ cd /Volumes/boot
allen-mbp:boot allen$ touch ssh
allen-mbp:boot allen$ ls
COPYING.linux        bcm2710-rpi-cm3.dtb    kernel.img
LICENCE.broadcom    bootcode.bin        kernel7.img
LICENSE.oracle        cmdline.txt        overlays
bcm2708-rpi-0-w.dtb    config.txt        ssh
bcm2708-rpi-b-plus.dtb    fixup.dat        start.elf
bcm2708-rpi-b.dtb    fixup_cd.dat        start_cd.elf
bcm2708-rpi-cm.dtb    fixup_db.dat        start_db.elf
bcm2709-rpi-2-b.dtb    fixup_x.dat        start_x.elf
bcm2710-rpi-3-b.dtb    issue.txt
allen-mbp:boot allen$
```

## 登入ssh

RaspberryPi開機後使用終端機或ssh client程式連行連線

指令：`ssh pi@raspberrypi.local`

```
allen-mbp:~ allen$ ssh pi@raspberrypi.local
pi@raspberrypi.local's password: 
Linux raspberrypi 4.9.59-v7+ #1047 SMP Sun Oct 29 12:19:23 GMT 2017 armv7l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Fri Dec 29 12:50:59 2017 from fe80::1037:567d:9387:a9dc%eth0

SSH is enabled and the default password for the 'pi' user has not been changed.
This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.

pi@raspberrypi:~ $
```

## 更新軟體套件的清單

`sudo apt-get update`

## 更新軟體套件

`sudo apt-get upgrade`

## 更新韌體

`sudo rpi-upgrade`

先使用uname -a 指令查詢目前的版本

更新前先查詢版本資訊，目前為「4.9.59-v7+」

```
pi@raspberrypi:~ $ uname -a
Linux raspberrypi 4.9.59-v7+ #1047 SMP Sun Oct 29 12:19:23 GMT 2017 armv7l GNU/Linux
```

執行更新

```
pi@raspberrypi:~ $ sudo rpi-update
 *** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
 *** Performing self-update
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 13403  100 13403    0     0  20532      0 --:--:-- --:--:-- --:--:-- 20525
 *** Relaunching after update
 *** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
 *** We're running for the first time
 *** Backing up files (this will take a few minutes)
 *** Backing up firmware
 *** Backing up modules 4.9.59-v7+
#############################################################
This update bumps to rpi-4.9.y linux tree
Be aware there could be compatibility issues with some drivers
Discussion here:
https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=167934
##############################################################
 *** Downloading specific firmware revision (this will take a few minutes)
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   168    0   168    0     0    169      0 --:--:-- --:--:-- --:--:--   169
100 54.1M  100 54.1M    0     0  1490k      0  0:00:37  0:00:37 --:--:-- 3138k
 *** Updating firmware
 *** Updating kernel modules
 *** depmod 4.9.72-v7+
 *** depmod 4.9.72+
 *** Updating VideoCore libraries
 *** Using HardFP libraries
 *** Updating SDK
 *** Running ldconfig
 *** Storing current firmware revision
 *** Deleting downloaded files
 *** Syncing changes to disk
 *** If no errors appeared, your firmware was successfully updated to 9b6060d3962fff5addd51b2eda97b7593c1e14c2
 *** A reboot is needed to activate the new firmware
```

更新後而要重開機，重開機後再查詢版本資訊，已更新為「4.9.72-v7+」

```
pi@raspberrypi:~ $ uname -a
Linux raspberrypi 4.9.72-v7+ #1069 SMP Fri Dec 29 17:21:52 GMT 2017 armv7l GNU/Linux
```

## Raspberry Pi Software Configuration Tool(raspi-config)

指令：`sudo raspi-config`

記得要加sudo，用管理者權限執行，否則會出現如下提示訊息

```
pi@raspberrypi:~ $ raspi-config
Script must be run as root. Try 'sudo raspi-config'
```

執行指令後的畫面如下圖，舊的版本有10個選項，舊版本的「1 Expand Filesystem」，在目前版本中，此功能已經被移到「7 Advanced Options」中

![](https://1812161165-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdydZPxjDcJnzcr9z_R%2F-LdydaRScqPPmeYs1eIz%2F-LdydeqM8I089oRiPbTr%2Fraspi-config-01.png?generation=1556903025352974\&alt=media)
