Use the Kiosk howto to install a R/O Kiosk. Magic Mirror software runs from the home directory of the user and can only be R/W. I used a USB SSD connected to the USB3 port of the Raspberry Pie 4.
Make a partition on the USB disk and format it as EXT4. Then use blkid to see PARTUID:
blkid /dev/mmcblk0p1: LABEL_FATBOOT="boot" LABEL="boot" UUID="5203-DB74" TYPE="vfat" PARTUUID="6c586e13-01" /dev/mmcblk0p2: LABEL="rootfs" UUID="2ab3f8e1-7dc6-43f5-b0db-dd5759d51d4e" TYPE="ext4" PARTUUID="6c586e13-02" /dev/sda1: UUID="2f7dbca4-e910-4517-b70a-efad86e0b8d3" TYPE="ext4" PARTUUID="b3a803bf-01"
In this case the PARTUUID of /dev/sda1 is b3a803bf-01. Change /etc/fstab to look something like this:
proc /proc proc defaults 0 0 PARTUUID=6c586e13-01 /boot vfat defaults,ro 0 2 PARTUUID=6c586e13-02 / ext4 defaults,noatime,ro 0 1 PARTUUID=b3a803bf-01 /home ext4 defaults,noatime 0 0 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
Reboot and see if /home is mounted. Create a directory for the user pi
mkdir /home/pi chmod 700 /home/pi chown pi. /home/pi
Now we are going to undo the changes of the system wide autostart and put them in the homedir of the pi user. Make it look like it was:
# # These things are run when an Openbox X Session is started. # You may place a similar script in $HOME/.config/openbox/autostart # to run user-specific things. # # If you want to use GNOME config tools... # #if test -x /usr/lib/arm-linux-gnueabihf/gnome-settings-daemon >/dev/null; then # /usr/lib/arm-linux-gnueabihf/gnome-settings-daemon & #elif which gnome-settings-daemon >/dev/null 2>&1; then # gnome-settings-daemon & #fi # If you want to use XFCE config tools... # #xfce-mcs-manager &
Now create the autostart file for the pi user as the pi user
cd ~ mkdir -p .config/openbox
xset -dpms xset s off xset s noblank unclutter -idle 0 & xrandr --output HDMI-1 --rotate left &
Rotate the graphical interface does not seem to work on a Pi 4. As you can see we are using xrandr to rotate. Rotation of the console must be disabled and the GL driver must be enabled. Use raspi-config to change to GL driver: 7 Advanced Options → A8 GL driver → G2 GL (Fake KMS)
Then change /boot/config.txt to remove rotate screen
. . . [pi4] # Enable DRM VC4 V3D driver on top of the dispmanx display stack dtoverlay=vc4-fkms-v3d max_framebuffers=2 [all] dtoverlay=vc4-fkms-v3d #display_rotate=3 disable_splash=1
The console messages will be in unrotated format which is ugly. Disable all console logging:
console=serial0,115200 console=tty3 root=PARTUUID=6c586e13-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait fastboot noswap ro logo.nologo quiet loglevel=3 vt.global_cursor_default=0
We are going to use the recommended manual way:
We must be the pi user
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get -y install git nodejs libnss3 libxtst-dev libxss-dev
cd ~ git clone https://github.com/MichMich/MagicMirror cd MagicMirror/ npm install npm audit fix npm install electron@6.0.12
Now copy the sample config in place:
cd ~/MagicMirror/config cp config.js.sample config.js
Install PM2 process manager
sudo npm install -g pm2 pm2 startup
The startup command creates a commandline we need to execute to create a systemd service. Execute it. In our case:
sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u pi --hp /home/pi
Create a little script in homedir of pi with name mm.sh
cd ~/MagicMirror DISPLAY=:0 npm start
chmod +x mm.sh
bash -c "$(curl -sL https://raw.githubusercontent.com/sdetweil/MagicMirror_scripts/master/fixuppm2.sh)"
Reboot and enjoy