jack-zheng
8/28/2018 - 10:46 AM

raspberry, nas, setup

raspberry, nas, setup

Write imge to Pi

For Windwos User

Software List

process is pretty simple, download your raspberry from offical website, unzip it and your will get an image file that is end with suffix '.img'. Mount your SD card to computer, format it with SD formatter. the format should FAT32. open Win32 DiskImager and write img to SD card. By now task done.

For Linux User

for Linux user, there is no need to download any tools for the purpose of format SD card and write image. the built-in commnad has support those functions. as Windows OS, download the Raspberry image first. and about format card, you can use fdisk command. and using dd command to write image to card.

sudo fdisk /dev/sdb
m # show menu
d # delete partition
p # show partition info
w # store change
q # quite without save

anyway you can type 'm' to get all the command info
sudo bs=4M if=2018-06-27-raspbian-stretch.img of=/dev/sdb status=progress conv=fsync
# bs: buffer size, 'M' need to be upper case
# if: the image path
# of: the SD card 
# status: help to show the process status, usefull
PS: of part you need to point to 'sdb' instead of 'sdb1' or write would be failed

Config Wireless network

Software list

  • Putty or other tools with same function if you are Windows user
  • Linux can be work with build-in tool

For users who get no display monitor or computer cable

mount your SD card to computer and

  1. touch a new file called 'ssh' -> enable ssh connection
  2. new a file named 'wpa_supplicant.conf' and input content as below

once your power on Pi, it will enable ssh and set wireless network for you, no other device is needed

For users who get computer cable but no display monitor

mount your SD card to computer and

  1. touch a new file called 'ssh' -> enable ssh connection

insert your SD card to Pi and connect it to router with computer cable, get Pi's ip from router. for example, when using TPLink, you get login to router management page and find device IP under:

查看路由器列表 -> DHCP 服务器 -〉 客户端列表, there will be a device named raspberry.

ssh to connect to Pi and update '/etc/wpa_supplicant/wpa_supplicant.conf' with content below

country=CN 
ctrl_interface=DIR=/var/run/wpa_supplicant 
GROUP=netdev 
update_config=1 
network={ 
    ssid="your router name" 
    psk="your password" 
    priority=1 
}

after config, 'sudo reboot'.

Update Source List

for Chinese user, it's important to update your source list to speed up your softerware update.

first of all, get know about your OS code name:

lsb_release -a

then update /etc/apt/source.list and /etc/apt/source.list.d/rasp.list

# 树莓派源更新, 阿里的源很慢, 最后用了中科大的
# /etc/apt/sources.list
deb http://mirrors.ustc.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi
# /etc/apt/sources.list.d/raspi.list
deb http://mirrors.ustc.edu.cn/archive.raspberrypi.org/ stretch main ui

** [!!!Attention]: if source config error, you would be in trouble when install software **

I cost more than 2 hours to fix this configure issue, WTF!!!

after config, run command to update and upgrade

sudo apt-get update
sudo apt-get upgrade

after this you may want to re-install vim editor, the build-in one is not convient to use

sudo apt-get remove vim-common # remove original one
sudo apt-get install vim

Other Issues

After re-install OS, I ssh to Pi and get exception as:

[jack@teng ~]$ ssh pi@192.168.1.101
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:5SwzT7Ac4Qpe/P0ixwJ1SAJR3QctNPfdMR7p0OWPRV4.
Please contact your system administrator.
Add correct host key in /home/jack/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /home/jack/.ssh/known_hosts:1
ECDSA host key for 192.168.1.101 has changed and you have requested strict checking.
Host key verification failed.

There is a cache file to log your SSH access info, you need to delete the .ssh folder under $HOME, or run command as:

ssh-keygen -R 192.168.1.101 
#作用: 备份known_hosts to known_hosts.old, 再新建一个空的known_hosts

Refer Source

树莓派3B+ 安装系统

树莓派学习笔记(5)

Linux 格式化U盘为ext4格式以及修复分区表方法