📜 ⬆️ ⬇️

Crimson Prog vs Internet Bricks, or Raspberry Pi with graphics read-only microSD

annotation


Launch Raspberry Pi with full graphics support on microSD, which remains forever in read-only mode after installing the system. The absence of any data recording on flash memory increases the reliability of the device, bringing it closer to the industrial class of products. Step-by-step instruction. A small theater of engineering absurdity to entertain the audience.


I needed an open source network device with HDMI output, and I decided to try Raspberry Prog. Yes, I just suggest translating Pi : Prog . Understandably, even a single motherboard needs an operating system. And so, I go to the official site , expecting to meet there a detailed guide to create a harsh, unbreakable Things à la turnkey box . But the people, as if nothing had happened, install Ubuntu (ie, Raspbian Jessie) right on the microSD, placing and swap there. As usual desktop, face palm.

But then flowers. Raspberry berries are projects of MalinProg photo frames that require a mandatory shutdown with a button. Otherwise, the photo frame after a power failure may not work, offering to use fsck instead of images. But this is not the limit, under the cut the reader is waiting for a real masterpiece of engineering absurdity, found by the author in the vast network.
')
So, according to the standard instructions, a normal single-board turns into a bloated desktop with an average lifetime of a year and a half until the worn out flash drive dies, turning a generally good device into a brick. And most people seem to be happy with this. Me - no.

Where the world is heading


Before opening the spoiler, put on a protective mask, or hold your head in advance with your hands.

A good project that spoiled one recommendation.
Imagine a big TV and slide show demonstrator based on RPi, but with a screensaver neutralized with a hardware (!) Mouse simulator. Say, in the Raspbian window interface, the timeout of the screensaver is not set for more than 720 minutes. Therefore, in order to not move the mouse every 12 hours manually, people automate the process with a microcontroller, creating virtual “crawls” of the USB mouse every 4 minutes. I'm not kidding, here is a real project on the RPi , there is also a link to the ECIO28P microcontroller, and the upcoming firmware is available.

Okay, I will not deny the self-utility of the hardware invader: this is a real life hack for those who have hourly pay for sitting in front of the monitor. Or, to maintain the tonus of some particularly stupid harsh industrial terminal, from which one connector for the mouse sticks out from under the anti-vandal armor (for the PS / 2 a green adapter should come up). Yes, if you squeeze a bloated desktop into a single-board computer, then in the hands of über-craftsmen this is a dangerous weapon, especially with the MK board sticking out of the connector. Immediately obvious: a person can work with his hands. But if you need an ever-on screen, there are enough heads on Linux, the residents of this resource know this very well. For guests of the portal, I still give instructions, you never know what.

Disable DPMS, screensaver and at the same time all GUI elements
, LightDM, X- DPMS /etc/lightdm/lightdm.conf:
...
xserver-command=X -s 0 -dpms -nocursor
...

-nocursor . ~/.config/lxsession/LXDE/autostart. , cron(8) 718 xscreensaver-command -deactivate ( , ;-)

: LightDM , ~/.config/lxsession/LXDE/autostart feh '@' . . .. , lxpanel, pcmanfm, xscreensaver, DPMS .

apt-get autostart, , X-, , . , .

UPD
Jaromir unclutter , . , .
Spider55 LightDM noDM. , .


— . GPIO I2C/PWM, CSI-DSI . - HDMI-, «» - , . , , . , «» , . -, . , Sauron .

, , (.. ) . : Raspberry Pi microSD read-only, - .


, SD- . , SSD- , , . microSD? , , , NAND- . , . fsck.

microSD Raspberry Pi read-only , .. ? , (). , . , . , , . , .

: - , «» .

: , , read-only, , .

: UnionFS


UnionFS . , , . , .

, «» (read-only microSD) «» , «» . microSD read-only, , . ? EXT4, , - - - , read-only. noatime , microSD. , /sys/block/mmcblk0/stat 282612 , 96, read-only? , 3000:1, 5:1. (, , )

UPD:
gattopazzo83 Flash Media Kit - ( ). 100,000 , SLC- microSD. read-only, , («» - «» ;-)


UPD:
doga, «» SD- RPi. doga mmc-utils, SD-, Raspbian . - , , , .
SD-
:
udevadm info -a -n /dev/mmcblk0

«» CID CSD, (name), (serial), (date), (hwrev, fwrev, oemid, manfid). www.sdcard.org «» (Simplified Specifications), . Part 1 Simplified, Physical Layer Simplified Specification.
stat, kernel.org. , .
- , lsmmc.c.
« » RPi SD cards Embedded Linux, .
— — , mmc-utils , .



