41
35

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

RaspberryPi: raspi-config コマンドラインから設定(ノンイタラクティブ)

Last updated at Posted at 2016-07-29

概要

  • raspi-configに、nonintをつけると、Non-Interactiveモードになって、スクリプト中の関数が呼べる.
  • 主にget_xxx系(現在の設定取得)とdo_xxx系(設定・実行)
  • 自動設定とかするのに、いいんじゃない?

  • 再起動の要求をされないので、設定後は、再起動したほうがいいかも。
  1. GPUメモリ、カメラの設定

    • カメラを使用の設定をすると、gpu_memが128に増やされる。
    実行例1-カメラ0=On/1=Off

pi@raspberrypi:~$ sudo raspi-config nonint do_memory_split 16
pi@raspberrypi:~$ cat /boot/config.txt | grep -i gpu
gpu_mem=16
pi@raspberrypi:~$ sudo raspi-config nonint do_camera 0
pi@raspberrypi:~$ cat /boot/config.txt | grep -i gpu
gpu_mem=128
pi@raspberrypi:~$


2. I2Cの設定

    ```shell-session:実行例2-I2c__0=On/1=Off
pi@raspberrypi:~$ sudo raspi-config nonint do_i2c 0
pi@raspberrypi:~$ cat /boot/config.txt | grep i2c
dtparam=i2c_arm=on
pi@raspberrypi:~$ sudo raspi-config nonint do_i2c 1
pi@raspberrypi:~$ cat /boot/config.txt | grep i2c
dtparam=i2c_arm=off
pi@raspberrypi:~$ 
  1. ホスト名の変更: sudo raspi-config nonint do_hostname <新しいhostname>

    実行例3

pi@raspberrypi:~$ sudo raspi-config nonint do_hostname raspberrypi
pi@raspberrypi:~$ cat /etc/hostname
raspberrypi
pi@raspberrypi:~$ cat /etc/hosts | grep raspberrypi
127.0.1.1 raspberrypi
pi@raspberrypi:~$ sudo raspi-config nonint do_hostname rpi_new_hostname
pi@raspberrypi:~$ cat /etc/hostname
rpi_new_hostname
pi@raspberrypi:~$ cat /etc/hosts | grep rpi_
127.0.1.1 rpi_new_hostname
pi@raspberrypi:~$



3. wifiの国設定

    ```shell-session:GB=>JP=>US=>GBとやってみる。
pi@raspberrypi:~$ sudo cat /etc/wpa_supplicant/wpa_supplicant.conf
country=GB
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
pi@raspberrypi:~$ sudo raspi-config nonint do_wifi_country JP
pi@raspberrypi:~$ sudo cat /etc/wpa_supplicant/wpa_supplicant.conf
country=JP
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
pi@raspberrypi:~$ sudo raspi-config nonint do_wifi_country US
pi@raspberrypi:~$ sudo cat /etc/wpa_supplicant/wpa_supplicant.conf
country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
pi@raspberrypi:~$ sudo raspi-config nonint do_wifi_country GB
pi@raspberrypi:~$ sudo cat /etc/wpa_supplicant/wpa_supplicant.conf
country=GB
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
pi@raspberrypi:~$ 
  1. タイムゾーンの設定 (追記:2018-0420) @miminashiさんより

    タイムゾーンをEurope/Amsterdamに設定してみる

pi@raspberrypi:~ $ ls /usr/share/zoneinfo/ # タイムゾーンの一覧はここ
Africa CET Etc Greenwich Japan Navajo PST8PDT US
America Chile Europe Hongkong Kwajalein NZ right UTC
Antarctica CST6CDT Factory HST leap-seconds.list NZ-CHAT ROC WET
Arctic Cuba GB Iceland Libya Pacific ROK W-SU
Asia EET GB-Eire Indian localtime Poland Singapore zone1970.tab
Atlantic Egypt GMT Iran MET Portugal SystemV zone.tab
Australia Eire GMT0 iso3166.tab Mexico posix Turkey Zulu
Brazil EST GMT-0 Israel MST posixrules UCT
Canada EST5EDT GMT+0 Jamaica MST7MDT PRC Universal
pi@raspberrypi:~ $ sudo raspi-config nonint do_change_timezone Europe/Amsterdam
Current default time zone: 'Europe/Amsterdam'
Local time is now: Fri Apr 20 11:41:33 CEST 2018.
Universal Time is now: Fri Apr 20 09:41:33 UTC 2018.



## 一覧

- 2016年7月29日の`raspi-config`

|項目1|項目2|エントリー名|get_系|do_系|オプションなど|
|:-:|:-:|:--|:--|:--|:--|
|1|  |Expand Filesystem            ||`do_expand_rootfs`||Ensures that all of the SD card storage is available to the OS       |
|2|  |Change User Password         ||`do_change_pass`|インタラクティブに聞かれる|Change password for the default user (pi)                            |
|3|  |Boot Options                 ||下記を使用||Choose whether to boot into a desktop environment or the command line|
| |B1|Console           ||`do_boot_behaviour B1`||Text console, requiring user to login                                           |
| |B2|Console Autologin ||`do_boot_behaviour B2`||Text console, automatically logged in as 'pi' user                              |
| |B3|Desktop           ||`do_boot_behaviour B3`||Desktop GUI, requiring user to login                                            |
| |B4|Desktop Autologin ||`do_boot_behaviour B4`||Desktop GUI, automatically logged in as 'pi' user                               |
|4|  |Wait for Network at Boot     ||`do_boot_wait`|0:Yes/1:No|Choose whether to wait for network connection during boot            |
|5|  |Internationalisation Options ||||Set up language and regional settings to match your location         |
| |I1|Change Locale          ||`do_change_locale`|`dpkg-reconfigure locales`が実行される|Set up language and regional settings to match your location               |
| |I2|Change Timezone        ||`do_change_timezone`|`dpkg-reconfigure tzdata`が実行される|Set up timezone to match your location                                     |
| |I3|Change Keyboard Layout ||`do_configure_keyboard`|`dpkg-reconfigure keyboard-configuration`が実行される|Set the keyboard layout to match your keyboard                             |
| |I4|Change Wi-fi Country   |`get_wifi_country`|`do_wifi_country`|GB(default)/JP(日本)/US(米国)など|Set the legal channels used in your country                                |
|6|  |Enable Camera                |`get_camera`|`do_camera`|0:Yes/1:No|Enable this Pi to work with the Raspberry Pi Camera                  |
|7|  |Add to Rastrack              ||`do_rastrack`|Menuが出てくる|Add this Pi to the online Raspberry Pi Map (Rastrack)                |
|8|  |Overclock                    ||`do_overclock`|None/Modest/Medium/High/Turbo<br>nonintだとチェックがスキップされるので注意|Configure overclocking for your Pi                                   |
|9|  |Advanced Options             |||Configure advanced settings                                          |
| |A1|Overscan     |`get_overscan`|`do_overscan`|0:Yes/1:No|You may need to configure overscan if black bars are present on display              |
| |A2|Hostname     |`get_hostname`|`do_hostname`|<ホスト名>|Set the visible name for this Pi on a network                                        |
| |A3|Memory Split ||`do_memory_split`|16/32/64/128/256|Change the amount of memory made available to the GPU                                | 
| |A4|SSH          |`get_ssh`|`do_ssh`|?? 1:Yes/0:No|Enable/Disable remote command line access to your Pi using SSH                       |
| |A5|SPI          |`get_spi`|`do_spi`|0:Yes/1:No|Enable/Disable automatic loading of SPI kernel module (needed for e.g. PiFace)       |    
| |A6|I2C          |`get_i2c`|`do_i2c`|0:Yes/1:No|Enable/Disable automatic loading of I2C kernel module                                |
| |A7|Serial       |`get_serial`|`do_serial`|0:Yes/1:No|Enable/Disable shell and kernel messages on the serial connection                    |
| |A8|Audio        ||`do_audio`|Menuが出てくる|Force audio out through HDMI or 3.5mm jack                                           |
| |A9|1-Wire       |`get_onewire`|`do_onewire`|0:Yes/1:No|Enable/Disable one-wire interface                                                    |
| |AA|GPIO Server  |`get_rgpio`|`do_rgpio`|0:Yes/1:No|Enable/Disable remote access to GPIO pins                                            |
| |AB|GL Driver    |`get_gldriver`|`do_gldriver`|0:Yes/1:No|Enable/Disable experimental desktop GL driver                                        |    
| |A0|Update       ||`do_update`||Update this tool to the latest version                                               |
|0|  |About raspi-config           ||`do_about`||Information about this configuration tool                            |


- (確認)
    - Yes/Noが 0/1, 1/0があるっぽい? (sshは1/0, カメラとか0/1)
    - インターナショナル設定は、インタラクティブになってしまう。が、NOOBSでは、`/boot/os_config.json`というファイルで自動に設定している?


<!-- メモ
|1|  |Expand Filesystem            |Ensures that all of the SD card storage is available to the OS       |
|2|  |Change User Password         |Change password for the default user (pi)                            |
|3|  |Boot Options                 |Choose whether to boot into a desktop environment or the command line|
| |B1|Console           |Text console, requiring user to login                                           |
| |B2|Console Autologin |Text console, automatically logged in as 'pi' user                              |
| |B3|Desktop           |Desktop GUI, requiring user to login                                            |
| |B4|Desktop Autologin |Desktop GUI, automatically logged in as 'pi' user                               |
|4|  |Wait for Network at Boot     |Choose whether to wait for network connection during boot            |
|5|  |Internationalisation Options |Set up language and regional settings to match your location         |
| |I1|Change Locale          |Set up language and regional settings to match your location               |
| |I2|Change Timezone        |Set up timezone to match your location                                     |
| |I3|Change Keyboard Layout |Set the keyboard layout to match your keyboard                             |
| |I4|Change Wi-fi Country   |Set the legal channels used in your country                                |
|6|  |Enable Camera                |Enable this Pi to work with the Raspberry Pi Camera                  |
|7|  |Add to Rastrack              |Add this Pi to the online Raspberry Pi Map (Rastrack)                |
|8|  |Overclock                    |Configure overclocking for your Pi                                   |
|9|  |Advanced Options             |Configure advanced settings                                          |
| |A1|Overscan     |You may need to configure overscan if black bars are present on display              |
| |A2|Hostname     |Set the visible name for this Pi on a network                                        |
| |A3|Memory Split |Change the amount of memory made available to the GPU                                | 
| |A4|SSH          |Enable/Disable remote command line access to your Pi using SSH                       |
| |A5|SPI          |Enable/Disable automatic loading of SPI kernel module (needed for e.g. PiFace)       |    
| |A6|I2C          |Enable/Disable automatic loading of I2C kernel module                                |
| |A7|Serial       |Enable/Disable shell and kernel messages on the serial connection                    |
| |A8|Audio        |Force audio out through HDMI or 3.5mm jack                                           |
| |A9|1-Wire       |Enable/Disable one-wire interface                                                    |
| |AA|GPIO Server  |Enable/Disable remote access to GPIO pins                                            |
| |AB|GL Driver    |Enable/Disable experimental desktop GL driver                                        |    
| |A0|Update       |Update this tool to the latest version                                               |
|0|  |About raspi-config           |Information about this configuration tool                            |
-->
41
35
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
41
35

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?