7

In order to protect the SD card in an application which may suffer a sudden loss of power I am attempting to mount the root in read-only mode.

In the working (read-write) system our full-screen application gets launched by the automatic X log-in executing an LXDE auto-start script.

I've got the system running, mostly, by the previously suggested /etc/fstab table:

proc /proc proc defaults 0 0 /dev/mmcblk0p1 /boot vfat defaults 0 2 /dev/mmcblk0p2 / ext4 defaults,noatime 0 1 tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0 tmpfs /var/log tmpfs defaults,noatime,mode=0755 0 0 tmpfs /var/lock tmpfs defaults,noatime,mode=0755 0 0 

My problem lies in getting the X application up and running. LXDE complains about not being able to create an .xauthority file. So I added the following kludge (note the access mode!):

tmpfs /var/lib/lightdm tmpfs defaults,noatime,mode=1777 0 0 

Unfortunately the auto-start still does not work, leaving me staring at the lightdm-greeter screen. Attempting to actually log in swiftly returns me to the same prompt, and curiously the logs seem to be silent about what the failure might be.

My next attempt was to forgo the window manager entirely through a custom .xsession or .xinitrc. While this works when manually executing startx it does not log on automatically for the pi user. I fear my attempts to fiddle with the global /etc/X11/xinit/xinitrc also met with little success.

The next idea was to replace the default lightdm-greeter script by linking to the auto-start script in /usr/share/xgreeters and editing /ect/ligthdm/ligthdm.conf with alternate greeter-user and greeter-session settings. This fails with a "Greeter closed communication channel" message. Presumably there is a protocol of some sort which a proper greeter is expected to implement.

Any suggestions? I suspecft this is child's play to anyone with actual experience of Unix administration but it's got me bashing my head against a wall.

2
  • 1
    have you succeeded? Commented Jun 17, 2013 at 19:26
  • No, I have to admit that I didn't. I eventually just gave up and ran the system with a read-write file system. Now I'm just wondering how long it will take before I receive the first error report of a crashed system.. Commented Jun 28, 2013 at 15:09

3 Answers 3

2

I did several things. It autostarts with the account kiosk

 cat /home/kiosk/kioskstartup #!/bin/sh xset -dpms xset s off unclutter & matchbox-window-manager -use_cursor no -use_titlebar no & midori -e Fullscreen -a http://127.0.0.1:4079/index.html cat /home/kiosk/.profile # ~/.profile: executed by the command interpreter for login shells. # This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login # exists. # see /usr/share/doc/bash/examples/startup-files for examples. # the files are located in the bash-doc package. # the default umask is set in /etc/profile; for setting the umask # for ssh logins, install and configure the libpam-umask package. #umask 022 # if running bash if [ -n "$BASH_VERSION" ]; then # include .bashrc if it exists if [ -f "$HOME/.bashrc" ]; then . "$HOME/.bashrc" fi fi # set PATH so it includes user's private bin if it exists if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$PATH" fi xinit ./kioskstartup cat /usr/share/xsessions/matchbox.desktop [Desktop Entry] Encoding=UTF-8 Name=Matchbox Comment=This session logs you into Matchbox Exec=matchbox-session Terminal=False Icon= Type=Application 

In addition to that, I modified the affected startup scripts so they weren't writing to /var, and instead created /tmp directories and put data there...

 chmod 777 /tmp/run fi if [ ! -d /tmp/cache ] then mkdir /tmp/cache chmod 777 /tmp/cache fi if [ ! -d /tmp/cache/lighttpd ] then mkdir /tmp/cache/lighttpd chmod 777 /tmp/cache/lighttpd fi if [ ! -d /tmp/log ] then mkdir /tmp/log chmod 777 /tmp/log fi if [ ! -d /tmp/log/lighttpd ] then mkdir /tmp/log/lighttpd chmod 777 /tmp/log/lighttpd fi PATH=/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/sbin/lighttpd NAME=lighttpd DESC="web server" PIDFILE=/tmp/run/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME DAEMON_OPTS="-f /etc/lighttpd/lighttpd.conf" test -x $DAEMON || exit 0 set -e check_syntax() { $DAEMON -t $DAEMON_OPTS > /dev/null || exit $? } if [ "$1" != status ]; then # be sure there is a /tmp/run/lighttpd, even with tmpfs # The directory is defined as volatile and may thus be non-existing # after a boot (DPM §9.3.2) if ! dpkg-statoverride --list /tmp/run/lighttpd >/dev/null 2>&1; then install -d -o www-data -g www-data -m 0750 "/tmp/run/lighttpd" fi fi . /lib/lsb/init-functions case "$1" in start) check_syntax log_daemon_msg "Starting $DESC" $NAME if ! start-stop-daemon --start --oknodo --quiet \ --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_OPTS then log_end_msg 1 else log_end_msg 0 fi ;; stop) log_daemon_msg "Stopping $DESC" $NAME if start-stop-daemon --stop --retry 30 --oknodo --quiet \ --pidfile $PIDFILE --exec $DAEMON then rm -f $PIDFILE log_end_msg 0 else log_end_msg 1 fi ;; reload|force-reload) check_syntax log_daemon_msg "Reloading $DESC configuration" $NAME if start-stop-daemon --stop --signal INT --quiet \ --pidfile $PIDFILE --exec $DAEMON then rm $PIDFILE if start-stop-daemon --start --quiet \ --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_OPTS ; then log_end_msg 0 else log_end_msg 1 fi else log_end_msg 1 fi ;; reopen-logs) log_daemon_msg "Reopening $DESC logs" $NAME if start-stop-daemon --stop --signal HUP --oknodo --quiet \ --pidfile $PIDFILE --exec $DAEMON then log_end_msg 0 else log_end_msg 1 fi ;; restart) check_syntax $0 stop $0 start ;; status) status_of_proc -p "$PIDFILE" "$DAEMON" lighttpd && exit 0 || exit $? ;; *) echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload|status}" >&2 exit 1 ;; esac exit 0 

Last thing, I totally got rid of LXDE and went to the window manger above. I used lighttpd instead of monkey as web server because it supports aliases properly. My browser is midori.

This config needs a little bit of work, but it does work!

0

Try to sudo chmod 777 /tmp and also /var too if something else fails.

In my case it was the only extra thing needed to do.

0

One thing which is important to understand is that the filesystem doesn't get corrupt from being rw at the time of a crash. It gets corrupt because of an unfinished write operation at the time of a crash. If no write operation is in progress, your rw filesystem is as safe as an ro one.

So I suggest you leave your filesystem rw, enable journalling and stop worrying about it. If the only write operation that still remains is creating the .xauthority file at boot time, chances that a crash will happen exactly at that moment are already pretty slim, and even in that case journalling will most probably handle the issue without you even noticing it.

Personal anecdote:

I have an SBC running headless (not exactly your case, but still) which is used as a wireless router. My mom which is obsessive about electricity pulls the plug every evening and plugs it back in the morning. The root filesystem is rw, yet the thing has been running for months now without any issues.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.