Raspberry Pi Wi-Fi extender

From eLinux.org
Revision as of 14:14, 8 August 2018 by Geertivp (talk | contribs) (How to create a Wi-Fi AP with just a Raspberry Pi3+)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

You only need (only) a Raspberry Pi 3B+ (to benefit from 5 GHz Wi-Fi).

The Raspberry Pi 3 would only give you 2.4 GHz Wi-Fi… for other models you need an extra Wi-Fi USB dongle…

We use a running Raspberry Pi (any model) to create a new Raspbian system disk. We use a new micro-SD card in an USB card reader (because the main SD slot is used by the running system). We could have also used any other Linux system.

Download the software

We do not want to use local temporary storage to avoid SD card wearout, so we only use streaming straight from the download server onto the SD-card.

Note that the ZIP directory structure is at the end of the archive; so we use zcat for unzipping a single image file. In this way the (internal ZIP) directory is ignored…

Verify the SD card device name

dmesg |tail
[370837.817910] usb-storage 1-1.3:1.0: USB Mass Storage device detected
[370837.818341] scsi host0: usb-storage 1-1.3:1.0
[370838.864431] scsi 0:0:0:0: Direct-Access     Generic  STORAGE DEVICE   1404 PQ: 0 ANSI: 6
[370838.865373] sd 0:0:0:0: Attached scsi generic sg0 type 0
[370839.000182] sd 0:0:0:0: [sda] 15523840 512-byte logical blocks: (7.95 GB/7.40 GiB)
[370839.001302] sd 0:0:0:0: [sda] Write Protect is off
[370839.001314] sd 0:0:0:0: [sda] Mode Sense: 21 00 00 00
[370839.002430] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[370839.018260]  sda: sda1
[370839.022472] sd 0:0:0:0: [sda] Attached SCSI removable disk

Fast installation of Rasbian on SD card.

Please change sdx to the real device… caveat for data loss… you can overwrite any connected device on your system.

It takes about 15 minutes to install the OS image:

time wget -qO- https://downloads.raspberrypi.org/raspbian_latest |zcat |dd bs=8M of=/dev/sdx
gzip: stdin: invalid compressed data--length error

0+106220 records in
0+106220 records out
4823449600 bytes (4.8 GB, 4.5 GiB) copied, 830.671 s, 5.8 MB/s

real    13m50.686s
user    3m24.739s
sys     0m53.884s

(you can ignore the error message; related to the ignored internal ZIP directory)

Strictly zcat is gunzip -c but it can unzip zip files as well… gunzip can currently decompress files created by gzip, zip, compress, compress -H, and pack.

Make sure you flush the disk I/O cache:


Configure the new system

mount /dev/sda1 /mnt/sda1
mount /dev/sda2 /mnt/sda2
cd /mnt/sda1
cat cmdline.txt
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=bd98648d-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet init=/usr/lib/raspi-config/init_resize.sh splash plymouth.ignore-serial-consoles
rcsdiff -u config.txt |grep ^\+
RCS file: RCS/config.txt,v
retrieving revision 1.1
diff -u -r1.1 config.txt
+++ config.txt  2018/08/08 16:50:04
cat issue.txt
Raspberry Pi reference 2018-06-27
Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, 0d34fb94398a4bd79711f21d6a0b5d35fe5f4a76, stage5
cd /mnt/sda2/etc
cat fstab
proc            /proc           proc    defaults          0       0
PARTUUID=bd98648d-01  /boot           vfat    defaults          0       2
PARTUUID=bd98648d-02  /               ext4    defaults,noatime  0       1
/dev/sda1: LABEL="boot" UUID="6228-7918" TYPE="vfat" PARTUUID="bd98648d-01"
/dev/sda2: LABEL="rootfs" UUID="6bfc8851-cf63-4362-abf1-045dda421aad" TYPE="ext4" PARTUUID="bd98648d-02"

Iptables configuration

vi rc.local
iptables-restore < /etc/sysconfig/iptables
mkdir sysconfig
cp /etc/sysconfig/iptables iptables/

Configure the network

cd network
vi interfaces
auto lo br0
iface lo inet loopback

iface default inet dhcp
#iface eth0 inet manual

#allow-hotplug wlan0
#iface wlan0 inet manual
#   wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

#allow-hotplug wlan1
#iface wlan1 inet manual
#    wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

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

allow-hotplug usb0
iface usb0 inet dhcp

#iface eth0 inet dhcp

iface eth1 inet dhcp

#iface br0 inet dhcp
#       bridge_ports eth0

iface br0 inet dhcp
        bridge_ports eth0

First boot

[    8.123986] sysrq: SysRq : Resetting
[    8.130186] CPU3: stopping
[    8.135696] CPU1: stopping
[    8.141229] CPU2: stopping

Change the password!

cat /boot/cmdline.txt
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=5a874da8-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles

You can see that the disk partition has been expanded.

Update the Operating system

The initial installation disk is already obsolete, so upgrade your new installation.

apt update
apt full-upgrade
sudo raspi-config
Localisation Options
Change Locale: en_US.UTF-8 UTF-8
Change Timezone: Europe/Brussels

Interfacing Options
sudo rc_gui
(rc_gui:1361): Gtk-WARNING **: cannot open display:

You need a graphical terminal...

Install and configure hostapd

apt install ntp rcs bridge-utils hostapd
vi /etc/ntp.conf
touch /etc/hostapd/hostapd.deny
vi /etc/hostapd/hostapd.conf



wmm_enabled=1         # QoS support


ieee80211ac=1         # 802.11ac support


basic_rates=180 240 360 480 540



(change ssid and wpa_passphrase)

vi /etc/default/hostapd
vi /etc/bash.bashrc
shopt -u checkwinsize

export LINES=40 COLUMNS=132 TERM=ansi
vi /etc/fstab
tmpfs           /tmp            tmpfs   defaults        0 0
uname -a > /a-raspberry-thomas-wifi


Raspbian GNU/Linux 9 raspberrypi ttyS0
raspberrypi login: pi
Last login: Wed Jun 27 01:24:14 UTC 2018 on ttyS0
Linux raspberrypi 4.14.52-v7+ #1123 SMP Wed Jun 27 17:35:49 BST 2018 armv7l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
df -h |sort
/dev/mmcblk0p1   43M   22M   21M  52% /boot
/dev/root       7.2G  4.1G  2.8G  60% /
devtmpfs        434M     0  434M   0% /dev
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           438M     0  438M   0% /dev/shm
tmpfs           438M     0  438M   0% /sys/fs/cgroup
tmpfs           438M   12M  427M   3% /run
tmpfs           438M  4.0K  438M   1% /tmp
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs            88M     0   88M   0% /run/user/1000
              total        used        free      shared  buff/cache   available
Mem:         896672      102124      586260       12760      208288      731100
Swap:        102396           0      102396
ntpq -p

Wi-Fi speed

  • Up to 120 Mbit/s in 5 GHz band with 40 MHz bandwidth in ac mode.
  • Ethernet port supports up to 300 Mbit/s

Internet links