Cruisers Forum
 


Reply
  This discussion is proudly sponsored by:
Please support our sponsors and let them know you heard about their products on Cruisers Forums. Advertise Here
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 29-05-2019, 11:08   #1
Registered User

Join Date: Jun 2015
Boat: Chantier duu Port Rézé les Nantes, Mopélia 2000
Posts: 90
opencpn.conf length is Zero byte !

My config : openCPN in OpenPlotter, on a RPi 3 model B+ (same on RPi 3 model B)


The issue : frequently, (1 time out of 10 or 20), the opencpn.conf file gets corrupted, its content disappear (zero byte).



It seems that when running a shutdown, the system is stopped before opencpn could save its configuration. This occurs with a frequency high enougn to make the promotion of opencpn difficult !
It happens even if the openCPN was stopped (CTRL+Q) before the shutdown!


I could arrange a walk around avoiding the need to reconfigure all options one by one, but it is still laborious, and not so elegant ! In view of this issue, many have said they wouldn't even try to use openCPN ...
Didier B is offline   Reply With Quote
Old 29-05-2019, 11:16   #2
Registered User

Join Date: Feb 2010
Location: Tierra del Fuego
Boat: Phantom 19
Posts: 6,207
Re: opencpn.conf length is Zero byte !

This has nothing to do with OpenCPN. The issue of filesystem corruption caused by incorrectly shutting down the system without flushing the in-memory filesystem caches to the storage was discussed some time ago, feel free to use the search function of this forum, you will also find some scripts to work it around in the respective thread.
nohal is offline   Reply With Quote
Old 29-05-2019, 17:07   #3
Registered User
 
rgleason's Avatar

Join Date: Mar 2012
Location: Boston, MA
Boat: 1981 Bristol 32 Sloop
Posts: 17,620
Images: 2
Re: opencpn.conf length is Zero byte !

Didier,
See [LennartG] Lennart Gilander solution and suggestions!

https://opencpn.org/wiki/dokuwiki/do...linux_shutdown
rgleason is offline   Reply With Quote
Old 29-05-2019, 19:08   #4
Registered User

Join Date: Feb 2010
Location: Tierra del Fuego
Boat: Phantom 19
Posts: 6,207
Re: opencpn.conf length is Zero byte !

Quote:
Originally Posted by rgleason View Post
Didier,
See [LennartG] Lennart Gilander solution and suggestions!

https://opencpn.org/wiki/dokuwiki/do...linux_shutdown
I'm sorry to say that, but your link has nothing to do with this.
nohal is offline   Reply With Quote
Old 29-05-2019, 20:19   #5
Registered User
 
rgleason's Avatar

Join Date: Mar 2012
Location: Boston, MA
Boat: 1981 Bristol 32 Sloop
Posts: 17,620
Images: 2
Re: opencpn.conf length is Zero byte !

So sorry
rgleason is offline   Reply With Quote
Old 30-05-2019, 00:11   #6
Registered User

Join Date: Jun 2015
Boat: Chantier duu Port Rézé les Nantes, Mopélia 2000
Posts: 90
Re: opencpn.conf length is Zero byte !

Quote:
Originally Posted by rgleason View Post
Didier,
See [LennartG] Lennart Gilander solution and suggestions!

https://opencpn.org/wiki/dokuwiki/do...linux_shutdown

Thank you for your interesting suggestion. I think a warning should be displayed to inform Linux users they MUST close OpenCPN before closing Linux !
Didier B is offline   Reply With Quote
Old 30-05-2019, 01:08   #7
Registered User

Join Date: Jul 2010
Location: Hannover - Germany
Boat: Amel Sharki
Posts: 2,541
Re: opencpn.conf length is Zero byte !

Quote:
Originally Posted by Didier B View Post
Thank you for your interesting suggestion. I think a warning should be displayed to inform Linux users they MUST close OpenCPN before closing Linux !
Obviously a design bug of Linux.
E.g. when I write something with LibreOffice, don't save it, don't stop LibreOffice and then shut down Linux I get no warning. Only when starting Linux again and starting LibreOffice again also I get this message:





So Linux should send signals to open programs to inform them about the coming shut down and waiting of any actions of open programs. I don't know if any Linux version do that. Ubuntu 18.04 does not as I have seen.
CarCode is offline   Reply With Quote
Old 30-05-2019, 01:35   #8
Registered User

