Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save yeokm1/2331dfebf92fba03ed9f to your computer and use it in GitHub Desktop.
Save yeokm1/2331dfebf92fba03ed9f to your computer and use it in GitHub Desktop.
Use Octoprint on Arch Linux ARM with read-only file system for Raspberry Pi

I wanted Octoprint (a 3D-printer management software) to start up fast without the bloatness of using Raspbian. I also regularly forgot to shutdown the Raspberry Pi hosting Octoprint properly leading to file system corruption and unbootable SD card.

This set of instructions should provide all that is needed to use Octoprint without fear of improper shutdown with Arch Linux ARM by using a read-only file system.

This instructions does not have the webcam setup as I didn't intend to use it. If you wish to use the webcam, please consult and try to port the official Raspbian FAQ.

##Instructions

  1. Convert the Arch Linux ARM file system to read-only. Please follow the instructions from my previous gist. The following instructions assume you are logged into with the root account.

  2. Install dependencies and download Octoprint

./writeenable.sh
pacman -Syu python2 python2-setuptools python2-pip python2-virtualenv git gcc libyaml
git clone https://github.com/foosel/OctoPrint.git
cd OctoPrint
virtualenv2 --system-site-packages venv
./venv/bin/python2 setup.py install
mkdir ~/.octoprint
  1. Setup config.yaml

To prevent writes to the file system, all these directories including the uploaded gcode files have been shifted to the /tmp which is in the RAM disk. This means you will lose those files on reboot. There is a price to pay for using a read-only file system eh...

nano ~/.octoprint/config.yaml

#Enter the following into the file up to before #end
folder:
  logs: /tmp
  timelapse: /tmp
  timelapse_tmp: /tmp
  uploads: /tmp
system:
  actions:
  - name: Shutdown
    command: poweroff
    action: shutdown
    confirm: You are about to shutdown the system.
  - name: Reboot
    command: reboot
    action: reboot
    confirm: You are about to reboot the system
  - name: Enable FS Write
    command: ~/writeenable.sh
    action: writeenable
    confirm: You are about to enable writes to the file system. You must reboot properly or enable read-only before unsafe poweroff if not file system corruption may happen.
  - name: Enable read-only FS
    command: ~/readonly.sh
    action: readonly
    confirm: You are about to relock the file system to read-only. Subsequent changes will be lost on reboot.
    devel:
webassets:
  bundle: false
  minify: false
#end
  1. Run Octoprint to check if everything as been installed correctly
/root/OctoPrint/venv/bin/octoprint --port=80 --iknowwhatimdoing

Open your web browser and navigate to the IP address of your Raspberry Pi. It is your choice whether to configure access control. Connect to your printer. Save your printer's serial port settings.

Once you reboot, the file system will be set to readonly. However, you can use the system buttons "Enable FS Write" and "Enable read-only FS" to adjust the file system status temporarily.

  1. Start Octoprint on boot

We use a systemd service file

nano /etc/systemd/system/octo.service
#Enter the following up to before the #end
[Unit]
Description=To start Octoprint on startup
After=network-online.target

[Install]
WantedBy=multi-user.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/root/OctoPrint/venv/bin/octoprint --port=80 --iknowwhatimdoing
#end

systemctl enable octo.service
  1. Wifi setup with static IP address (Optional)

I prefer to set a static IP so I can easily navigate back to the webpage

pacman -S wpa_supplicant
cp /etc/netctl/examples/wireless-wpa-static /etc/netctl/wlan0-ssid
nano /etc/netctl/wlan0-ssid
#Configure this file with your wifi settings

netctl enable wlan0-ssid
  1. Reboot the system and test
reboot

Anytime you wish to change the Octoprint settings, you will have to unlock the file system first. If you have followed my read-only gist, you can use the writeenable.sh and readonly.sh shell scripts to accomplish this task. Remember to relock back once you are done.

@mil
Copy link

mil commented Aug 1, 2015

@yeokm1 thanks for this simple guide. Works almost flawlessly.. Only problem I found was that I needed to set in ~/.octoprint/config.yaml:

devel:
  webassets:
    bundle: false
    minify: false

In order for Octoprint to not try and build compiled web assets to .octoprint/.build which can't happen with a ro filesystem.

@yeokm1
Copy link
Author

yeokm1 commented Jan 28, 2016

ok, thanks for the feedback! I have updated the gist

@zbrozek
Copy link

zbrozek commented Dec 14, 2017

It'd be nice to work out how to run as a non-root user. I haven't sorted out GPIO access yet, but it's working otherwise.

Edit: udev rules seem to be the way to go:
https://stackoverflow.com/questions/30938991/access-gpio-sys-class-gpio-as-non-root

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment