====== Raspberry as Kiosk PC ======
===== Introduction =====
This howto describes how to install a Chromium based kiosk using minimal installation. Everything is done as the root user in this howto.
===== Installation =====
==== Raspbian Buster Lite ====
Download Raspbian Buster Lite edition at: [[https://www.raspberrypi.org/downloads/raspbian/]]
Use Etcher or whatever to install the downloaded zip on a SD card.
==== Initial settings to enable remote configuration ====
Use raspi-config to set network and change password of the pi user and change the hostname:
raspi-config
systemctl enable ssh.service
systemctl start ssh.service
[Time]
NTP=172.16.0.254
#FallbackNTP=0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org
#RootDistanceMaxSec=5
#PollIntervalMinSec=32
#PollIntervalMaxSec=2048
==== Making the system a read-only system ====
The goal is to make a Kiosk so we can disconnect the power and do no harm to the filesystem. We also want to limit SDCard wear.
apt-get update
apt-get -y upgrade
apt-get -y remove --purge triggerhappy logrotate dphys-swapfile dc nano
apt-get -y autoremove --purge
Edit the following file and add "fastboot noswap ro" to the end of the line so it looks something like this:
console=serial0,115200 console=tty1 root=PARTUUID=6c586e13-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait fastboot noswap ro
apt-get -y install busybox-syslogd
apt-get -y remove --purge rsyslog
Edit fstab so it looks something like this. Your PARTUUIDs are different!
proc /proc proc defaults 0 0
PARTUUID=6c586e13-01 /boot vfat defaults,ro 0 2
PARTUUID=6c586e13-02 / ext4 defaults,noatime,ro 0 1
tmpfs /tmp tmpfs defaults,noatime,nosuid,mode=1777,size=100m 0 0
tmpfs /var/tmp tmpfs defaults,noatime,nosuid,size=30m 0 0
tmpfs /var/log tmpfs defaults,noatime,nosuid,mode=0755,size=100m 0 0
tmpfs /var/run tmpfs defaults,noatime,nosuid,mode=0755,size=2m 0 0
tmpfs /etc/console-setup tmpfs defaults,noatime,nosuid,mode=0755,size=2m 0 0
tmpfs /var/lib/systemd/timesync tmpfs defaults,noatime,nosuid,mode=0755,size=2m 0 0
tmpfs /var/lib/lightdm tmpfs defaults,noatime,nosuid,size=30m 0 0
tmpfs /home/pi tmpfs defaults,noatime,nosuid,size=100m 0 0
rm -rf /var/lib/dhcp /var/lib/dhcpcd5 /var/spool /etc/resolv.conf
ln -s /tmp /var/lib/dhcp
ln -s /tmp /var/lib/dhcpcd5
ln -s /tmp /var/spool
touch /tmp/dhcpcd.resolv.conf
ln -s /tmp/dhcpcd.resolv.conf /etc/resolv.conf
rm /var/lib/systemd/random-seed
ln -s /tmp/random-seed /var/lib/systemd/random-seed
cp /lib/systemd/system/systemd-random-seed.service /etc/systemd/system/systemd-random-seed.service
Edit the copied service file and make the Service section look like this:
.
.
.
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStartPre=/bin/echo "" >/tmp/random-seed
ExecStart=/lib/systemd/systemd-random-seed load
ExecStop=/lib/systemd/systemd-random-seed save
TimeoutSec=30s
Because /var/spool is also a tmpfs filesystem, we need to disable that directory to become mask 0755. Copy the following file
cp /usr/lib/tmpfiles.d/var.conf /etc/tmpfiles.d
comment out the following line so it looks like this:
.
.
.
#d /var/spool 0755 - - -
==== Disable ugly boot splash and rotate screen ====
I need to rotate the screen, because I use the monitor in portrait mode. 0=normal, 1=90 degrees CW, 2=180 degrees CW, 3=90 degrees CCW, and 4=upside down. Add the following to the end of the file:
.
.
.
display_rotate=3
disable_splash=1
==== R/O and R/W aliases to make writable filesystem easy ====
Bash aliases to remount filesystem RO and RW are very convenient. Add the following at the end of the following file:
.
.
.
set_bash_prompt() {
fs_mode=$(mount | sed -n -e "s/^\/dev\/.* on \/ .*(\(r[w|o]\).*/\1/p")
PS1='\[\033[01;32m\]\u@\h${fs_mode:+($fs_mode)}\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
}
alias temp='/opt/vc/bin/vcgencmd measure_temp'
alias ro='sudo mount -o remount,ro / ; sudo mount -o remount,ro /boot'
alias rw='sudo mount -o remount,rw / ; sudo mount -o remount,rw /boot'
PROMPT_COMMAND=set_bash_prompt
Reboot the system. Login and check if the filesystems are mounted R/O
mount |grep /dev/ |grep ro
/dev/mmcblk0p2 on / type ext4 (ro,noatime)
/dev/mmcblk0p1 on /boot type vfat (ro,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro)
===== Graphical User Interface =====
Because we have a R/O filesystem now, we need to make it R/W when doing stuff.
rw
==== Install Xserver ====
apt-get -y install --no-install-recommends xserver-xorg xinit xterm x11-xserver-utils
apt-get -y install --no-install-recommends lightdm openbox unclutter
The pi user needs to be added to the tty group:
usermod -a -G tty pi
==== Chromium browser ====
Chromium supports kiosk mode, which is great for our purpose
apt-get -y install --no-install-recommends chromium-browser
==== Autostart ====
Edit the autostart script to start the browser once logged in:
xset -dpms
xset s off
xset s noblank
unclutter -idle 0 &
chromium-browser --noerrdialogs --disable-infobars --kiosk https://www.google.com &
Enable auto login to graphical desktop. Choose 3 Boot Options -> B1 Desktop / CLI -> B4 Desktop Autologin
raspi-config
Reboot! Your Pi should now start in Chromium Kiosk mode!
{{tag>linux}}