使用Raspberry Pi Zero W和只读文件系统升级DakBoard系列日历
Eric Brown added two great comments (the comments on my blog are always better than the content!) He said:
埃里克·布朗(Eric Brown)添加了两个很棒的评论(我博客上的评论总是比内容更好!)他说:
- You can save power & money by using an Pi Zero W instead. 您可以改用Pi Zero W节省功率和金钱。
- This is likely overkill, but I took the time to get the Pi Zero to mount the SD card read-only and do all the writes to a RAM disk. 这可能有点矫kill过正,但是我花了些时间让Pi Zero将SD卡安装为只读状态,并将所有写入操作都写入RAM磁盘。
Eric said "RPis are surprisingly sensitive to power glitches, and will often corrupt the SD card" and that "after mounting the SD read-only, my DakBoard has been running stably for months; before doing that, it corrupted the SD card within 6 weeks."
埃里克(Eric)说:“ RPis令人惊讶地对电源故障敏感,并且经常会损坏SD卡”,并且“在以只读方式安装SD之后,我的DakBoard已经稳定运行了几个月;在此之前,它已损坏SD卡6次周。”
While I haven't had any issues with my Raspberry Pis, this seemed like a fun "version 2" of the calendar to make with the kids. Worst case scenario? Now I have LCD family calendars!
尽管我的Raspberry Pi没遇到任何问题,但这似乎是与孩子们一起制作的有趣的日历“版本2”。 最坏的情况? 现在我有液晶家庭日历!
You'll recall I commented about how important the Spouse Acceptance Factor is whenever introducing new technology into the house.
您会记得我曾评论过,每当将新技术引入房屋时,“配偶接受因素”的重要性。
It has to just work. If my Spouse doesn't like the idea or find its not reliable, the SAF (Spouse Acceptance Factor) will be low and they'll want to get rid of it. All it takes is one "why isn't this working" and I'm dead in the water.
它必须工作。 如果我的配偶不喜欢这个主意或发现它不可靠,那么SAF(配偶接受因子)就会很低,他们会想要摆脱它。 只需要一个“为什么这不起作用”,我就死定了。
I checked Amazon and found a number of Raspberry Pi Zero W (W is for Wireless, important!) Kits for around US$20. You can see in the picture above how SMALL a Raspberry Pi Zero W is (with LEGO Miss Marvel for scale).
我检查了亚马逊,发现一些Raspberry Pi Zero W(W代表无线,很重要!)套件售价约20美元。 您可以在上面的图片中看到Raspberry Pi Zero W的小巧之处(乐高LEGO奇迹小姐为此而生)。
使HDMI电缆尽可能齐平 (Get the HDMI cables as flush an sanitary as possible)
If you have the cables, power supplies, and don't need the headers and extra stuff, I've seen them as low as $10. It's very important to note that a Raspberry Pi Zero W does support HDMI but it has a MINI-HDMI female connector. You'll need a mini-HDMI to HDMI adapter or a mini-HDMI to HDMI short cable.
如果您有电缆,电源,不需要接头和多余的东西,我发现它们的价格低至10美元。 请务必注意,Raspberry Pi Zero W确实支持HDMI,但它具有MINI-HDMI母接口。 您需要微型HDMI至HDMI适配器或微型HDMI至HDMI短电缆。
Here's another aside. Did you know there are a LOT of different HDMI connector orientations? Sure, you could just loop a big old 6 foot HDMI cable back there, but where's the fun in that? There are micro HDMI D1,D2,D3 that describe 90 degree and 270 degree rotations of the male. If you want to be really flush, consider a cable (for example like a C2 to A2) that is usually used in drones. This would allow you to mount the Pi Zero W flush against the back of the monitor - or even better, inside the monitor or a wooden picture frame!
这是另一个。 您知道很多不同的HDMI连接器方向吗? 当然,您可以将一根旧的6英尺长的HDMI粗线绕回那里,但是这样做的乐趣何在? 有微型HDMI D1,D2,D3,它们描述了公头的90度和270度旋转。 如果要真正平齐,请考虑通常在无人机中使用的电缆(例如,从C2到A2 )。 这样一来,您就可以将Pi Zero W齐平安装在显示器的背面,或者甚至更好地安装在显示器或木制相框内部!
在您的无线设备上获得Raspberry Pi Zero W,避免键盘和鼠标的麻烦! (Get the Raspberry Pi Zero W on your wireless and avoid the trouble of keyboards and mice!)
Pi Zero Ws are so small that they don't have a regular USB connector. There is one for power and one that is "USB OTG." If you want to connect a mouse and keyboard directly to the Zero you'll need this USB OTG Micro to Type A Cable and/or a powered USB hub.
Pi Zero Ws很小,没有常规的USB连接器。 有一种电源,一种是“ USB OTG”。 如果要将鼠标和键盘直接连接到“零”,则需要此USB OTG Micro转Type A电缆和/或有源USB集线器。
OR!
要么!
Save money and prep your Raspberry Pi Micro SD Card with SSH turned on by default and your Wireless Network enabled by default! Then you can set it up remotely as a DakBoard/MagicMirror Family Calendar.
省钱并准备好您的Raspberry Pi Micro SD卡,默认情况下启用SSH并默认启用无线网络! 然后,您可以将其远程设置为DakBoard / MagicMirror系列日历。
-
Download the Image for Raspbian Stretch. You'll want the desktop version (not Lite) because this IS a visual project, not a headless one!
下载Raspbian Stretch图片。 您将需要桌面版本(而不是精简版),因为这是一个可视项目,而不是无头的项目!
-
I recommend Etcher for burning images to SD Cards. It's free.
我建议使用Etcher将图像刻录到SD卡。 免费。
-
Raspberry Pi Zero W and a 1A+ micro USB power supply
Raspberry Pi Zero W和1A +微型USB电源
-
Cheap micro SD Card. They should include an adapter to plug it into your main computer to prepare.
便宜的micro SD卡。 它们应包括一个适配器,以将其插入主计算机以进行准备。
- Create an empty file called "ssh" on the prepared Micro SD Card before you put the card in the Raspberry Pi 在将卡放入Raspberry Pi中之前,在准备好的Micro SD卡上创建一个名为“ ssh”的空文件
- Make a file called wpa_supplicant.conf with Linux line feeds (LF, not the default Windows CR/LF) with content like this (and your own country code)使用Linux换行符(LF,而不是默认的Windows CR / LF)制作一个名为wpa_supplicant.conf的文件,其内容如下(以及您自己的国家/地区代码)
Cheap micro SD Card. They should include an adapter to plug it into your main computer to prepare.
便宜的micro SD卡。 它们应包括一个适配器,以将其插入主计算机以进行准备。
country=us
update_config=1
ctrl_interface=/var/run/wpa_supplicant
network={
scan_ssid=1
ssid="YourNetworkSSID"
psk="NETWORKPASSWORD!"
}
This will cause the Pi to get on the network on boot up which should allow you to SSH over to it directly, thereby avoiding any trouble with keyboards and mice and the Pi Zero W.
这将导致Pi在启动时进入网络,这应该允许您直接通过SSH对其进行切换,从而避免了键盘,鼠标和Pi Zero W带来的任何麻烦。
If you DO end up wanted to connect the keyboard and mouse, you'll want a keyboard/mouse setup that is all in one with just one USB adapter or you'll need a Powered USB Hub. This should be temporary as you get the Pi prepared.
如果您最终想连接键盘和鼠标,则只需要一个USB适配器就可以将键盘/鼠标设置全部集成在一起,或者需要一个有源USB集线器。 准备好Pi时,这应该是暂时的。
将Raspberry Pi Zero W设置为只读-在使用DakBoard配置它之后 (Make the Raspberry Pi Zero W readonly - after it's been configured with DakBoard)
Once I had the Pi Zero W all prepared I went around the net looking for tutorials to make it readonly. You're basically causing Linux to mount the SD Card readonly and then do all writes to a RAM Disk that will ultimately be tossed whenever you (rarely) reboot. Get it perfect before you go readonly as it's a small hassle to switch back. Or you can pull the card out and mount it on your other computer then return it. Still, not awesome.
准备好Pi Zero W之后,我便四处搜寻有关使其变为只读的教程。 基本上,您是在让Linux以只读方式挂载SD卡,然后将所有写操作写入RAM磁盘,而最终(每次)重新引导时,该磁盘都会被扔掉。 只读之前先使其完美,因为切换回去很麻烦。 或者,您可以拉出卡并将其安装在另一台计算机上,然后将其退还。 不过,还不算很棒。
Eric from the comments pointed me to a Raspberry Pi Jesse tutorial, but I tried it and it didn't work for me, likely because I'm on Raspbian Stretch, a newer version. There's a LOT of choices and ways to do this but the best tutorial I found was on the page for Domoticz, a n open source Home Automation system which looks, as an aside, awesome and something I need to check out in the future!
评论中的Eric向我介绍了Raspberry Pi Jesse教程,但我尝试了一下,但它对我不起作用,可能是因为我使用的是Raspbian Stretch(较新版本)。 有很多选择和方法,但是我找到的最好的教程是Domoticz的页面, Domoticz是一个开放源代码的家庭自动化系统,顺便说一句,它看起来很棒,我将来需要检查一下!
For now, I followed these instructions on Setting up overlayFS on Raspberry PI (the "overlay" being the file system you'll write to but it's a fake, the writes are going to one folder and the two foldkers (one read-write and one read-only are overlaid over each other). This allowed me to make a Raspberry Pi Raspbian Stretch system Readonly on my Pi Zero W.
现在,我按照这些说明在Raspberry PI上设置overlayFS (“ overlay”是您要写入的文件系统,但它是伪造的,写入到一个文件夹和两个文件夹(一个为读写文件夹,一个只读的对象会彼此重叠。)这使我可以在Pi Zero W上将Raspberry Pi Raspbian Stretch系统设为Readonly 。
I followed the instructions exactly, only skipping the parts like "Modify domoticz service" that didn't apply. When I run "mount" I can see the main file system is read-only and the others are overlaid and read-write.
我完全按照说明进行操作,只是跳过了诸如“修改domoticz服务”之类不适用的部分。 当我运行“ mount”时,我可以看到主文件系统是只读的,而其他文件系统则被覆盖并且是可读写的。
aaa@qq.com:~ $ mount
/dev/mmcblk0p7 on / type ext4 (ro,noatime,data=ordered)
snip!
ramdisk on /var_rw type tmpfs (rw,relatime)
ramdisk on /home_rw type tmpfs (rw,relatime)
overlay on /home type overlay (rw,relatime,lowerdir=/home_org,upperdir=/home_rw/upper,workdir=/home_rw/work)
overlay on /var type overlay (rw,relatime,lowerdir=/var_org,upperdir=/var_rw/upper,workdir=/var_rw/work)
So far so good! This will make a smaller and lower power Family Calendar that will hopefully be more reliable as well! Thanks Eric from the comments!
Sponsor: Preview the latest JetBrains Rider with its Assembly Explorer, Git Submodules, SQL language injections, integrated performance profiler and more advanced Unity support.
赞助商:预览最新的JetBrains Rider,包括其Assembly Explorer,Git子模块,SQL语言注入,集成的性能分析器以及更高级的Unity支持。
关于斯科特 (About Scott)
Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.
斯科特·汉塞尔曼(Scott Hanselman)是前教授,前金融首席架构师,现在是演讲者,顾问,父亲,糖尿病患者和Microsoft员工。 他是一位失败的单口相声漫画家,一个玉米种植者和一本书的作者。