Join Date: Feb 2010
Location: Tierra del Fuego
Boat: Phantom 19
Posts: 6,207
Re: opencpn.conf length is Zero byte !

Quote:
Originally Posted by CarCode View Post
Obviously a design bug of Linux.
E.g. when I write something with LibreOffice, don't save it, don't stop LibreOffice and then shut down Linux I get no warning. Only when starting Linux again and starting LibreOffice again also I get this message:





So Linux should send signals to open programs to inform them about the coming shut down and waiting of any actions of open programs. I don't know if any Linux version do that. Ubuntu 18.04 does not as I have seen.
What you say is not true, all the running processes on Linux of course do get the TERM signal in this situation. Exactly the same as they do on macOS.
In case of OpenCPN that signal is correctly handled and the program is shut down gracefully.
What happens here is that the distribution used by the user has incorrectly implemented the shutdown procedure and cuts the power before "Linux" writes the caches to the extremely slow SD card storage used on the Raspberry PI.
nohal is offline   Reply With Quote
Old 30-05-2019, 03:36   #9
Registered User

Join Date: Jul 2010
Location: Hannover - Germany
Boat: Amel Sharki
Posts: 2,541
Re: opencpn.conf length is Zero byte !

Quote:
Originally Posted by nohal View Post
What you say is not true, all the running processes on Linux of course do get the TERM signal in this situation. Exactly the same as they do on macOS.
In case of OpenCPN that signal is correctly handled and the program is shut down gracefully.
What happens here is that the distribution used by the user has incorrectly implemented the shutdown procedure and cuts the power before "Linux" writes the caches to the extremely slow SD card storage used on the Raspberry PI.
You may want to explain why there is no message when I shut down Ubuntu during a still open LibreOffice with unsafed files. That is exactly not the same as macOS.
CarCode is offline   Reply With Quote
Old 30-05-2019, 03:43   #10
Registered User

Join Date: Feb 2010
Location: Tierra del Fuego
Boat: Phantom 19
Posts: 6,207
Re: opencpn.conf length is Zero byte !

Quote:
Originally Posted by CarCode View Post
You may want to explain why there is no message when I shut down Ubuntu during a still open LibreOffice with unsafed files. That is exactly not the same as macOS.
Because the state is saved automatically and the user interaction happens on the next start. And why is this implementation detail different between the two operating systems? Because, unlike on macOS where it is implemented like that, on Linux the OS is not waiting indefinitely for the application to handle the TERM signal with user input. It of course changes nothing on the fact the application gets the TERM signal and has the opportunity to shut down gracefully in both cases.
Some other doubts I might help you with?
nohal is offline   Reply With Quote
Old 30-05-2019, 06:18   #11
Registered User

Join Date: Jul 2010
Location: Hannover - Germany
Boat: Amel Sharki
Posts: 2,541
Re: opencpn.conf length is Zero byte !

Quote:
Originally Posted by nohal View Post
It of course changes nothing on the fact the application gets the TERM signal and has the opportunity to shut down gracefully in both cases.
I'm not a Linux fan and I dislike the fact that for all the different Linux derivates and versions someone always need new program versions to install. Seems to be the main reason this OS has not widespread.

But if OpenCPN receives a TERM signal as you said why it doesn't save its configs?
CarCode is offline   Reply With Quote
Old 30-05-2019, 06:33   #12
Registered User
 
transmitterdan's Avatar

Join Date: Oct 2011
Boat: Valiant 42
Posts: 6,008
Re: opencpn.conf length is Zero byte !

Gerhars,

OpenCPN does save it’s configuration. But the OS is “optimized” for operating from a micro-SD card. So it has massive cache buffers that it only writes to the actual card when it has to. It can take long time to write a few hundred megabytes of cache out. So if the user does not wait for that to happen during shutdown then the SD card file system can get corrupted.

For Raspberry Pi it’s best to power it from never ending power source and don’t shut it down a lot. When shutting it down don’t assume that when the screen goes dark the shutdown process is finished. It is not. Wait until the green LED flashes many (10 I think) which signals that the cache has been flushed. Then wait a while longer before removing power.

A Pi is not a Mac obviously. It costs €25. Not surprising it has some quirks as compared to a Mac.
transmitterdan is offline   Reply With Quote
Old 31-05-2019, 00:47   #13
Registered User

Join Date: Jul 2010
Location: Hannover - Germany
Boat: Amel Sharki
Posts: 2,541
Re: opencpn.conf length is Zero byte !

Quote:
Originally Posted by transmitterdan View Post
Gerhars,

OpenCPN does save it’s configuration. But the OS is “optimized” for operating from a micro-SD card. So it has massive cache buffers that it only writes to the actual card when it has to. It can take long time to write a few hundred megabytes of cache out. So if the user does not wait for that to happen during shutdown then the SD card file system can get corrupted.

For Raspberry Pi it’s best to power it from never ending power source and don’t shut it down a lot. When shutting it down don’t assume that when the screen goes dark the shutdown process is finished. It is not. Wait until the green LED flashes many (10 I think) which signals that the cache has been flushed. Then wait a while longer before removing power.

A Pi is not a Mac obviously. It costs €25. Not surprising it has some quirks as compared to a Mac.
So people writing software for such an OS doesn't know that? Strange.
CarCode is offline   Reply With Quote
Old 31-05-2019, 04:07   #14
Registered User
 
transmitterdan's Avatar

Join Date: Oct 2011
Boat: Valiant 42
Posts: 6,008
Re: opencpn.conf length is Zero byte !

I don’t understand your question. Of course the OS people know what they are doing. That’s why it blinks the LED to show shutdown complete. But users often don’t read the instructions.

The Pi uses a simple micro-SD card for its mass storage. When used as an IoT device the OS can be built to make the SD card file system read-only and thus power failure is of no concern. But many people use the Pi as a regular desktop computer where the file system cannot be RO.

But reading and writing is very slow to an SD card. So the OS has a disk cache feature that allocates unused RAM for disk buffers. This greatly speeds up writing. Also rereading files, especially shared object files, is hundreds of times faster. As far as I know it also caches the file system tables even.

So when power is removed prematurely the SD card can be left in an incomplete state. In not so rare cases the SD card itself can be bricked due to unfinished writing when power fails. I have an SD card from a Pi that is unusable because of a power failure.

A €25 desktop computer is bound to have some limitations. The Pi is very reliable when used within its limitations. Shutdown has to be done with care.
transmitterdan is offline   Reply With Quote
Old 31-05-2019, 09:13   #15
Registered User

Join Date: Jul 2010
Location: Hannover - Germany
Boat: Amel Sharki
Posts: 2,541
Re: opencpn.conf length is Zero byte !

Quote:
Originally Posted by transmitterdan View Post
I don’t understand your question. Of course the OS people know what they are doing. That’s why it blinks the LED to show shutdown complete. But users often don’t read the instructions.

The Pi uses a simple micro-SD card for its mass storage. When used as an IoT device the OS can be built to make the SD card file system read-only and thus power failure is of no concern. But many people use the Pi as a regular desktop computer where the file system cannot be RO.

But reading and writing is very slow to an SD card. So the OS has a disk cache feature that allocates unused RAM for disk buffers. This greatly speeds up writing. Also rereading files, especially shared object files, is hundreds of times faster. As far as I know it also caches the file system tables even.

So when power is removed prematurely the SD card can be left in an incomplete state. In not so rare cases the SD card itself can be bricked due to unfinished writing when power fails. I have an SD card from a Pi that is unusable because of a power failure.

A €25 desktop computer is bound to have some limitations. The Pi is very reliable when used within its limitations. Shutdown has to be done with care.
With such a raw egg you want to do navigation?
NEVER!
CarCode is offline   Reply With Quote
Reply

Tags
enc, opencpn

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
File opencpn.conf 'leaks' to 0 byte ! Didier B OpenCPN 15 07-03-2019 09:20
Country? Berth cost, Boat Length or Berth Length? sailabroad Dollars & Cents 33 16-04-2018 07:12
OpenCPN on Pi Zero Rhapsody-NS27 OpenCPN 21 25-01-2017 04:29
OpenCPN puts Track Point at Lat Long Zero LifePart2 OpenCPN 6 02-05-2014 02:15
Could Not Locate OpenCPN.conf manuprenlair OpenCPN 1 28-09-2011 06:03

Advertise Here


All times are GMT -7. The time now is 15:52.


Google+
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Social Knowledge Networks
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2024, vBulletin Solutions, Inc.

ShowCase vBulletin Plugins by Drive Thru Online, Inc.