Difference between revisions of "Raspberry Pi 3 - Browser Client"

From Alpine Linux
Jump to: navigation, search
(AutoLogin, Startx automatically on Boot)
Line 9: Line 9:
 
* community repo is used.
 
* community repo is used.
  
It is based off of this guide: [[Raspberry_Pi]]. Due to the dependencies required to run X and FF, there is very little RAM disk space for the user to operate in, after this tutorial is complete. Take this into consideration. It's possible that the RPI4 with its additional RAM, may fare better.
+
It is based off of this guide: [[Raspberry_Pi]]. Due to the dependencies required to run X and FF, there is very little RAM disk space for the user to operate in, after this tutorial is complete (about 30MB is v3.11). Take this into consideration. It's possible that the RPI4 with its additional RAM, may fare better.
 +
 
 +
aarch64 is used, because firefox-esr is in the community repo. armhf (as of v3.11) does not have firefox prepackaged in the base or community repo.
 +
 
 +
See https://pkgs.alpinelinux.org/packages?name=*firefox*&branch=v3.11&arch=aarch64
 +
 
 +
Note that the aarch64 build is not compatible with all RPI. See [[Raspberry Pi]].
  
 
==Steps==
 
==Steps==
 +
===Base Install===
 +
 +
These steps are duplicated from [[Raspberry_Pi]] page.
 +
 +
Use fdisk or gdisk to format the SD card. You must have the first partition
 +
be a bootable, FAT filesystem.
 +
e.g.:
 +
<pre>
 +
Command (m for help): p
 +
Disk /dev/sdb: 59.5 GiB, 63864569856 bytes, 124735488 sectors
 +
Units: sectors of 1 * 512 = 512 bytes
 +
Sector size (logical/physical): 512 bytes / 512 bytes
 +
I/O size (minimum/optimal): 512 bytes / 512 bytes
 +
Disklabel type: dos
 +
Disk identifier: 0x00000000
 +
 +
Device    Boot Start      End  Sectors Size Id Type
 +
/dev/sdb1  *    2048 62916607 62914560  30G  b W95 FAT32
 +
</pre>
 +
mkdosfs -F 32 /dev/sdX1
 +
 +
untar onto mounted disk
 +
 +
mount /dev/sdX1 /mnt/folder
 +
tar xvf archive.tar -C /mnt/folder/.
 +
 +
If you plan to enable increased RAM (e.g. for RPI4 with 2 or 4GB) or other
 +
config settings, do so in a usercfg.txt now.
 +
 +
Again, duplicating the [[Raspberry Pi]] page
 +
 +
    Insert the SD card into the Raspberry Pi and turn it on
 +
    Login into the Alpine system as root. Leave the password empty.
 +
    Type setup-alpine
 +
    Once the installation is complete, commit the changes by typing lbu commit -d
 +
 +
 +
saving space: busybox instead of chronyd, dropbear instead of openssh
 +
 +
After setup, make sure dropbear is installed
 +
apk add dropbear
 +
 +
Start it:
 +
rc-service dropbear start
 +
 +
Add it to the default runlevel:
 +
rc-update add dropbear
  
  setup-alpine
+
# if you need an accurate clock, enable software/ntp here (optional, i don't need a clock for the website I view).
 +
rc-update add swclock boot # enable the software clock
 +
rc-update del hwclock boot # disable the hardware clock
 +
  setup-ntp
  
lbu_commit -d
 
  
For X and FF:
+
===Browser Client Install===
apk add libx11-dev libxft-dev libxinerama-dev ncurses adwaita-gtk2-theme adwaita-icon-theme ttf-dejavu
+
 
<small>Note that the fonts/icon theme are required for FF to display correctly</small>
 
  
Uncomment the community repo in /etc/apk/repos.conf for firefox-esr
+
enable community repo (/etc/apk/repositories)
 +
apk update
  
  apk add firefox-esr
+
#NO NCURSES
<small>It's firefox-esr, not firefox</small>
+
  apk add libx11-dev libxft-dev libxinerama-dev adwaita-gtk2-theme adwaita-icon-theme ttf-dejavu
 +
<small>Note that the fonts/icon theme are required for FF to display correctly. Without these, firefox will load, but text will not render on the browser menus.</small>
  
Installing X:
+
the RAM tmp fs remaining can be viewed while installing, with watch df -h
setup-xorg-base
 
  
 +
next firefox
 +
apk add firefox-esr
 +
