Battery out... deleted my day's work!

I carefully plugged in my laptop to its charger as usual, but unfortunately forgot to turn the main switch on! So after a few hours my machine shut down in the middle of doing some work.

Strangely, all the work I was doing has vanished! A new folder I created (with its contents), some compiled files, a download, and even my WebPositive settings…

I didn’t think this was possible! (And I’d have thought the system was smart enough to do a clean shutdown, rather than abruptly shutting off.) Should I be worried about other corruption?

1 Like

Power management is still rather rudimentary though normally Haiku is rather vigilant about keeping files after an outage. How long had it been since it was supposed to save? You would probably want to run a checkfs now to get the filesystem sorted.

1 Like

Yeah, I’d have thought with all the journalling and such, things were fairly well protected. That was a couple of hours’ (though sporadic) work. Fortunately not at all critical (just playing with Java), and easily recreated.

I guess I can trust checkfs not to screw things up further? :grinning:

1 Like

Running checkfs should be safe. From what I understand it should play out any pending actions and clear up unallocated blocks.

1 Like

Year that was also my biggest mistake. Journaling is mostly for the fs itself (so the folder should be there) but not for content of the file. I alway lost data on crashes (i wrote my whole thesis in gobe on zeta… and from this side it was a pain …also using gobe was a charm)

Is there on notice by haiku about the stand of battery state by haiku?

Make a bug report please.

Yes, if you have the powerstatus replicant in deskbar, it will show notifications when the battery is getting low.

As to how thisis possible: Haiku will cache filesystem data in ram to avoid useless disk io. If you have lots osf ram and dont use it for something else, the data may stay there for some time. You can run the “sync” command to make sure things are flushed to disk

I’m sorry you lost your work. Most FileSystem writes are cached and are not commited until later. I’ve gotten into a habit of executing ‘sync’ often to work around the lazy FileSystem updates. The update / flush frequency could do with tweaking.

It’s quite possible that happened… I have to admit to a slight fib :grinning: – I wasn’t exactly working at the time… I was banging away on my piano connected through MusicWeaver, playing along with Radio Caroline! So I wasn’t in a position to notice any notification. (In any case the laptop of course flashes the charging LED when the battery is low.)

Ahh. Thanks for explaining that. I’ll have to remember to “sync”.

Might be not a bad idea then to make the FS automatically sync to disc in regular intervals. Even desktop system can be hit by power-outages out of the blue.

Indeed. I think it’s supposed to work like that, but I don’t have enough knowledge of our block and file caches to be sure.

Also, you can use some kind of “cron” daemon to schedule the execution of the sync command (for example, every 15 minutes). Not sure if Haiku includes the cron command. If not, you can try the ‘dcron’ package available at HaikuDepot.

Gah! I was talking about this very thing YEARS ago! And it STILL hasn’t been addressed?!? Utter and complete BLASPHEMY! :smiley:

Cart before the horse, once again…

Or – as I don’t have much use for cron otherwise – do as I’ve just done and put a script (with execute bit set) like this in /boot/home/config/settings/boot/launch:

#! /bin/sh
while true; do
 sleep 15m
 sync
 notify --timeout 30 "System Sync'ed"
done

(The ‘notify’ is just for my reassurance…)

1 Like

Why they can’t incorporate this into the OS, I don’t understand, but thank you for showing people how to do it themselves.

However, how does this script “loop” until you shut down? When it’s Sync’d after 15 min., doesn’t it end the loop and quit?

If you mean Pete’s script, it has a while true, so it will keep looping theoretically forever.

I’m running Haiku x86_64 and I created a file called “sync.sh” and entered in the lines of text and saved it, setting the execute bit, but even after rebooting, I never got a notice onscreen that said the system was synced.

Did I do something wrong or…?

Well, first I would try running it from a terminal.

It does work for me, so something must be off. I did work up to it in stages, to make sure I’d done everything right. As Chris suggests, run from the Terminal first. I also started out with a 1 minute sleep, so I made sure I was seeing the ‘notify’.

When you think it actually should be running, check that it is with ‘ps’, or the ProcessController.

One other thing to know is that the launching is done via UserBootScript, so check that is correct. A while back I too was puzzled that nothing was launching… until I looked at UserBootScript and found it was still referencing ~/config/boot/launch! It should look like:

# DO NOT EDIT! 
 #=====================================================================
        # Start programs and open files in the boot launch folder
        for file in $HOME/config/settings/boot/launch/* 
        do 
        	/bin/open "$file" &
        done
        #=====================================================================

ADDENDUM: I meant to add that I think that last is an Ooh-nasty misstep! A file labelled “UserBootScript” should be exclusively for user customization. If something is put in the 'launch" folder, I’d expect the system to take care of it. And of course there’s a /boot/system/data/user_launch/user script that invokes UserBootScript itself, so that’s where the launch folder launching should be done too.

I totally done lost ya. Could you write out what I should do, in step-by-step fashion? Please? PM or Email me, if necessary.