Initial steps for Raspbian

  • Write Raspbian Image on microSD memory.
  • Boot with fresh Raspbian
  • Login with pi / raspberry (default ID/password)
  • Run sudo raspi-config to setup initial configuration.

Set configuration with following menu.

  • 1. Change User Password - Change password for user pi.
  • 2. Hostname - Default value is raspberrypi, name what you want.
  • 3. Boot Options - Select console mode (command line) or Graphic mode (desktop)
  • 4. Localisation Options
    • T1 Change Locale - Default value is en_GB.UTF-8 UTF-8, recommendation is setting both en_US.UTF-8 UTF-8 and ko_KR.UTF-8 UTF-8.
    • T2 Change Timezone - Where Raspberry Pi lives.
    • T3 Change Wi-fi Country - What you want. Frequency ranges are different depending on country.
  • 5. Interfacing Options
    • P2 SSH - MUST CHECK with ENABLE
    • Others - Check ENABLE/DISABLE for your purposes.
  • 7. Advanced Options
    • A1 Expand Filesystem - MUST DO to extend your memory capacity to utilize
    • A3 Memory Split - Memory size for GPU. If you are console user, 32is rather optimal value.
  • Change root password - sudo passwd root
  • Add user for yourself - sudo adduser userid
  • Add sudoer privilege for userid
  # User privilege specification
  root    ALL=(ALL:ALL) ALL
  userid   ALL=(ALL) NOPASSWD: ALL
  • copy all files from /home/pi/ to /home/userid (e.g.: .profile .bashrc)
  • Logout pi user and login with userid
  • Delete pi user without regret sudo deluser pi and delete user directory sudo rm -rf /home/pi
  • Update & upgrade
  sudo apt-get update && sudo apt-get dist-upgrade -y && sudo apt-get autoremove

or enjoy every single step

  sudo apt-get update      
  sudo apt-get dist-upgrade -y 
  sudo apt-get autoremove 

Update firmware updater

  sudo rpi-update 

Configure wireless connection

  • Check wireless & configuration sudo iwconfig to find wireless is available.
  • Change proper configuration with editing /etc/network/interfaces

Since Stretch, /etc/network/interfaces is not useless unless stop dhcpcd service. Use /etc/dhcpcd.conf instead.

# Do not use in Stretch 
  allow-hotplug wlan0
  iface wlan0 inet static
    address 192.168.abc.xyz
    netmask 255.255.255.0
    gateway 192.168.abc.1
    dns-nameservers 8.8.8.8 8.8.4.4
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

Edit /etc/dhcpcd.conf for static IP address

# Here is an example which configures a static address, routes and dns.
# define static profile
profile static_eth0
static ip_address=192.168.1.23/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1
 
# fallback to static profile on eth0
interface eth0
fallback static_eth0

This configuration is static (fixed) IP with assigned DNS servers. fallback option is possible to configure a static profile within dhcpcd and fall back to it when DHCP lease fails.

  • Edit /etc/wpa_supplicant/wpa_supplicant.conf
  country=US
  ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
  update_config=1
 
  network={
    ssid="YOUR_SSID"
    psk="YOUR_PRESHARED_KEY_FOR_WIRELESS"
    key_mgmt=WPA-PSK
  }
  • Gear wireless up
  sudo ip link set wlan0 down
  sudo ip link set wlan0 up

Mount USB attached drive(s)

Check attached devices using sudo blkid

format with ext4

  sudo mkfs.ext4 /dev/sdXY 

mount ntfs

Even thought NTFS has little advantage in format, it has great advantage on compatibility.

  sudo apt-get install ntfs-3g

formatting with NTFS

  mkfs.ntfs -Q -L diskLabel /dev/sdXY

mount and booting option

 sudo vi /etc/fstab

Add line with device's UUID, which prevents failing mount due to point of devices.

UUID="dd7c1879-68c5-e9b9-bad6-789d3b8db984"  /(path)/Storage   ext4    defaults          0       0

Set Google Public NTP

Use either systemd-timesyncd or ntp service. If you wish to use ntp

  apt-get install ntp 
 
  systemctl stop systemd-timesyncd
  systemctl disable systemd-timesyncd
​  (sudo) /etc/init.d/ntp stop
​  (sudo) /etc/init.d/ntp start

Edit /etc/ntp.conf and append the following near server part.

server time1.google.com iburst
server time2.google.com iburst
server time3.google.com iburst
server time4.google.com iburst

restart NTP daemon

sudo service ntp reload

Move directories & files using rsync

rsync is useful command to transfer data from source to destination.

  rsync -av --ignore-existing --remove-source-files /.. /source_directory/ TARGET.DOMAINS:/.. /destination_direcotry/ && \
  find /../source_directory/ -depth -type d -empty -delete;

–remove-source-files sender removes synchronized files (non-dirs)

–ignore-existing skip updating files that already exist on receiver

After running rsync command, find command runs to find and delete empty directories.


hash sum mismatch during apt-get update

This problem has something to do with slow connection or connection failure due to bad network situation.

sudo vi /etc/apt/source.lists 

Change mirror address seemingly to be fast.

Raspbian Mirrors

This is a kind of temporary problem due to network condition.


Upgrade Raspbian from Jessie to Stretch

Upgrade video guide Upgrade Guide

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

Check for any system inconsistencies. Perform database sanity and consistency checks for partially installed, missing and obsolete packages

  sudo dpkg -C

If no issues are reported, check what packages are held back.

  sudo apt-mark showhold

Packages showing On Hold will not upgrade.
Replace Jessie to Stretch in distribution sources.

  sudo sed -i 's/jessie/stretch/g' /etc/apt/sources.list

And update & upgrade with stretch sources. Reboot & check distribution information.

  lsb_release -a

  • rpi_common
  • Last modified: 2018/07/26 15:30
  • by Júne Park