install X
 +
setup xorg-base
 
The RPI also requires for X:
 
The RPI also requires for X:
 
  apk add xf86-video-fbdev
 
  apk add xf86-video-fbdev
 +
 +
At this point, we have about 421MB used up.
 +
 +
Filesystem                Size      Used Available Use% Mounted on
 +
devtmpfs                10.0M        0    10.0M  0% /dev
 +
shm                    457.9M        0    457.9M  0% /dev/shm
 +
/dev/mmcblk0p1          30.0G    259.4M    29.7G  1% /media/mmcblk0p1
 +
tmpfs                  457.9M    420.0M    37.9M  92% /
 +
tmpfs                    91.6M    188.0K    91.4M  0% /run
 +
/dev/loop0              24.9M    24.9M        0 100% /.modloop
 +
 +
 +
lbu_commit -d
  
 
===AutoLogin, Startx automatically on Boot===
 
===AutoLogin, Startx automatically on Boot===
Line 37: Line 109:
  
 
/root/ doesn't save any files, so it's necessary to edit files in /etc/ and lbu_commit -d after all changes. First let's add a file that will call firefox.
 
/root/ doesn't save any files, so it's necessary to edit files in /etc/ and lbu_commit -d after all changes. First let's add a file that will call firefox.
 +
<small>lbu_commit is alpine local backup. If you want to save folders other than /etc see:https://wiki.alpinelinux.org/wiki/Alpine_local_backup#Include_special_files.2Ffolders_to_the_apkovl
 +
also see: /etc/apk/protected_paths.d/lbu.list</small>
  
 
create a file named /etc/startup.sh:
 
create a file named /etc/startup.sh:
Line 61: Line 135:
 
tty1::respawn:/bin/login -f root
 
tty1::respawn:/bin/login -f root
 
</pre>
 
</pre>
 +
 +
 +
That's it. Now reboot, and watch the RPI boot into firefox without user intervention. At this point, you have a functioning minimal OS booting from RAM, with firefox, and ~30MB of available space for further configuration.
 +
 +
 +
 +
==Tips/Troubleshooting==
 +
===Why was this setup used? Why not Awesome, or dwm?===
 +
It should be noted that the author ran through a few different setups of alpine on the rpi, and found that dwm + awesome required too many dependencies to run on an RPI3 with 512MB in /tmp (running in RAM), or surf browser was unstable (the application was viewing video streams). Therefore, running firefox direct off X was just barely able to fit into the available space, and was stable. This is one of the reasons aarch64 was used, instead of armhf.
 +
 +
===Width & height of firefox doesn't fit the monitor===
 +
Firefox can be called with -height and -width flags, e.g.
 +
firefox -width 480 -height 640 somewebsite.com
 +
 +
==Related Links==
 +
* [[dwm]]
 +
* [[Raspberry Pi]]

Revision as of 12:21, 20 May 2020

This is a guide for setting up a RAM based RPI3 which is able to run X, and firefox. This tutorial will go through setting up auto login for Alpine, and starting X on boot without user interaction. It is a type of kiosk machine.

This Guide is a Work-in-Progress

Overview

This guide uses the following:

  • aarch64 img
  • RPI3
  • community repo is used.

It is based off of this guide: Raspberry_Pi. Due to the dependencies required to run X and FF, there is very little RAM disk space for the user to operate in, after this tutorial is complete (about 30MB is v3.11). Take this into consideration. It's possible that the RPI4 with its additional RAM, may fare better.

aarch64 is used, because firefox-esr is in the community repo. armhf (as of v3.11) does not have firefox prepackaged in the base or community repo.

See https://pkgs.alpinelinux.org/packages?name=*firefox*&branch=v3.11&arch=aarch64

Note that the aarch64 build is not compatible with all RPI. See Raspberry Pi.

Steps

Base Install

These steps are duplicated from Raspberry_Pi page.

Use fdisk or gdisk to format the SD card. You must have the first partition be a bootable, FAT filesystem. e.g.:

Command (m for help): p
Disk /dev/sdb: 59.5 GiB, 63864569856 bytes, 124735488 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000

Device     Boot Start      End  Sectors Size Id Type
/dev/sdb1  *     2048 62916607 62914560  30G  b W95 FAT32
mkdosfs -F 32 /dev/sdX1

untar onto mounted disk

mount /dev/sdX1 /mnt/folder
tar xvf archive.tar -C /mnt/folder/.

