rpi_common

General Things on Raspbian


Flash Raspberry Pi OS 1) β€” ingredients: Raspberry Pi OS & BalenaEtcher

Booting with flashed OS & login with pi / raspberry (default ID/password)

Execute sudo raspi-config to setup initial configuration.

1. Change User Password β€” Change password for user pi 2. Network Options

  • N1 Hostname β€” Change hostname for server
  • N2 Wireless LAN β€” Setup wireless region, SSID and passphrase for wireless network
  • N3 Network interface names β€” predictable network interface name such as enx78e7d1ea46da vs. traditional name such as wlan0
  • N4 Network proxy settings β€” if necessary

3. Boot Options

  • B1 Desktop / CLI β€” Desktop GUI or Command Line Interface for operation CLI
  • B2 Wait for Network at Boot β€” Booting sequences are not completed without network connection if yes
  • B3 Splash Screen β€” Choose your taste

4. Localisation Options

  • I1 Change Locale β€” Default value is en_GB.UTF-8 UTF-8 , Set both en_US.UTF-8 UTF-8 & ko_KR.UTF-8 UTF-8
  • I2 Change Time Zone β€” Asia/Seoul or your place
  • I3 Change Keyboard Layout β€” if necessary but usually pass
  • I4 Change WLAN Country β€” if necessary

5. Interfacing Options

  • Disable: P1 Camera, P3 VNC (if use CLI) , P4 SPI , P5 I2C , P6 Serial , P7 1-Wire , P8 Remote GPIO
  • Enable: P2 SSH

6. Overclock β€” Simply pass over

7. Advance Options

  • A1 Expand Filesystem
  • A3 Memory Split β€” 32 for console user. less than 32 can cause problem

Change password for root

sudo passwd root 

Create active userid

pi user is build-in account, which means weak point of security. Therefore creating personal userid is recommended.

sudo adduser //userid// 

Append sudoer privilege for userid

Edit /etc/sudoers

# User privilege specification
root    ALL=(ALL:ALL) ALL
userid   ALL=(ALL) NOPASSWD: ALL

Copy all files from /home/pi to /home/userid if necessary (e.g.: .profile .bashrc)

Reboot system and login with userid

Delete pi user

sudo deluser pi 
sudo rm -rf /home/pi 

Update and Upgrade

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

or enjoy every single step

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

Update kernel and VideoCore firmware

sudo rpi-update 

Check attached or plugin devices using

sudo blkid

Format the disk with ext4

sudo mkfs.ext4 /dev/sdXY 

Mount NTFS formatted disk

NTFS format has little advantage under Linux system but could mount it as well

sudo apt-get install ntfs-3g

Formatting disk with NTFS

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

Disk mount at booting

Edit /etc/fstab

Append line(s) with device's UUID or location path /dev/sdXY. strongly prefer UUID with mount pointing

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

Reboot the system and check the disk mounted.


Under review

  • 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

Under review

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

Initially install the following packages for convenience.

  • tree β€” The tree is a tiny, cross-platform command-line program used to recursively list or display the content of a directory in a tree-like format.
  • vim β€” vim is a text editor. It can be used for editing any kind of text and is especially suited for editing computer programs.
  • iftop β€” iftop is a real time console-based Linux network bandwidth monitoring

Edit ~/.bashrc and change PS1 line

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]: \[\033[01;33m\]\D{%T}\[\033[00m\] \[\033[01;37m\]\w\$\[\033[00m\] '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h: \D{%T} \w\$ '
fi

Save and load .bashrc

source ~/.bashrc 

Edit /etc/motd

Live Configuration

Create 20-disks (arbitrary name) and edit in /etc/update-motd.d/

#!/bin/sh
printf "\n"
df -h /dev/sd* --out=target,fstype --output=size,used,avail,pcent --type=ext4
printf "\n"

Script shows the information of the attached disks, which also reminds whether disk is mounted or not.

Mounted on             Type  Size  Used Avail Use%
/home/userid/disk1     ext4  917G  338G  533G  39%
/home/userid/disk2     ext4  458G  307G  128G  71% 

Under review

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.


Upgrade video guide | Upgrade Guide

sudo apt update 
sudo apt 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 be upgraded.

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

Preparing upgrade with keeping up latest

sudo apt update 
sudo apt dist-upgrade -y 

Update Raspberry Pi's firmware,

sudo rpi-update 

After rebooting, modify source list with buster Edit /etc/apt/source.list

deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi

Edit /etc/apt/sources.list.d/raspi.list

deb http://archive.raspberrypi.org/debian/ buster main

To optimize upgrading process, remove apt-listchanges package

sudo apt-get remove apt-listchanges

Run update and upgrade for buster and it takes a long time.

sudo apt update
sudo apt dist-upgrade

Optional remove (or possible these are supposed to be removed) the followings

sudo apt purge timidity lxmusic gnome-disk-utility deluge-gtk evince wicd wicd-gtk clipit usermode gucharmap gnome-system-tools pavucontrol

Clean and purge repository for update and reboot finally.

sudo apt autoremove -y
sudo apt autoclean
sudo reboot 


1)
previous called Raspbian
  • rpi_common
  • Last modified: 2024/04/18 08:52
  • by JΓΊne Park