# How to Build a Chromium-Based Kiosk

# Installing a Debian Machine

[![Bootstrapping a Debian Machine](https://img.shields.io/badge/Bootstrapping_a_Debian_Machine-4F46E5?style=flat-square)](/books/debian-guides/page/bootstrapping-a-debian-machine)
[![Protecting GRUB with a Password](https://img.shields.io/badge/Protecting_GRUB_with_a_Password-4F46E5?style=flat-square)](/books/debian-guides/page/protecting-grub-with-a-password)

Installation
-------------

```shell
sudo apt install cage chromium kanshi
```

```shell
sudo useradd  -d "/var/lib/chromium" --create-home --groups input,render,video --shell /usr/sbin/nologin --system chromium
```

```shell
sudo tee "/etc/systemd/system/wl-chromium.service" >/dev/null <<'EOF'
[Unit]
Description=Wayland Kiosk (Chromium)
Conflicts=getty@tty1.service
After=getty@tty1.service

[Service]
Type=simple
User=chromium
Group=chromium
PAMName=login
TTYPath=/dev/tty1
TTYReset=yes
TTYVHangup=yes
TTYVTDisallocate=yes
StandardInput=tty
StandardOutput=journal
StandardError=journal
UtmpIdentifier=tty1
UtmpMode=user

EnvironmentFile=/etc/default/chromium
Environment=XDG_SESSION_TYPE=wayland

ExecStartPre=/usr/bin/mkdir -p $XDG_RUNTIME_DIR/chromium-cache
ExecStart=/usr/bin/cage -- /usr/bin/chromium --disk-cache-dir=$XDG_RUNTIME_DIR/chromium-cache --disk-cache-size=1073741824 $CHROMIUM_OPTS

Restart=always
RestartSec=2

[Install]
WantedBy=graphical.target
EOF
```

```shell
sudo tee "/etc/default/chromium" >/dev/null <<'EOF'
CHROMIUM_OPTS="--ozone-platform=wayland --no-first-run --noerrdialogs --kiosk --disable-session-crashed-bubble --disable-infobars --overscroll-history-navigation=0 --disable-pinch http://127.0.0.1/"
EOF
```

```shell
sudo tee "/etc/systemd/system/kanshi.service" >/dev/null <<'EOF'
[Unit]
Description=Wayland Output Management
After=wl-chromium.service
Requires=wl-chromium.service
PartOf=wl-chromium.service

[Service]
Type=simple
User=chromium
Group=chromium
PAMName=login

ExecStartPre=/bin/sleep 2
ExecStart=/usr/bin/kanshi

Restart=on-failure
RestartSec=2

[Install]
WantedBy=graphical.target
EOF
```

```shell
sudo systemctl daemon-reload
sudo systemctl disable --now getty@tty1.service
sudo systemctl enable --now wl-chromium.service
sudo systemctl enable --now kanshi.service
```

Configuration
--------------

#### Minimize System Verbosity

```shell file="/etc/default/grub"
GRUB_TIMEOUT=1
GRUB_CMDLINE_LINUX_DEFAULT="quiet loglevel=3 consoleblank=0"
```

```shell
sudo update-grub
```

Troubleshooting
----------------

#### Video Playback is Not Working

```shell
sudo apt install intel-media-va-driver vainfo
```

Debugging
-----------

```shell
sudo apt install evtest libinput-tools python3-evdev
```

# Hosting Web Content Locally

Installation
-------------

```shell
sudo apt install nginx
```

# Minimizing Disk Writes

Make Journal Storage Volatile
------------------------------

```shell file="/etc/systemd/journal.conf"
[Journal]
Storage=volatile
RuntimeMaxUse=256M
Compress=yes
ForwardToSyslog=no
```

Mount options - noatime
------------------------

```shell file="/etc/fstab"
UUID=xxxx  /  ext4  errors=remount-ro,noatime  0  1
```

Disable Coredump
-----------------
```shell file="/etc/systemd/coredump.conf"
[Coredump]
Storage=none
```

Disable services
-----------------

```shell
sudo systemctl disable --now man-db.timer
sudo systemctl disable --now apt-daily.timer apt-daily-upgrade.timer
```

Watch What Writes to Disk
--------------------------

```shell
sudo iotop -o -a
```