スワップなど。
対象環境
- Raspberry Pi 3 Model B+
- Raspbian stretch 9.0 2018-11-13 Desktop
HDMI設定
初回ブートするもディスプレイが真っ暗。No Signal
となりHDMI信号がディスプレイに発信されていない模様。そこでHDMI設定した。以下ファイルの末尾に以下内容を追記。
/boot/config.txt
# 2018-09-21 Elecrow Display start Raspbian stretch 9.0 2018-06-27で有効であることを確認 # 古いディスプレイ(1024x768まで対応)だとブートしなくなる。(ディスプレイが暗い状態でチカチカするのを無限ループする)その場合はコメントアウトする。 max_usb_current=1 hdmi_group=2 hdmi_mode=1 hdmi_mode=82 hdmi_cvt 1920 1080 60 6 0 0 0 # 2でないと音が出ない #hdmi_drive=1 hdmi_drive=2 # 2018-09-21 Elecrow Display end # 2018-09-30 https://qiita.com/tkyonezu/items/0d11c782da3921d6a9f3 program_usb_boot_mode=1 program_usb_boot_timeout=1 # 2018-09-30 https://qiita.com/tkyonezu/items/0d11c782da3921d6a9f3
RAM Disk
sudo leafpad /etc/fstab
ファイル末尾に以下を追記。
tmpfs /tmp tmpfs defaults,size=768m,noatime,mode=1777 0 0 tmpfs /var/tmp tmpfs defaults,size=16m,noatime,mode=1777 0 0 tmpfs /var/log tmpfs defaults,size=32m,noatime,mode=0755 0 0 tmpfs /home/pi/.cache/chromium/Default/ tmpfs defaults,size=768m,noatime,mode=1777 0 0 tmpfs /home/pi/.cache/lxsession/LXDE-pi tmpfs defaults,size=1m,noatime,mode=1777 0 0
aptサーバ設定
sudo leafpad /etc/apt/sources.list
ファイル先頭に以下追記。
# appended 2019-02-12 install initialize setting deb http://ftp.jaist.ac.jp/raspbian/ stretch main contrib non-free rpi deb http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian/ stretch main contrib non-free rpi deb http://ftp.yz.yamagata-u.ac.jp/pub/linux/raspbian/raspbian/ stretch main contrib non-free rpi deb http://mirrordirector.raspbian.org/raspbian/ stretch main contrib non-free rpi # firmwar update deb http://mirrors.ustc.edu.cn/archive.raspberrypi.org/debian/ stretch main ui # appended 2019-02-12 install initialize setting
ログ出力抑制
sudo leafpad /etc/rsyslog.conf
以下の行における先頭に#
を追記してコメントアウト。(以下はすでにコメントアウト済み)
############### #### RULES #### ############### # # First some standard log files. Log by facility. # #auth,authpriv.* /var/log/auth.log #*.*;auth,authpriv.none -/var/log/syslog #cron.* /var/log/cron.log #daemon.* -/var/log/daemon.log #kern.* -/var/log/kern.log #lpr.* -/var/log/lpr.log #mail.* -/var/log/mail.log #user.* -/var/log/user.log # # Logging for the mail system. Split it up so that # it is easy to write scripts to parse these files. # #mail.info -/var/log/mail.info #mail.warn -/var/log/mail.warn #mail.err /var/log/mail.err # # Some "catch-all" log files. # #*.=debug;\ # auth,authpriv.none;\ # news.none;mail.none -/var/log/debug #*.=info;*.=notice;*.=warn;\ # auth,authpriv.none;\ # cron,daemon.none;\ # mail,news.none -/var/log/messages
システムのアップデート
sudo apt-get update -y sudo apt-get upgrade -y sudo apt-get dist-upgrade -y
途中で以下のダイアログが出た。OK
ボタンをクリックした。
libavfilter6:armhf (7:3.2.12-1~deb9u1+rpt1) を設定しています ... vlc-plugin-qt:armhf (3.0.6-0+rpt1+deb9u1) を設定しています ... raspberrypi-ui-mods (1.20181206) を設定しています ... The desktop has been updated. To apply the updates, please reboot your Pi, and then select one of the options on the Defaults page in Appearance Settings. ** (zenity:22928): WARNING **: Error retrieving accessibility bus address: org.freedesktop.DBus.Error.ServiceUnknown: The name org.a11y.Bus was not provided by any .service files libqt5printsupport5:armhf (5.7.1+dfsg-3+rpi1+deb9u1) を設定しています ... vlc-plugin-skins2:armhf (3.0.6-0+rpt1+deb9u1) を設定しています ... libavdevice57:armhf (7:3.2.12-1~deb9u1+rpt1) を設定しています ...
日本語化(IME、フォント)
sudo apt install -y fcitx-mozc sudo apt install -y fonts-vlgothic sudo apt install -y fonts-ipafont fonts-ipaexfont
昔書いたバッチ
#!/bin/bash # =================================================== # 題名: Raspbian stretch 初期セットアップ自動化バッチ # セットアップ概要: # * スワップ停止 # * RAMディスク設定 # * aptのソースを日本サーバに設定 # * ログ出力の抑制 # * システム更新 # * 日本語フォント+日本語入力のインストール # 実行タイミング: # SDカードにRaspbianをインストールし、 # 初回ブートし、 # ダイアログに従ってセットアップ # した後に1度だけ実行する。 # なお、システム更新はダイアログの時点ではスキップし、このバッチで行うほうが高速に完了するはず。 # 対象OS: Raspbian stretch 2018-06-27 # 作成日: 2018-10-12 # 作成者: ytyaru # =================================================== # コマンドをsudo権限で実行する # $1: some linux command. function run_sudo() { sudo sh -c "${1}" } # 指定したテキストを指定したファイルに追記する # $1: text: new line text. # $2: file: target file path. # http://yut.hatenablog.com/entry/20111013/1318436872 # https://qiita.com/b4b4r07/items/e56a8e3471fb45df2f59 # http://wannabe-jellyfish.hatenablog.com/entry/2015/01/10/004554 # http://pooh.gr.jp/?p=6311 function write_line() { for i in "${1}"; do local command="echo '${i}'" sudo sh -c "${command} >> \"${2}\"" done } # 指定ファイルのうち先頭が指定テキストの場合、先頭に#を付与する # $1: file: target file path. # $2: text: target text(ヒアドキュメントで複数行指定されることを想定) #http://linux-bash.com/archives/3745148.html function write_sharp() { #IFS_backup=IFS #IFS=$'\n' for i in ${2}; do # 末尾の改行を除去(しないと次のエラーが出る。"sed: -e expression #1, char 2: アドレスregexが終了していません") local line=`echo ${i} | sed -e "s/[\r\n]\+//g"` local sed_script="/^${line}/s/^/#/" local sed_cmd="sed -e \"${sed_script}\" -i.bak \"${1}\"" run_sudo "${sed_cmd}" done #IFS=IFS_backup } # スワップ停止(SDカード書込上限対策) function stop_swap() { sudo swapoff --all sudo systemctl stop dphys-swapfile sudo systemctl disable dphys-swapfile } # RAMディスク作成(SDカード書込上限対策) function write_fstab() { text=' tmpfs /tmp tmpfs defaults,size=768m,noatime,mode=1777 0 0 tmpfs /var/tmp tmpfs defaults,size=16m,noatime,mode=1777 0 0 tmpfs /var/log tmpfs defaults,size=32m,noatime,mode=0755 0 0 tmpfs /home/pi/.cache/chromium/Default/ tmpfs defaults,size=768m,noatime,mode=1777 0 0 tmpfs /home/pi/.cache/lxsession/LXDE-pi tmpfs defaults,size=1m,noatime,mode=1777 0 0 ' write_line "${text}" "/etc/fstab" } # システム更新の高速化(日本用) function write_apt_sources_list() { text=' deb http://ftp.jaist.ac.jp/raspbian/ jessie main contrib non-free rpi deb http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian/ jessie main contrib non-free rpi deb http://ftp.yz.yamagata-u.ac.jp/pub/linux/raspbian/raspbian/ jessie main contrib non-free rpi deb http://mirrordirector.raspbian.org/raspbian/ jessie main contrib non-free rpi # firmwar update deb http://mirrors.ustc.edu.cn/archive.raspberrypi.org/debian/ jessie main ui ' write_line "${text}" "/etc/apt/sources.list" } # ログ出力を抑制する(SDカード書込上限対策) #http://linux-bash.com/archives/3745148.html #http://momijiame.tumblr.com/post/92049916671/%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%81%AE%E7%89%B9%E5%AE%9A%E8%A1%8C%E3%82%92-sed-%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E3%81%A7%E3%82%B3%E3%83%A1%E3%83%B3%E3%83%88%E3%82%A2%E3%82%A6%E3%83%88%E3%81%99%E3%82%8B #/etc/rsyslog.conf function comment_out_rsyslog_conf() { text=' auth,authpriv.* *.*;auth,authpriv.none cron.* daemon.* kern.* lpr.* mail.* user.* mail.info mail.warn mail.err *.=debug; auth,authpriv.none; news.none;mail.none *.=info;*.=notice;*.=warn; auth,authpriv.none; cron,daemon.none; mail,news.none ' write_sharp "/etc/rsyslog.conf" "${text}" } # システム&ファームウェア更新 function update_system() { sudo apt-get update -y sudo apt-get upgrade -y sudo apt-get dist-upgrade -y } # 日本語化 function japanese() { sudo apt-get install -y fonts-vlgothic fonts-ipafont fonts-ipaexfont sudo apt-get install -y fcitx-mozc } # 実行する stop_swap write_fstab write_apt_sources_list comment_out_rsyslog_conf update_system japanese # 再起動する reboot
write_apt_sources_list
jessie
でなくstretch
に置換する
comment_out_rsyslog_conf
スワップ
スワップはHDDに物理メモリの代用をさせる。Windowsでいう仮想メモリ。
Raspberry Pi 3B+は物理メモリが1GBしかない。これを補うべくスワップを2GBにする。ただしSDカードは書込上限があるため寿命が縮みやすい。スワップはHDDで利用するほうが良いと思う。
sudo leafpad /etc/dphys-swapfile
以下の100
はスワップ(仮想メモリ)のサイズが100MBであるという意味。デフォルト値である。これを2048
に変更する。
before
CONF_SWAPSIZE=100
after
CONF_SWAPSIZE=2048
sudo systemctl stop dphys-swapfile sudo systemctl start dphys-swapfile
before
$ free -h total used free shared buff/cache available Mem: 927M 700M 35M 69M 191M 122M Swap: 99M 99M 4K
after
$ free -h total used free shared buff/cache available Mem: 927M 696M 55M 74M 175M 106M Swap: 2.0G 100M 1.9G
.bashrc
自作スクリプトを起動するようにする。
sudo leafpad /home/pi/.bashrc
ファイルの末尾に以下を追記する。
# 2018-03-19 自作スクリプト呼出 . "$HOME/root/script/sh/_called/bash/bashrc.sh"
install applications
sudo apt install -y pluma sudo apt install -y gimp
テキストエディタと画像エディタ。
ブラウザ(Chromium)
設定
- メニュー→
設定
各項目を設定する。
- 起動時:
前回開いていたページを開く
- ダウンロード 保存先:
/tmp
拡張機能
拡張機能 | 説明 |
---|---|
ublock-origin | 広告ブロック |
stylus | ユーザスタイルシート |
authenticator | 二段階認証アプリ |