2

I am trying to figure out if I can make a program bootup on linux, like a light switch. Power on and off at will. So, if the program is running, I can shut it off whenever I want, but, so that files won't corrupt when I do so. Kind of like those computers in cars nowadays. They can turn the computers on and off whenever the car is turned on or turned off at will. How, can I go about doing that with Linux?

VoyagerLinuxGamer
  • 123
  • 2
  • 3
  • 14

1 Answers1

2

Try to design your program to be stateless - read from sensors, receive data from network ports, write to serial ports and/or to network connections, etc, without writing to hard disks/flash memory. You could have read-only access to a configuration file, that is fine.

If this is not possible use journalling file system (i.e. ext4) and mount it with options sync,journal=data. This will do more writes to the storage media but will ensure consistency - if the power goes out in the middle of a write your program will see either the old version of the file or the new one. You would also need to add some checkpoint/restart functionality to your program.

Another advice: keep your files closed. Whenever you need to store something do open, seek, write, close.

A bit more information about what are you trying to achieve would be usefull..

sмurf
  • 4,680
  • I am trying to make a custom Operating System. If you have seen Knight Rider, (the old version), where he has a screen in his dashboard, I have a LibreOffice Impress (like powerpoint) that will hopefully automatically open, and go to the operating system. If you know how to make a Bootable PowerPoint project, then please tell me. That would help alot. If I did not give better/more information, than what you stated will work. – VoyagerLinuxGamer Aug 11 '15 at 17:03
  • What you are asking is outside the scope of the normal Ubuntu use. You would need to replace GDM (the Graphical Logon manager) with LibreOffice Impress and pass the file name of your presentation as a parameter. Not impossible but involves messing with init scripts which is somewhat advanced and can render your computer unbootable. Good luck! – sмurf Aug 12 '15 at 04:22