If you plan to enable increased RAM (e.g. for RPI4 with 2 or 4GB) or other config settings, do so in a usercfg.txt now.

Again, duplicating the Raspberry Pi page

   Insert the SD card into the Raspberry Pi and turn it on
   Login into the Alpine system as root. Leave the password empty.
   Type setup-alpine
   Once the installation is complete, commit the changes by typing lbu commit -d


saving space: busybox instead of chronyd, dropbear instead of openssh

After setup, make sure dropbear is installed

apk add dropbear

Start it:

rc-service dropbear start

Add it to the default runlevel:

rc-update add dropbear
  1. if you need an accurate clock, enable software/ntp here (optional, i don't need a clock for the website I view).
rc-update add swclock boot # enable the software clock 
rc-update del hwclock boot # disable the hardware clock
setup-ntp


Browser Client Install

enable community repo (/etc/apk/repositories)

apk update
  1. NO NCURSES
apk add libx11-dev libxft-dev libxinerama-dev adwaita-gtk2-theme adwaita-icon-theme ttf-dejavu

Note that the fonts/icon theme are required for FF to display correctly. Without these, firefox will load, but text will not render on the browser menus.

the RAM tmp fs remaining can be viewed while installing, with watch df -h

next firefox

apk add firefox-esr

install X

setup xorg-base

The RPI also requires for X:

apk add xf86-video-fbdev

At this point, we have about 421MB used up.

Filesystem Size Used Available Use% Mounted on devtmpfs 10.0M 0 10.0M 0% /dev shm 457.9M 0 457.9M 0% /dev/shm /dev/mmcblk0p1 30.0G 259.4M 29.7G 1% /media/mmcblk0p1 tmpfs 457.9M 420.0M 37.9M 92% / tmpfs 91.6M 188.0K 91.4M 0% /run /dev/loop0 24.9M 24.9M 0 100% /.modloop


lbu_commit -d

AutoLogin, Startx automatically on Boot

At this point, you should be able to login as root, and run startx manually. Now, we will add a number of configuration files that allow this to happen without user interaction.

/root/ doesn't save any files, so it's necessary to edit files in /etc/ and lbu_commit -d after all changes. First let's add a file that will call firefox. lbu_commit is alpine local backup. If you want to save folders other than /etc see:https://wiki.alpinelinux.org/wiki/Alpine_local_backup#Include_special_files.2Ffolders_to_the_apkovl also see: /etc/apk/protected_paths.d/lbu.list

create a file named /etc/startup.sh:

#!/bin/ash
firefox http://somewebsite.com

We have to edit xinitrc, and the profile configs. Normally, this would be done in the user's directory, but here we will use the globals for simplicity.

mv /etc/X11/xinit/xinitrc /etc/X11/xinit/xinitrc_BAK
nano /etc/X11/xinit/xinitrc

In this file put:

/etc/startup.sh

At the end of /etc/profile (leave the existing file) append

startx

And remember to: lbu_commit -d For autologin, alpine uses busybox, which has an alias to /sbin/getty as well as /bin/login. It's possible to navigate to /sbin/ or /bin/ and run /sbin/getty -h to see what settings are available. To have root auto login upon boot, review the existing inittab and edit as needed, according to the config below.

# Set up a couple of getty's
#tty1::respawn:/sbin/getty 38400 tty1
tty2::respawn:/sbin/getty 38400 tty2
tty3::respawn:/sbin/getty 38400 tty3
tty4::respawn:/sbin/getty 38400 tty4
tty5::respawn:/sbin/getty 38400 tty5
tty6::respawn:/sbin/getty 38400 tty6

tty1::respawn:/bin/login -f root


That's it. Now reboot, and watch the RPI boot into firefox without user intervention. At this point, you have a functioning minimal OS booting from RAM, with firefox, and ~30MB of available space for further configuration.


Tips/Troubleshooting

Why was this setup used? Why not Awesome, or dwm?

It should be noted that the author ran through a few different setups of alpine on the rpi, and found that dwm + awesome required too many dependencies to run on an RPI3 with 512MB in /tmp (running in RAM), or surf browser was unstable (the application was viewing video streams). Therefore, running firefox direct off X was just barely able to fit into the available space, and was stable. This is one of the reasons aarch64 was used, instead of armhf.

Width & height of firefox doesn't fit the monitor

Firefox can be called with -height and -width flags, e.g.

firefox -width 480 -height 640 somewebsite.com

Related Links