, «» ? , 1 1970 , NTP. «» 46 , . , — .

UPD:
st1373 I2C- DS3231 ( ). : RTC ( ) Raspberry Pi.



. , , , Adobe Flash . , , «» . SquashFS . , «» read-only , .. «» , : (?) . , root, — , .


Rasbian Jessie microSD read-only, . .

DISCLAIMER
. root, sudo. , , sudo, -. , * * , ? -, 0.33, , … : , root sudo bash, .

1.

Raspbian Jessie Lite. raspi-config pi. , Debian — . .

apt-key update
apt-get update

2.

, :

apt-get install --no-install-recommends tightvncserver xtightvncviewer xserver-xorg xinit lxde-core lxappearance lightdm feh xprintidle policykit-1 busybox-syslogd ntpdate watchdog unionfs-fuse

:

dpkg --purge rsyslog
apt-get remove --purge wolfram-engine triggerhappy cron anacron logrotate dphys-swapfile fake-hwclock
apt-get autoremove --purge


tightvncserver, xtightvncviewer, xprintidle feh , .

, ** : xserver-xorg xinit lxde-core lxappearance lightdm policykit-1.

3.

raspi-config , pi. sudo, pi, pi . pu «» . (default shell) ( /usr/sbin/nologin), /usr/local/bin/pu. , SSH, . Sauron et al.

adduser --home /home/pu --shell /usr/local/bin/pu --uid 990 --gecos "RPi p-u" --gid 1000 pu
mkdir -p /home/pu/.config/lxsession/LXDE
cp -p /etc/xdg/lxsession/LXDE/desktop.conf /home/pu/.config/lxsession/LXDE/desktop.conf
touch /home/pu/.config/lxsession/LXDE/autostart
chown -R pu:pi /home/pu
sed -i 's/^#\?xserver-command=.*$/xserver-command=X -s 0 -dpms -nocursor/' /etc/lightdm/lightdm.conf
sed -i 's/^#\?autologin-user=.*$/autologin-user=pu/' /etc/lightdm/lightdm.conf

/etc/lightdm/lightdm.conf , , :

...
xserver-command=X -s 0 -dpms -nocursor
...
autologin-user=pu
...

4. ( )

Raspberry Pi 3 Model B, :

modprobe bcm2835_wdt
echo "bcm2835_wdt " | sudo tee -a /etc/modules

[Install] /lib/systemd/system/watchdog.service:

[Install]
WantedBy=multi-user.target

:

systemctl enable watchdog.service

, . , , , , , .. . watchdog(8) watchdog.conf(5)

5.

swap-, . /boot/cmdline.txt logo.nologo fastboot noswap. :

logo.nologo dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait fastboot noswap

6. Raspberry Pi read-only

, , .

, mount_unionfs - /usr/local/bin. +x (chmod 755 555). .orig .rw, ():

#!/bin/sh
DIR=$1
ROOT_MOUNT=$(awk '$2=="/" {print substr($4,1,2)}' < /etc/fstab)
if [ $ROOT_MOUNT = "rw" ]; then
	/bin/mount --bind ${DIR}.orig ${DIR}
else
	/bin/mount -t tmpfs ramdisk ${DIR}.rw
	/usr/bin/unionfs-fuse -o cow,allow_other,suid,dev,nonempty ${DIR}.rw=RW:${DIR}.orig=RO ${DIR}
fi

:

insserv -r bootlogs
insserv -r alsa-utils

rm -rf /var/lib/dhcp/
ln -s /tmp /var/lib/dhcp

/home - , /etc /var /home. UnionFS ( .orig .rw):


cp -al /etc /etc.orig
mv /var /var.orig
mv /home /home.orig
mkdir /etc.rw /var /var.rw /home /home.rw

, fstab(5)

proc            /proc           proc    defaults        0       0
/dev/mmcblk0p1  /boot           vfat    ro              0       2
/dev/mmcblk0p2  /               ext4    ro              0       1
mount_unionfs   /etc            fuse    defaults        0       0
mount_unionfs   /var            fuse    defaults        0       0
mount_unionfs   /home           fuse    defaults        0       0
none            /tmp            tmpfs   defaults        0       0

7.

, .bash_history, - .. , , (, /var.orig var).

, . , , single user root. , read-only read-write :

mount -o rw,remount /

read-only , !
-.

8.

, read-write (. ). fstab(5) , mount_unionfs, ** /var.orig ( /home.orig ). /var, , apt-get , ? apt-get . , ;)


, ( read-only) Raspberry Pi , . , , Geektimes:)

( HDMI-), , , , . Raspberry Pi , :)

, .

UPD: OverlayFS
ValdikSS OverlayFS, Linux 2014, , initramfs. art_gl : Raspbian with Read-only Root.
, Domoticz, , OverlayFS. Sauron Domoticz.


UPD: SquashFS
Vooon, Vcoderlab, av_in et al SquashFS. , «» union mount, . , SquashFS by-design read-only, .. firmware-, () , . , , . , IoT . , , SquashFS, - ? , , community- SquashFS, .. Raspberry Pi. , OpenELEC.


UPD: F2FS
nlykl F2FS aka «Flash-Friendly File System», HOWTO: Replace the micro SD card's ext4 root partition by f2fs on the Raspberry PI. DISCLAIMER: . . F2FS -.


UPD:
ilmarin77 : Network booting. . , , , , ( ) . USB-Ethernet LAN9514 0..70°C


UPD: USB-
ilmarin77 USB: How to boot from a USB Mass Storage Device on a Raspberry Pi 3. SSD, USB, , microSD, USB 2.0 (- 30-40/, ). , . , read-only microSD, SSD , . USB- , microSD, .


UPD: (watchdog)
homecreate systemd, , . . .


UPD:

?


. , - , S.M.A.R.T HDD SSD. SanDisk, , , EXTCSD. - , Linux . , , smartd(8) .

« Linux- SD- /» , , (.. uptime , 10 ). , ( sudo root):

uptime
cat /sys/block/mmcblk0/stat | awk '{printf "Uptime read: %.3fMiB (%.1f%% I/Os merged) written: %.3f MiB (%.1f%% I/Os merged)\n", $3*512/1048576, $2/$1*100, $7*512/1048576, $6/$5*100}'

, , , «» . , Meklon -, openELEC / KODI. 6 72 66. / 1:1, SquashFS ( SD- ). / 5:1 10:1, . , 10 — , .
, : 512 , , erase- . Optimizations for Cheap Flash Media Arnd Bergmann (, .) «» , .. 32, erase- 4..8. «» , 512 erase-, .. 64 , stat. 6/, microSD- .
, .



Make Raspbian System Read-Only
blog.pi3g.com/2014/04/make-raspbian-system-read-only
()

How to make RaspberryPi truly read-only, reliable and trouble-free
k3a.me/how-to-make-raspberrypi-truly-read-only-reliable-and-trouble-free
( )

Protect your Raspberry PI SD card, use Read-Only filesystem
hallard.me/raspberry-pi-read-only
( sisaenkov, , )

Stopping SD Card Corruption on Raspberry Pi’s Raspbian
ideaheap.com/2013/07/stopping-sd-card-corruption-on-a-raspberry-pi
( )

Raspberry Pi — VNC localhost
habrahabr.ru/post/212661

RTC ( ) Raspberry Pi
raspberrypi.ru/blog/598.html
( I2C- DS3231)

How to boot from a USB Mass Storage Device on a Raspberry Pi 3
www.raspberrypi.org/documentation/hardware/raspberrypi/bootmodes/msd.md

Network booting
www.raspberrypi.org/documentation/hardware/raspberrypi/bootmodes/net.md

ECIO(TM), a powerful USB programmable single chip computer based on PICmicro microcontroller technology
www.matrixtsl.com/product.php?Prod=ECIO28P

Easy Raspberry Pi Based Screensaver/Slideshow for Exhibitions/Store Front
www.instructables.com/id/Easy-Raspberry-Pi-Based-ScreensaverSlideshow-for-E
( 6)

Flash memory card design (2013)
wiki.linaro.org/WorkingGroups/KernelArchived/Projects/FlashCardSurvey
( , ? FAT; ; 2013)

Optimizing Linux with cheap flash drives, Arnd Bergmann, 2011
lwn.net/Articles/428584
( )

Optimizations for Cheap Flash Media, Arnd Bergmann, 2011
free-electrons.com/blog/elce-2011-videos
( , , )

SD Association, Simplified Specifications, Part 1 Simplified: Physical Layer Simplified Specification
www.sdcard.org/downloads/pls/index.html

Block layer statistics in /sys/block/<dev>/stat
www.kernel.org/doc/Documentation/block/stat.txt
( SD- : cat /sys/block/mmcblk0/stat uptime)

Source: https://habr.com/ru/post/400011/


All Articles