Preventing filesystem corruption

I’d like to know is there something else to do for preventing
filesystem from corruption. We are havingproblems with QNX filesystem
on Sandisk 48M flash. We’ve done this far:

  • Filesystem won’t be full, there’s always at least 1 meg free.
  • On boot image, mount is run like this (using synchronous mount)
    /bin/mount -p /dev/hd1.0 /dev/hd1.0t77 / -s
  • We have battery backup power, and we get at least 15 second warning
    for power going down. After it:
  • applications don’t write on disk
  • we run ‘sync’
    We can’t do shutdown on that point because we don’t know if power
    returns or not. If it returns before battery getting empty, we
    continue as usual.
  • On boot we run 'chkfsys -uPr / ’


    Still, we are getting corrupted flash. In fact, some small files are
    getting empty nearly every time if they are written nearby of
    reboot. And sometimes we get random corruption (plain text files have
    binary carbage, etc). We have tried this on two units, and I don’t
    think it’s broken hardware.

Running QNX 4.25D, using Fsys.eide for flash.

All ideas welcome, if using e-mail remove xx and .invalid from my e-mail.


M. Tavasti / tavastixx@iki.fi / +358-40-5078254
Poista sähköpostiosoitteesta molemmat x-kirjaimet
Remove x-letters from my e-mail address

On 07 May 2001 10:46:53 +0300, “M. Tavasti” <tavastixx@iki.fi.invalid>
wrote:

Try running Fsys with -d0 anc -c0

I’d like to know is there something else to do for preventing
filesystem from corruption. We are havingproblems with QNX filesystem
on Sandisk 48M flash. We’ve done this far:

  • Filesystem won’t be full, there’s always at least 1 meg free.
  • On boot image, mount is run like this (using synchronous mount)
    /bin/mount -p /dev/hd1.0 /dev/hd1.0t77 / -s
  • We have battery backup power, and we get at least 15 second warning
    for power going down. After it:
  • applications don’t write on disk
  • we run ‘sync’
    We can’t do shutdown on that point because we don’t know if power
    returns or not. If it returns before battery getting empty, we
    continue as usual.
  • On boot we run 'chkfsys -uPr / ’


    Still, we are getting corrupted flash. In fact, some small files are
    getting empty nearly every time if they are written nearby of
    reboot. And sometimes we get random corruption (plain text files have
    binary carbage, etc). We have tried this on two units, and I don’t
    think it’s broken hardware.

Running QNX 4.25D, using Fsys.eide for flash.

All ideas welcome, if using e-mail remove xx and .invalid from my e-mail.


M. Tavasti / > tavastixx@iki.fi > / +358-40-5078254
Poista sähköpostiosoitteesta molemmat x-kirjaimet
Remove x-letters from my e-mail address

If you are writing text files from a program, watch out for using higher
level streaming C++ I/O functions (iostreams). I used to use them (back
when I first started programming under QNX) and found that any random loss
of power (happened to have very poorly supplied power to my house) could
cause extreme havoc on my partition. I’ve lost complete partitions due to
the problem. My suggestion is, if you are writing data files normally, to
use as low level access methods as possible (when reading/writing binary
data, use read/write, if doing ASCII file manipulation, try to use fopen and
f* accessor functions). This might help to prevent more corruption.

Also, a nice trick is if you are writing files and can get an estimate as to
how large the file will be, to resize the file (ltrunc) before you write.
This helps to prevent extra manipulations of the file tables while writing
to disk and can keep your data sane more often.

Other than that, doing syncs is good. If you can do an fsync() on the
particular files you have open, that might be a nice way to keep the
particular open files you are writing in sync.

And try to avoid hard powering off during a chkfsys, I haven’t personally
had any problems with it but have heard that it can cause trouble.

R B Adler


“M. Tavasti” <tavastixx@iki.fi.invalid> wrote in message
news:m2vgndha8i.fsf@akvavitix.vuovasti.com

