angus1024
Posts: 15
Joined: Thu May 10, 2018 6:10 am

Headless sdcard shutdown power off

Mon Jun 11, 2018 7:11 am

I run rpi 3b headless with 'feh' for a slideshow so cannot run 'shutdown' when we switchoff power at night. The SD card has not yet been undamaged.

Presumably the risk is that the raspbian OS writes to an sd card at the time the power is removed ?

Is there a version of raspbian that never writes to the sd card after startup (perhaps writes to ram instead) please ?

Thanks

angus1024

fred44nl
Posts: 292
Joined: Sat Jun 25, 2016 11:59 am
Location: Scharendijke, NL

Re: Headless sdcard shutdown power off

Mon Jun 11, 2018 8:23 am

if you connect to your RPi with SSH, you could give a shutdown command from there.
most operating systems will write back the info and data they have in cache.
headless RPi 3B running from usbhdd.

User avatar
Z80 Refugee
Posts: 358
Joined: Sun Feb 09, 2014 1:53 pm

Re: Headless sdcard shutdown power off

Mon Jun 11, 2018 8:47 am

angus1024 wrote:
Mon Jun 11, 2018 7:11 am
The SD card has not yet been undamaged.
Presumably you meant the opposite.
Military and Automotive Electronics Design Engineer (retired)

For the best service: make your thread title properly descriptive, and put all relevant details in the first post (including links - don't make us search)!

hippy
Posts: 8929
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Headless sdcard shutdown power off

Mon Jun 11, 2018 10:33 am

angus1024 wrote:
Mon Jun 11, 2018 7:11 am
Is there a version of raspbian that never writes to the sd card after startup (perhaps writes to ram instead) please ?
I don't know about Raspbian but PiCore appears intended to do exactly that.

alphanumeric
Posts: 2788
Joined: Tue Jan 19, 2016 2:17 pm
Location: Sydney, Nova Scotia, Canada

Re: Headless sdcard shutdown power off

Mon Jun 11, 2018 12:12 pm

I have several Pi's I run headless. I have a button wired to a GPIO pin to do the shutdown via a python script. Then I just wait for the act LED to stop blinking and kill the power.

angus1024
Posts: 15
Joined: Thu May 10, 2018 6:10 am

Re: Headless sdcard shutdown power off

Mon Jun 11, 2018 12:55 pm

Thank you everyone .

PiCore appears to be 'the bees knees'. I had not heard of this before. Presumably it will run 'feh' and I can mount a USB with the data on it. Thank you.

I wonder - if one reads data from a USB flashdrive and powers it off without unmounting - could that damage it? It may be that reading data from a usb involves rewriting it?

User avatar
Z80 Refugee
Posts: 358
Joined: Sun Feb 09, 2014 1:53 pm

Re: Headless sdcard shutdown power off

Mon Jun 11, 2018 1:30 pm

The risk is that a write operation (rather than a read operation) is not completed if you just unplug it hot without unmounting first. If doing a controlled shut-down, unmounting is not necessary.
Military and Automotive Electronics Design Engineer (retired)

For the best service: make your thread title properly descriptive, and put all relevant details in the first post (including links - don't make us search)!

pfletch101
Posts: 633
Joined: Sat Feb 24, 2018 4:09 am
Location: Buffalo, NY, USA

Re: Headless sdcard shutdown power off

Mon Jun 11, 2018 2:02 pm

angus1024 wrote:
Mon Jun 11, 2018 7:11 am
I run rpi 3b headless with 'feh' for a slideshow so cannot run 'shutdown' when we switchoff power at night. The SD card has not yet been undamaged.
If 'when we switch off power at night' is a predictable time, you can always create a cron job to shut down the Pi shortly before you turn the power off.

angus1024
Posts: 15
Joined: Thu May 10, 2018 6:10 am

Re: Headless sdcard shutdown power off

Mon Jun 11, 2018 2:10 pm

cron - good idea - thanks.

It used to be that a memory read erases the information , then it writes it back. Dont know if this is still the case.

epoch1970
Posts: 5914
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Headless sdcard shutdown power off

Mon Jun 11, 2018 4:10 pm

PiCore (tiny core linux) is a very smart OS indeed. It uses ramfs and squashfs, making it quite robust and stateless. It works about like this:
1 - Kernel is found on boot medium, loaded along with a skeleton root file system in RAM,
2 - User area of boot medium is mounted read-only,
3 - User-defined packages, e.g. feh.tcz (I don't know if the package exists) are read and expanded into loop devices in RAM
4 - Loop devices are mounted over the root filesystem to populate it.
You can save to the loop device, but unless you commit the loop device to the package on the boot medium (with filetool.sh), your changes are lost upon reboot. It's a bit like containers before containers were invented.
With a system like that, it is quite unlikely/unlucky to actually kill an SD or corrupt the filesystem when cutting power to a Pi.

You can make the system almost bulletproof (except during boot, saves) by using option "copy2fs". With copy2fs, step 2 becomes:
2a - User area of boot medium is mounted read-only, copied to RAM
2b - Boot medium is unmounted
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

angus1024
Posts: 15
Joined: Thu May 10, 2018 6:10 am

Re: Headless sdcard shutdown power off

Mon Jun 11, 2018 5:13 pm

Thank you very much - this is new to me (especially Loop devices - just looked up in wikepedia). What imagine I want to do is somehow define a directory in ram (gparted ?) , copy a few .jpg files from usb into this directory and point feh to this directory.

Need to skill myself up in linux - I wrote my first script in 1968 and strill know nothing !

angus1024

User avatar
thagrol
Posts: 4040
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Headless sdcard shutdown power off

Mon Jun 11, 2018 7:07 pm

IF you have nothing that writes to the SD card, this might be worth a look: https://learn.adafruit.com/read-only-raspberry-pi
Arguing with strangers on the internet since 1993.

epoch1970
Posts: 5914
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Headless sdcard shutdown power off

Mon Jun 11, 2018 7:15 pm

Should be simpler than that.
- Download and burn piCore 9.0.3 to an SD
- Setup the Pi with a local console, boot
- Follow the directions in the Readme file and start browsing the tinycore forum. There are some TCL/piCore users here too, I think.

It looks like feh got the boot by piCore 8.x, I spotted a thread where the response was "install ImageMagick instead".
In general it is not difficult to create a custom package (.tcz) if you need to. You can install gcc and all other utils required to compile from source,
and existing tcz packages can be opened/created with unsquashfs/mksquashfs.

Once you have your application ready to work, what I would probably do it simply copy the image files to the home directory of user "tc" (default user under piCore). Then a swift call to filetool.sh should backup the files to archive.tgz. Archive.tgz is always auto-expanded at boot to populate tc's homedir.
I would put there any script necessary to control the display program, too. Then you'd need to add a call to your script in /opt/bootlocal.sh, and the program would start at boot.

Overall piCore is a bit strange at start, but its simplicity is refreshing.
HTH
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

angus1024
Posts: 15
Joined: Thu May 10, 2018 6:10 am

Re: Headless sdcard shutdown power off

Tue Jun 12, 2018 5:59 am

Thanks. It will be a few days before I attempt this.

I need be able to easily change the content (set of slideshow .jpg ) so it be reading a USB flashdrive - perhaps at each powerOn.

Return to “Beginners”