Raspberry Pi Boot Options

From Wiki
Jump to navigationJump to search

Prevent resizing on boot

Mount the SD card's partition 1 somewhere. Edit cmdline.txt and remove the following:

init=/usr/lib/raspi-config/init_resize.sh

List packages I installed

zgrep -h ' install ' /var/log/dpkg.log* | sort | awk '{print $4}'

Install nodejs

Raspian comes with nodejs 0.10.29, which is freakin' archaic. This installs a version from this century.

cd ~
sudo apt-get remove --purge npm node nodejs
wget https://nodejs.org/dist/v6.11.1/node-v6.11.1-linux-armv6l.tar.xz
cd /usr/local
sudo tar xf ~/node-v6.11.1-linux-armv6l.tar.xz --strip=1
cd ~

Switch between WiFi AP and client modes

Requires that dnsmasq and hostapd be installed

apt-get -q -q update && apt-get install dnsmasq hostapd

/home/<x>/wifi_mode

#!/bin/bash

case "$1" in
  ap)
    sudo cp /etc/network/interfaces.ap /etc/network/interfaces
    sudo systemctl disable wpa_supplicant.service
    sudo systemctl enable dnsmasq.service
    sudo systemctl enable hostapd.service
    sudo shutdown -r now
    ;;
  client)
    sudo cp /etc/network/interfaces.client /etc/network/interfaces
    sudo systemctl disable hostapd.service
    sudo systemctl disable dnsmasq.service
    sudo systemctl enable wpa_supplicant.service
    sudo shutdown -r now
    ;;
  *)
    echo "Usage: wifi_mode {ap|client}"
    exit 1
    ;;
esac

exit 0

/etc/network/interfaces.ap

auto lo

iface lo inet loopback

allow-hotplug wlan0
iface wlan0 inet static
  address 192.168.0.1
  netmask 255.255.255.0
  network 192.168.0.0

/etc/network/interfaces.client

auto lo

iface lo inet loopback

allow-hotplug wlan0
iface wlan0 inet dhcp
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

/etc/wpa_supplicant/wpa_supplicant.conf

country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
        ssid="My Favorite SSID"
        psk="I Won't Tell You"
}

/etc/hostapd/hostapd.conf

interface=wlan0
driver=nl80211
ssid=MyVisibleAP
hw_mode=g
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=MySecretPassword
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP