如何将你的树莓派变成强大的云办公设备 How to make your Raspberry Pi a powerful edge device to WFH

As we know, Raspberry Pi is getting even more popular with its cheap cost and highly customized functions. Now the most powerful Raspberry Pi 4B model has 4GB memory and quad-A72 cores. This is even better than my first smartphone in 2015. As the coronavirus has deeply reformed our daily lives, it is time to buy a raspberry pi, to work from home. I have spent some time finding useful tools and writing scripts to help me study in the dorm conveniently and elegantly.

Reasons Why Raspberry 4B

  • Its hardware is rather outstanding.
  • It supports two 4K monitors.
  • As Apple turns to using arm on their macbook, there will be much more available softwares in this ecosystem.

Before Booting

You should prepare the boot image and image burning tool, and a SD card. Now the raspberry has officially published two OS (called raspberry Pi OS), for 32 bit and 64 bit respectively. I recommend using the latest 64bit. Although it is a beta version, it should have higher performance (see evaluation here: https://medium.com/@matteocroce/why-you-should-run-a-64-bit-os-on-your-raspberry-pi4-bd5290d48947). Also the ARM ISA it uses has a nice backward compatibility, i.e., we can simultaneously install and execute 32bit and 64bit under the aarch64 ISA.

Raspberry Pi OS 64bit introduction: https://www.raspberrypi.org/forums/viewtopic.php?t=275370
Latest download link: https://downloads.raspberrypi.org/raspios_arm64/images/
Installation guide: https://qengineering.eu/install-raspberry-64-os.html
Use the official tool to burn the image to your SD card: https://www.raspberrypi.org/downloads/

Remote Control

The most critical function should be connecting to a remote laptop. So I do not have to carry it between my dormitory and working place. There are many candidate softwares here but I choose VNC as my option, since VNC has a specialized arm build for raspberry. The GUI is friendly. And it is free for personal use.

First of all, download a VNC Server on your laptop: https://www.realvnc.com/en/connect/download/vnc/

And download the client (called VNCViewer) on your raspberry: https://www.realvnc.com/en/connect/download/viewer/. You can also check other interesting builds like Chrome and iOS apps. But I have not tried them yet.

Set an account and password. And now you should connect with your laptop or any other devices.

Proxy

Although the raspberry OS has chromium as its default web browser, we can not directly synchronize my personal preferences (favorites, extensions, passwords and form autofills, etc) due to the-reason-we-know. I choose electron-ssr to bypass the GFW and synchronize my remote google accounts, because it has a beautiful GUI and supports subscription links. Unfortunately the original source repo does not provide an arm build. So what? we can build it from source. First do apt update and apt install npm. Then in the source repo, npm install and npm build. The author does not provide a correct package description. We need to manually modify it at the middle of installation. I have successfully built one.

Electron-ssr back-up repo: https://github.com/qingshuisiyuan/electron-ssr-backup/

Another approach is to use the existing proxy on your remote laptop. After knowing the network topology from your laptop at the working place to your raspberry in your dorm, it is possible you set the http_proxy environment on your raspberry and the traffic would route to your laptop. I am currently trying this method.

Programming

It is exciting news that VSCode just published the 1.50 version, along with official arm/arm64 build. Now we do not need VSCode-OSS (a third-party built software, based on the public VSCode source repo) anymore. With the remote extensions, we can elegantly connect to a server and write our code in the dormitory.

VSCode arm64 download page: https://code.visualstudio.com/docs/?dv=linuxarm64_deb

Sharing Files

Files on the Server

I need to read papers everyday. It is possible that we can download papers in my dorm and update any comments and modifications to another place without launching the cumbersome VNC server. I recommend to use sshfs, which is a filesystem implemented in user mode. It is slower than regular NFS but it does not require a sudo privilege to setup in the server.

on your client (i.e., your raspberry), do sudo apt install sshfs and sshfs <remote-path> <local-mount-point> -o <ssh-options>, e.g., sshfs congou-1:/scorpio/xxx/ ~/serverfile. Strangely umount needs sudo privileges. But it is fine since we do those completely on the client side. Now you can retrieve those files and install a PDF viewer program (e.g., the popular okular) to view those papers.

Files on Your Laptop

My files are synchronized by iCloud and Google Cloud simultaneously. Luckily we can install the iCloud client for linux: sudo apt install snapd and sudo snap install icloud-for-linux. But on my raspberry, the GUI would not start. I will update the part after I can use it.

Conclusion

With the powerful hardware and rapidly growing software supports, raspberry pi should be of more general use. Recently RIOS is announcing another similar hardware based on RISCV. If arm is not open anymore, who is our next choice?

---以上---