This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
doc:raspi2 [2015/04/22 01:07] stwn [Initial Configuration] minor fix |
doc:raspi2 [2015/11/14 23:30] (current) stwn [Storage] minor fix |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Raspberry Pi 2 ====== | ====== Raspberry Pi 2 ====== | ||
- | $ lscpu<code>Architecture: armv7l | + | <code>$ lscpu |
+ | Architecture: armv7l | ||
Byte Order: Little Endian | Byte Order: Little Endian | ||
CPU(s): 4 | CPU(s): 4 | ||
Line 12: | Line 13: | ||
===== Installation ===== | ===== Installation ===== | ||
- | $ sudo dd bs=4M if=2015-02-16-raspbian-wheezy.img of=/dev/sdc. | + | <code>$ sudo dd bs=4M if=2015-09-24-raspbian-jessie.img of=/dev/sdX</code> |
===== Initial Configuration ===== | ===== Initial Configuration ===== | ||
- | - $ sudo nano /boot/config.txt | + | - Edit /boot/config.txt.<code>$ sudo nano /boot/config.txt |
- | - $ tvservice -m DMT | + | disable_overscan=1 |
- | - $ sudo raspi-config. pilih Expand Filesystem, Change User Password, Internationalisation Options-Change, Timezone/Locale, Advanced Options-Hostname/Memory Split(16),SPI/I2C/Serial(disable) | + | hdmi_force_hotplug=1 |
+ | hdmi_group=2 | ||
+ | hdmi_mode=48 | ||
+ | hdmi_drive=2 | ||
+ | config_hdmi_boost=4 | ||
+ | start_x=0 | ||
+ | gpu_mem=8 | ||
+ | dtparam=spi=off | ||
+ | dtparam=i2c_arm=off | ||
+ | max_usb_current=1 # maximum current for usb</code> | ||
+ | - Run raspi-config.<code>$ sudo raspi-config</code>Please select each option that you interested in to config. | ||
+ | * Expand Filesystem. | ||
+ | * Change User Password. | ||
+ | * Boot Options: B1 Console. | ||
+ | * Internationalisation Options: Change Locale and Change Timezone. | ||
+ | * Advanced Options: A2 Hostname, A3 Memory Split, A6 SPI, A7 I2C, A8 Serial. | ||
+ | ===== Updating and Upgrading ===== | ||
+ | |||
+ | - Update packages index from official repository. <code>$ sudo apt-get update</code> | ||
+ | - Upgrade installed packages. <code>$ apt-get upgrade</code> | ||
+ | ===== Package Management ===== | ||
+ | |||
+ | - List installed packages and save it to a file. <code>$ dpkg-query --show -f '${Package}\n' > pkgs.list</code> | ||
+ | - Edit the file and let the names of packages which you want to remove in it, i.e. graphical environment, applications and friends. | ||
+ | - Run 'apt-get autoremove' to remove unneeded packages. <code>$ sudo apt-get autoremove</code> | ||
+ | - Install some packages. <code>$ sudo apt-get install screen vrms</code> | ||
+ | ===== Custom Configuration ===== | ||
+ | |||
+ | - Disable triggerhappy. <code>$ sudo systemctl disable triggerhappy</code> | ||
+ | - Edit /etc/bash.bashrc <code>$ sudo nano $HOME/.bashrc | ||
+ | PS1="\[\033[01;32m\]\u@\h\[\033[00m\]:\W \[\033[01;34m\]\A \[\033[00m\]\`if [ \$? == 0 ]; then echo \:\); else echo '\[\033[0;31m\]:('; fi\`\[\033[00m\] "</code> | ||
+ | - Disable password authentication for SSH. | ||
+ | * Generate authentication key in the machine which you want to login from, and copy the result to the Raspberry. <code>$ ssh-keygen | ||
+ | $ ssh-copy-id user@raspberry</code> | ||
+ | * Edit sshd_config and restart sshd.<code>$ sudo nano /etc/ssh/sshd_config | ||
+ | PasswordAuthentication no</code><code>$ sudo systemctl restart ssh</code> | ||
+ | |||
+ | ===== Debmirror ===== | ||
+ | |||
+ | * Install debmirror. <code>$ sudo apt-get install debmirror</code> | ||
+ | * Edit debmirror scripts. <code>$ nano debmirror-debian | ||
+ | $ nano debmirror-raspbian</code> | ||
+ | * Find the Debian and Raspbian archive keyrings on their official repositories respectively. | ||
+ | * Add Debian and Raspbian archive keyrings. <code>$ gpg --keyring debian-archive-keyring.gpg --export|gpg --no-default-keyring --keyring trustedkeys.gpg --import | ||
+ | $ gpg --keyring raspbian.public.key --export|gpg --no-default-keyring --keyring trustedkeys.gpg --import</code> | ||
+ | * List the added keys. <code>$ gpg --list-keys --with-colons</code> | ||
+ | * Test the scripts by running them. | ||
+ | * Add crontab. <code>$ nano /etc/cron.d/debmirror or /etc/crontab</code> | ||
+ | * Restart crontab service. <code>$ sudo systemctl restart cron</code> | ||
+ | ===== Storage ===== | ||
+ | |||
+ | * # mkfs.ext4 /dev/sda1 | ||
+ | * # mkdir /media/dir | ||
+ | * # mount /dev/sda1 /media/dir/ | ||
+ | * # nano /etc/fstab | ||
+ | |||
+ | ===== Cron ===== | ||
+ | |||
+ | $ sudo nano /etc/crontab | ||
+ | $ sudo service cron restart | ||
+ | |||
+ | ===== Wireless ===== | ||
- # cd /etc/network | - # cd /etc/network | ||
- # cp interfaces interfaces.orig | - # cp interfaces interfaces.orig | ||
Line 35: | Line 99: | ||
- # service networking restart | - # service networking restart | ||
- wlanup.sh | - wlanup.sh | ||
- | |||
- | ===== Updating and Upgrading ===== | ||
- | # nano /etc/apt/sources.list | ||
- | # apt-get update | ||
- | # apt-get upgrade | ||
- | |||
- | # apt-get dist-upgrade | ||
- | ===== Package Management ===== | ||
- | |||
- | # vrms | ||
- | # apt-get remove --purge [I still use firmware-realtek for TL-WN725N] | ||
- | # apt-get remove --purge firmware-atheros firmware-brcm80211 firmware-libertas firmware-ralink oracle-java8-jdk pistore wolfram-engine | ||
- | # apt-get remove --purge lxde* gnome* | ||
- | # apt-get autoremove | ||
- | # apt-get install screen | ||
- | # apt-get install mariadb-server | ||
- | ===== Custom Configuration ===== | ||
- | |||
- | # update-rc.d -f triggerhappy remove | ||
- | # update-rc.d -f thd remove | ||
- | # update-rc.d -f triggerhappy remove | ||
- | # nano /etc/ssh/sshd_config | ||
- | <code>PasswordAuthentication no</code> | ||
- | # nano /etc/bash.bashrc (PS1). I got it somewhere on the Internet. I will find the exact source.<code>PS1="\u@\h:\W \A \`if [ \$? == 0 ]; then echo \:\); else echo \:\(; fi\` "</code> | ||
- | # nano $HOME/.bashrc<code>PS1="\[\033[01;32m\]\u@\h\[\033[00m\]:\W \[\033[01;34m\]\A \[\033[00m\]\`if [ \$? == 0 ]; then echo \:\); else echo '\[\033[0;31m\]:('; fi\`\[\033[00m\] "</code> | ||
- | # nano /etc/rc.local | ||
- | $ ssh-keygen | ||
- | $ ssh-copy-id user@host | ||
- | ===== Pagekite ===== | ||
- | |||
- | $ wget -c https://pagekite.net/pk/pagekite.py | ||
- | $ chmod +x pagekite.py | ||
- | $ nano .pagekite.rc | ||
- | $ ./pagekite.py | ||
- | $ screen -S pagekite | ||
- | |||
- | When you upgrade the Raspbian to jessie, you will get an error message:<code>Traceback (most recent call last): | ||
- | File "tmp/scr/pagekite.py", line 249, in <module> | ||
- | exec __FILES[".SELF/sockschain/__init__.py"] in sys.modules["sockschain"].__dict__ | ||
- | File "<string>", line 130, in <module> | ||
- | File "<string>", line 132, in SSL | ||
- | AttributeError: 'module' object has no attribute 'PROTOCOL_SSLv3'</code>Install python-openssl | ||
- | |||
- | * Error<code>debug2: ssh_connect: needpriv 0 | ||
- | debug1: Connecting to somesite.pagekite.me [XXX.YYY.ZZZ.22] port 22. | ||
- | debug1: Connection established. | ||
- | debug1: SELinux support disabled | ||
- | debug1: key_load_public: No such file or directory | ||
- | debug1: identity file /home/stwn/.ssh/id_rsa type -1 | ||
- | debug1: key_load_public: No such file or directory | ||
- | debug1: identity file /home/stwn/.ssh/id_rsa-cert type -1 | ||
- | debug1: key_load_public: No such file or directory | ||
- | debug1: identity file /home/stwn/.ssh/id_dsa type -1 | ||
- | debug1: key_load_public: No such file or directory | ||
- | debug1: identity file /home/stwn/.ssh/id_dsa-cert type -1 | ||
- | debug1: key_load_public: No such file or directory | ||
- | debug1: identity file /home/stwn/.ssh/id_ecdsa type -1 | ||
- | debug1: key_load_public: No such file or directory | ||
- | debug1: identity file /home/stwn/.ssh/id_ecdsa-cert type -1 | ||
- | debug1: key_load_public: No such file or directory | ||
- | debug1: identity file /home/stwn/.ssh/id_ed25519 type -1 | ||
- | debug1: key_load_public: No such file or directory | ||
- | debug1: identity file /home/stwn/.ssh/id_ed25519-cert type -1 | ||
- | debug1: Enabling compatibility mode for protocol 2.0 | ||
- | debug1: Local version string SSH-2.0-OpenSSH_6.7p1 Debian-3 | ||
- | ssh_exchange_identification: Connection closed by remote host</code> | ||
- | * Debug with /usr/sbin/sshd -ddd -p 22 and try to connect to it. | ||
- | * Install corkscrew and add .ssh/config:<code>Host *.pagekite.me | ||
- | CheckHostIP no | ||
- | ProxyCommand /usr/bin/corkscrew %h 443 %h %p</code> | ||
- | * prun.sh | ||
- | |||
- | ===== Syncthing ===== | ||
- | |||
- | $ wget -c https://github.com/syncthing/syncthing/releases/download/v0.10.29/syncthing-linux-arm-v0.10.29.tar.gz | ||
- | $ wget -c https://github.com/syncthing/syncthing/releases/download/v0.10.29/sha1sum.txt.asc | ||
- | $ cat sha1sum.txt.asc |grep arm | ||
- | $ sha1sum syncthing-linux-arm-v0.10.29.tar.gz > syncthing-linux-arm-v0.10.29.tar.gz.sha1 | ||
- | $ tar zxvf syncthing-linux-arm-v0.10.29.tar.gz | ||
- | $ mv syncthing-linux-arm-v0.10.29 syncthing | ||
- | $ syncthing/syncthing | ||
- | $ cd .config/syncthing/ | ||
- | $ nano config.xml | ||
- | $ screen -S syncthing | ||
- | |||
- | ===== Debmirror ===== | ||
- | |||
- | * $ sudo apt-get install debmirror | ||
- | * $ nano debmirror-jessie | ||
- | * You can find the Debian and Raspbian archive keyrings on their official repository respectively | ||
- | * $ gpg --keyring debian-archive-keyring.gpg --export|gpg --no-default-keyring --keyring trustedkeys.gpg --import | ||
- | * $ gpg --keyring raspbian.public.key --export|gpg --no-default-keyring --keyring trustedkeys.gpg --import | ||
- | * $ debmirror-raspbian | ||
- | * $ nano /etc/cron.d/debmirror or /etc/crontab | ||
- | * $ sudo systemctl restart cron.service | ||
- | * $ sudo systemctl disable bla.service | ||
- | ===== Storage ===== | ||
- | |||
- | # mkfs.ext4 /dev/sda1 | ||
- | # mkdir /media/dir | ||
- | # mount /dev/sda1 /media/dir/ | ||
- | # nano /etc/fstab | ||
- | |||
- | ===== Cron ===== | ||
- | |||
- | $ sudo nano /etc/crontab | ||
- | $ sudo service cron restart | ||
===== Lighttpd ===== | ===== Lighttpd ===== | ||
Line 154: | Line 111: | ||
* lighty-enable-mod fastcgi | * lighty-enable-mod fastcgi | ||
* lighty-enable-mod fastcgi-php | * lighty-enable-mod fastcgi-php | ||
+ | * lighty-enable-mod mod-rewrite | ||
+ | * lighty-enable-mod accesslog | ||
+ | * <code>server.modules = ( | ||
+ | ... | ||
+ | "mod_rewrite", | ||
+ | ... | ||
+ | ) | ||
+ | ... | ||
+ | $HTTP["host"] == "stwn.duniasemu.org" { | ||
+ | server.document-root = "/home/user/public_html/" | ||
+ | } | ||
+ | </code> | ||
===== Managed DNS ===== | ===== Managed DNS ===== | ||
- Change nameservers in your domain panel | - Change nameservers in your domain panel |