Both sides previous revision Previous revision Next revision | Previous revision Next revisionBoth sides next revision |
rpi_common [2020/02/10 18:47] – [Upgrade Raspbian from Jessie to Stretch] Júne Park | rpi_common [2020/09/20 15:22] – Júne Park |
---|
<nav> | <nav> |
* {{fa>server?color=#8B0000}} Linux | * {{fa>server?color=#8B0000}} Linux |
* [[:rpi_common|General Things on Raspbian]] | * [[:rpi_common|■ General Things on Raspbian]] |
* [[:rpi_autism|Media Ditorium ─ AUTiSM Rainbow]] | * [[:rpi_autism|Media Ditorium ─ AUTiSM Rainbow]] |
* [[:rpi_epigen|Private Cellarium ─ EPiGEN Crystal]] | * [[:rpi_epigen|Private Cellarium ─ EPiGEN Crystal]] |
* [[:rpi_nimbus|Webius Officium ─ NiMBUS deBlanc]] | * [[:rpi_nimbus|Webius Officium ─ NiMBUS deBlanc]] |
* [[:debian_common|General info on Debian Linux]] | * [[:debian_common|■ General info on Debian Linux]] |
* [[:deb_mutism|Opus Imperium ─ MUTiSM Magnum]] | * [[:deb_mutism|Opus Imperium ─ MUTiSM Magnum]] |
| * [[:deb_gilead|Actu Periculum ─ GiLEAD Argenta]] |
| * [[:deb_debris|Finca LaDichium ─ DEBRiS Chrome]] |
* {{fa>windows?color=#0000A0}} Windows | * {{fa>windows?color=#0000A0}} Windows |
* [[:pc_common|Common Works on Windows]] | * [[:pc_common|■ Common Works on Windows]] |
* [[:pc_mesonism|Primus Workstation ─ MESONiSM]] | * [[:pc_mesonism|Primus Workstation ─ MESONiSM]] |
* [[:pc_mesonium|Manibus Tablet ─ MESONiUM]] | * [[:pc_mesonium|Manibus Tablet ─ MESONiUM]] |
* [[:pc_mesonity|Praevus Station ─ MESONiTY]] | * [[:pc_mesonity|Praevus Station ─ MESONiTY]] |
* {{fa>android?color=#006400}} Android | * {{fa>android?color=#006400}} Android |
* [[:cell_common|Common Stuffs on Androids]] | * [[:cell_common|■ Common Stuffs on Androids]] |
* [[:cell_epiaux|Júne's Primus ─ EPiAUX 5X]] | * [[:cell_epiaux|Júne's Primus ─ EPiAUX 5X]] |
* [[:cell_epihex|Júne's Extentus ─ EPiHEX 6]] | * [[:cell_epihex|Júne's Extentus ─ EPiHEX 6]] |
| * [[:cell_epimer|Júne's Maximus ─ EPiMER 5P]] |
* [[:cell_epinex|Júne's Secondus ─ EPiNEX 5]] | * [[:cell_epinex|Júne's Secondus ─ EPiNEX 5]] |
* [[:cell_epitab|Júne's Laminus - EPiTAB 7]] | * [[:cell_epitab|Júne's Laminus - EPiTAB 7]] |
</nav> | </nav> |
| |
===== General Things on Raspbian ===== | ====== General Things on Raspbian ====== |
| |
{{:playground:boo_the_bunny_13.png?nolink&250|}} | {{:playground:boo_the_bunny_13.png?nolink&200|}} |
| |
---- | ---- |
| |
==== Initial steps for Raspbian ==== | ===== First step for Raspberry OS ===== |
* Write [[https://www.raspberrypi.org/downloads/raspbian/|Raspbian Image]] on microSD memory. | |
* Boot with fresh Raspbian | |
* Login with ''**pi**'' / ''raspberry'' (default ID/password) | |
* Run ''**sudo raspi-config**'' to setup initial configuration. | |
| |
{{:manual:raspbi-config.png?650|}} | {{mdi>mini-sd?color=#c7053d}} Flash Raspberry Pi OS ((previous called Raspbian)) --- ingredients: [[https://www.raspberrypi.org/downloads/|Raspberry Pi OS]] & [[https://www.balena.io/etcher/|BalenaEtcher]] |
| |
| {{mdi>monitor?color=#c7053d}} Booting with flashed OS & login with ''**pi**'' / ''raspberry'' (default ID/password) |
| |
Set configuration with following menu. | {{mdi>powershell?color=#c7053d}} Execute ''**sudo raspi-config**'' to setup initial configuration. |
* 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, ''32''is rather optimal value. | |
| |
* Change ''root'' password - ''sudo passwd root'' | {{:manual:raspbi-config.png|}} |
* Add user for yourself - ''sudo adduser //userid//'' | |
* Add ''sudoer'' privilege for ''//userid//'' | ==== Setup raspbi-config ==== |
| |
| 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. <del>Overclock</del> --- Simply pass over |
| |
| 7. Advance Options |
| * **''A1 Expand Filesystem''** |
| * **''A3 Memory Split''** --- ''**32**'' for console user. less than 32 can cause problem |
| |
| ==== Manage accounts ==== |
| |
| === Change password for root === |
| |
| <code bash> |
| sudo passwd root |
| </code> |
| |
| === Create active userid === |
| |
| ''pi'' user is build-in account, which means weak point of security. Therefore creating personal ''userid'' is recommended. |
| |
| <code bash> |
| sudo adduser //userid// |
| </code> |
| |
| Append ''sudoer'' privilege for ''userid'' |
| |
| Edit ''/etc/sudoers'' |
| |
<code autoconf> | <code autoconf> |
# User privilege specification | # User privilege specification |
root ALL=(ALL:ALL) ALL | root ALL=(ALL:ALL) ALL |
userid ALL=(ALL) NOPASSWD: ALL | userid ALL=(ALL) NOPASSWD: ALL |
</code> | </code> |
| |
* copy all files from ''/home/pi/'' to ''/home/userid'' (e.g.: ''.profile'' ''.bashrc'') | Copy all files from ''/home/pi'' to ''/home/userid'' if necessary (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'' | Reboot system and login with ''userid'' |
* Update & upgrade | |
| Delete ''pi'' user |
| |
| <code bash> |
| sudo deluser pi |
| sudo rm -rf /home/pi |
| </code> |
| |
| === Update and Upgrade === |
| |
<code bash> | <code bash> |
sudo apt-get update && sudo apt-get dist-upgrade -y && sudo apt-get autoremove | sudo apt update && sudo apt dist-upgrade -y && sudo apt autoremove |
</code> | </code> |
| |
| |
<code bash> | <code bash> |
sudo apt-get update | sudo apt update |
sudo apt-get dist-upgrade -y | sudo apt dist-upgrade -y |
sudo apt-get autoremove | sudo apt autoremove |
</code> | </code> |
| |
Update ''firmware updater'' | Update kernel and VideoCore **''firmware''** |
| |
<code bash> | <code bash> |
sudo rpi-update | sudo rpi-update |
</code> | </code> |
| |
| ---- |
| |
| ==== Mount external disk(s) ==== |
| |
| Check attached or plugin devices using |
| |
| <code bash> |
| sudo blkid |
| </code> |
| |
| === Format the disk with ext4 === |
| |
| <code bash> |
| sudo mkfs.ext4 /dev/sdXY |
| </code> |
| |
| === Mount NTFS formatted disk === |
| |
| NTFS format has little advantage under Linux system but could mount it as well |
| |
| <code bash> |
| sudo apt-get install ntfs-3g |
| </code> |
| |
| Formatting disk with NTFS |
| |
| <code bash> |
| mkfs.ntfs -Q -L diskLabel /dev/sdXY |
| </code> |
| |
| === 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 |
| |
| <code ini> |
| UUID="dd7c1879-68c5-e9b9-bad6-789d3b8db984" /(path)/Storage ext4 defaults 0 0 |
| </code> |
| |
| Reboot the system and check the disk mounted. |
| |
---- | ---- |
==== Configure wireless connection ==== | ==== Configure wireless connection ==== |
| |
| <accordion> |
| <panel title="Under review"> |
| |
* Check wireless & configuration ''sudo iwconfig'' to find wireless is available. | * Check wireless & configuration ''sudo iwconfig'' to find wireless is available. |
sudo ip link set wlan0 up | sudo ip link set wlan0 up |
</code> | </code> |
| |
| </panel> |
| </accordion> |
| |
---- | ---- |
| |
==== Mount USB attached drive(s) ==== | ==== Set Google Public NTP ==== |
| |
''Check'' attached devices using ''sudo blkid'' | |
| |
=== format with ext4 === | |
<code bash> | |
sudo mkfs.ext4 /dev/sdXY | |
</code> | |
| |
=== mount ntfs === | |
| |
Even thought ''NTFS'' has little advantage in format, it has great advantage on compatibility. | |
| |
<code bash> | |
sudo apt-get install ntfs-3g | |
</code> | |
| |
formatting with NTFS | |
| |
<code bash> | |
mkfs.ntfs -Q -L diskLabel /dev/sdXY | |
</code> | |
| |
=== mount and booting option === | |
| |
<code bash> | <accordion> |
sudo vi /etc/fstab | <panel title="Under review"> |
</code> | |
| |
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'' | Use either ''systemd-timesyncd'' or ''ntp'' service. If you wish to use ''ntp'' |
sudo service ntp reload | sudo service ntp reload |
</code> | </code> |
| |
| </panel> |
| </accordion> |
| |
---- | ---- |
==== Move directories & files using rsync ==== | |
''rsync'' is useful command to transfer data from source to destination. | ===== Maintenance & Operation ===== |
| |
| ==== Useful packages ==== |
| |
| 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 |
| |
| ---- |
| |
| ==== Time stamp prompt ==== |
| |
| Edit ''~/.bashrc'' and change ''PS1'' line |
| |
<code bash> | <code bash> |
rsync -av --ignore-existing --remove-source-files /.. /source_directory/ TARGET.DOMAINS:/.. /destination_direcotry/ && \ | if [ "$color_prompt" = yes ]; then |
find /../source_directory/ -depth -type d -empty -delete; | 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 |
</code> | </code> |
| |
''--remove-source-files'' sender removes synchronized files (non-dirs) | Save and load ''.bashrc'' |
| |
''--ignore-existing'' skip updating files that already exist on receiver | <code bash> |
| source ~/.bashrc |
After running ''rsync'' command, ''find'' command runs to find and delete empty directories. | </code> |
| |
---- | ---- |
==== hash sum mismatch during apt-get update ==== | |
| |
This problem has something to do with ''slow connection'' or ''connection failure'' due to bad network situation. | ==== Modify login message ==== |
| |
| Edit ''/etc/motd'' |
| |
| <button type="danger" size="sm" icon="mdi mdi-message-text">[[https://wiki.meson.one/doku.php?id=secured:motd_raspbian|Live Configuration]]</button> |
| |
| Create ''20-disks'' (arbitrary name) and edit in ''/etc/update-motd.d/'' |
| |
<code bash> | <code bash> |
sudo vi /etc/apt/source.lists | #!/bin/sh |
| printf "\n" |
| df -h /dev/sd* --out=target,fstype --output=size,used,avail,pcent --type=ext4 |
| printf "\n" |
</code> | </code> |
| |
Remove downloaded repository information from the ''/var/lib/apt/lists/'' directory. | Script shows the information of the attached disks, which also reminds whether disk is mounted or not. |
| |
<code bash> | <code ini> |
sudo rm -rf /var/lib/apt/lists/* | Mounted on Type Size Used Avail Use% |
</code> | /home/userid/disk1 ext4 917G 338G 533G 39% |
| /home/userid/disk2 ext4 458G 307G 128G 71% |
| </code> |
| |
Change mirror address seemingly to be fast. | ---- |
| ==== Move directories & files using rsync ==== |
| |
[[https://www.raspbian.org/RaspbianMirrors|Raspbian Mirrors]] | <accordion> |
| <panel title="Under review"> |
| ''rsync'' is useful command to transfer data from source to destination. |
| |
This is a kind of temporary problem due to network condition. | <code bash> |
| rsync -av --ignore-existing --remove-source-files /.. /source_directory/ TARGET.DOMAINS:/.. /destination_direcotry/ && \ |
| find /../source_directory/ -depth -type d -empty -delete; |
| </code> |
| |
| ''--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. |
| </panel> |
| </accordion> |
| |
| ---- |
| |
---- | |
==== Upgrade Raspbian from Jessie to Stretch ==== | ==== Upgrade Raspbian from Jessie to Stretch ==== |
[[https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=184830|Upgrade video guide]] | |
[[https://www.52pi.com/blog/7-upgrade-raspbian-jessie-to-raspbian-stretch|Upgrade Guide]] | [[https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=184830|Upgrade video guide]] | [[https://www.52pi.com/blog/7-upgrade-raspbian-jessie-to-raspbian-stretch|Upgrade Guide]] |
| |
<code bash> | <code bash> |
sudo apt-get update | sudo apt update |
sudo apt-get upgrade | sudo apt dist-upgrade |
sudo apt-get dist-upgrade | |
</code> | </code> |
| |
| |
<code bash> | <code bash> |
sudo dpkg -C | sudo dpkg -C |
</code> | </code> |
| |
| |
<code bash> | <code bash> |
sudo apt-mark showhold | sudo apt-mark showhold |
</code> | </code> |
| |
Packages showing ''On Hold'' will not upgrade. \\ | Packages showing ''On Hold'' **will not be upgraded**. |
| |
Replace ''Jessie'' to ''Stretch'' in distribution sources. | Replace ''Jessie'' to ''Stretch'' in distribution sources. |
| |
<code bash> | <code bash> |
sudo sed -i 's/jessie/stretch/g' /etc/apt/sources.list | sudo sed -i 's/jessie/stretch/g' /etc/apt/sources.list |
</code> | </code> |
| |
| |
<code bash> | <code bash> |
lsb_release -a | lsb_release -a |
</code> | </code> |
| |
</code> | </code> |
| |
After rebooting, modify source list with ''buster'' Edit ''/etc/apt/source.list | After rebooting, modify source list with ''buster'' Edit ''/etc/apt/source.list'' |
| |
<code apt> | <code> |
deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi | deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi |
</code> | </code> |
Edit ''/etc/apt/sources.list.d/raspi.list'' | Edit ''/etc/apt/sources.list.d/raspi.list'' |
| |
<code apt> | <code> |
deb http://archive.raspberrypi.org/debian/ buster main | deb http://archive.raspberrypi.org/debian/ buster main |
</code> | </code> |
</code> | </code> |
| |
| Run update and upgrade for ''buster'' and it takes a long time. |
| |
---- | <code bash> |
| sudo apt update |
| sudo apt dist-upgrade |
| </code> |
| |
==== Customize login messages ==== | Optional remove (or possible these are supposed to be removed) the followings |
| |
edit or append ''/etc/update-motd.d/xx-command'', where xx is arbitrary number to set priorities. | <code bash> |
| sudo apt purge timidity lxmusic gnome-disk-utility deluge-gtk evince wicd wicd-gtk clipit usermode gucharmap gnome-system-tools pavucontrol |
| </code> |
| |
For example touch ''/etc/update-motd.d/20-disk'' with the following, | Clean and purge repository for update and reboot finally. |
| |
<code bash> | <code bash> |
#!/bin/sh | sudo apt autoremove -y |
printf "\n" | sudo apt autoclean |
df -h /dev/sd* --out=target,fstype --output=size,used,avail,pcent --type=ext4 | sudo reboot |
printf "\n" | |
</code> | </code> |
| |
shows size of disk, used and available capacities of ''ext4'' format disk(es). | |
| |
<code ini> | ---- |
Mounted on Type Size Used Avail Use% | |
/home/userid/disk1 ext4 917G 338G 533G 39% | |
/home/userid/disk2 ext4 458G 307G 128G 71% | |
</code> | |
| |
---- | |