I’d like to know is there something else to do for preventing
filesystem from corruption. We are havingproblems with QNX filesystem
on Sandisk 48M flash. We’ve done this far:

  • Filesystem won’t be full, there’s always at least 1 meg free.
  • On boot image, mount is run like this (using synchronous mount)
    /bin/mount -p /dev/hd1.0 /dev/hd1.0t77 / -s
  • We have battery backup power, and we get at least 15 second warning
    for power going down. After it:
  • applications don’t write on disk
  • we run ‘sync’
    We can’t do shutdown on that point because we don’t know if power
    returns or not. If it returns before battery getting empty, we
    continue as usual.
  • On boot we run 'chkfsys -uPr / ’


    Still, we are getting corrupted flash. In fact, some small files are
    getting empty nearly every time if they are written nearby of
    reboot. And sometimes we get random corruption (plain text files have
    binary carbage, etc). We have tried this on two units, and I don’t
    think it’s broken hardware.

Running QNX 4.25D, using Fsys.eide for flash.

All ideas welcome, if using e-mail remove xx and .invalid from my e-mail.


M. Tavasti / > tavastixx@iki.fi > / +358-40-5078254
Poista sähköpostiosoitteesta molemmat x-kirjaimet
Remove x-letters from my e-mail address

mcharest@nozinformatic.com (Mario Charest) writes:

Try running Fsys with -d0 anc -c0

It looks like working thing…


M. Tavasti / tavastixx@iki.fi / +358-40-5078254
Poista sähköpostiosoitteesta molemmat x-kirjaimet
Remove x-letters from my e-mail address

This is good news for me too, as I am also using a flash disk and have had
the same problem.

One question though – how do I call Fsys with different args at boot time?
It looks to me as though it is built into the boot image and I will have to
re-install. Is this correct?

Best,

Dave McMordie

Ambulatory Robotics Lab / Centre for Intelligent Machines / McGill
University

mcmordie@cim.mcgill.ca

“M. Tavasti” <tavastixx@iki.fi.invalid> wrote in message
news:m28zk8fee7.fsf@akvavitix.vuovasti.com

mcharest@nozinformatic.com > (Mario Charest) writes:

Try running Fsys with -d0 anc -c0

It looks like working thing…


M. Tavasti / > tavastixx@iki.fi > / +358-40-5078254
Poista sähköpostiosoitteesta molemmat x-kirjaimet
Remove x-letters from my e-mail address

Previously, Dave McMordie wrote in qdn.public.qnx4:

This is good news for me too, as I am also using a flash disk and have had
the same problem.

One question though – how do I call Fsys with different args at boot time?
It looks to me as though it is built into the boot image and I will have to
re-install. Is this correct?

Take a look in your /boot/build file. You will probably see a file
named hard.1 or something similar. Take a look at the file,
there is a probably a few lines like this:

/bin/Fsys
$ 8000 Fsys -r 1024K

You can add parameters itn the obvious place. Then you must
rebuild the file using buildqnx. There is a Makefile in the
/boot directory which you can use, or use buildqnx directly.
The file that is created is copied to /.boot. It’s a good
idea to copy /.boot to /.altboot and /etc/config/sysinit.1
to /etc/config/altsysinit before changing anything.


Mitchell Schoenbrun --------- maschoen@pobox.com

Yep.

You’ll have to edit the boot image build file and use buildqnx to create a
new image.
Make sure you copy your old image to .altboot before you over-write it with
the new one.
Other wise you’ll be sorry if you’ve made a mistake (easily done, believe
me).

Regards,

Liam Power.


“Dave McMordie” <mcmordie@cim.mcgill.ca> schrieb im Newsbeitrag
news:9eri1b$10d$1@inn.qnx.com

This is good news for me too, as I am also using a flash disk and have had
the same problem.

One question though – how do I call Fsys with different args at boot
time?
It looks to me as though it is built into the boot image and I will have
to
re-install. Is this correct?

Best,

Dave McMordie

Ambulatory Robotics Lab / Centre for Intelligent Machines / McGill
University

mcmordie@cim.mcgill.ca

“M. Tavasti” <> tavastixx@iki.fi.invalid> > wrote in message
news:> m28zk8fee7.fsf@akvavitix.vuovasti.com> …
mcharest@nozinformatic.com > (Mario Charest) writes:

Try running Fsys with -d0 anc -c0

It looks like working thing…


M. Tavasti / > tavastixx@iki.fi > / +358-40-5078254
Poista sähköpostiosoitteesta molemmat x-kirjaimet
Remove x-letters from my e-mail address