Re: automating 'fsck -y' after a power failure

2009-10-07 Thread Janne Johansson
Joachim Schipper wrote:
>>> make a dump of the partition before going to execute potentially data
>>> destroying actions?
>> yes, this is sound advice of course.  but what are you going
>> to do with the dump if say, fsck is not able to revive the fs?
>> "dump" it back, run fsck again and answer "no" at a couple of
>> fsck prompts?  how is it going to change anything in the end?
> 
> Well, if fsck can't revive your partition, you can always try different
> tools. Something like fsdb may be able to recover part or all of your
> filesystem even in cases where fsck loses the plot.

Also, fsck may fail in the middle due to lack of memory, so moving the
dump to a bigger box to make it run through may be a good solution in
that case. Or old fsck fails where a -current fsck won't.



Re: automating 'fsck -y' after a power failure

2009-10-05 Thread Aaron Mason
On Sun, Oct 4, 2009 at 3:10 AM, Anthony Roberts
 wrote:
> What I tend to do for those is just make the filesystems for that machine
> read-only.
>
> This is inconvenient to set up/use for several reasons, but it helps make
> machines indifferent to surprise reboots. It's handy if the site has
> unreliable power (eg solar/battery out in the bush somewhere) or even
> simply because people don't realize random Soekris boxes in wiring cabinets
> might need to be shut down cleanly.
>
> -Anthony
>
> On Sat, 3 Oct 2009 11:14:16 -0300, "Jose Fragoso"
> 
> wrote:
>> Hi,
>>
>>> If that was a wisething to do, we would have already done so. In other
>>> words, it is not wise. It's foolish.
>>>
>>>  -Otto
>>
>> I totally agree with you. This should not be in the release.
>>
>> However, I have a few obsd boxes working at places where I can
>> not reach with ease. What I want to avoid is telling a client
>> (who does not know anything about unix or Xbsd), by phone, to
>> run 'fsck -y', when the system does not boot, as a last resource,
>> before I have to go there myself. Sometimes, not even a console
>> is available.
>>
>> Thanks for your insight.
>>
>> Regards,
>>
>> Jose
>
>

I agree with Anthony here - make root read only, mfs /dev, and mount
everything else as nosuid,nodev.  If you think you're going to need to
add things to it at some point in the future, keep fstab the same,
create a directory, add changes to that, then run a script from
/etc/rc.securelevel to merge changes and remount root as readonly.  It
is good to have a throwaway server to test these things on before
applying them to a production box.

A script to do the above would look something like this in my head
(assuming your staging directory is /usr/tmp/staging:

cat >/usr/local/sbin/merge-staging <

Re: automating 'fsck -y' after a power failure

2009-10-04 Thread James Hartley
On Sun, Oct 4, 2009 at 11:26 AM, bofh  wrote:

> What does fsck mean?
>

Filesystem check.



Re: automating 'fsck -y' after a power failure

2009-10-04 Thread Joachim Schipper
On Sun, Oct 04, 2009 at 07:58:06PM +0200, frantisek holop wrote:
> hmm, on Fri, Oct 02, 2009 at 10:49:56PM +0200, Otto Moerbeek said that
> > > here's the thing: even though every single diagnostic message
> > > fsck may produce is documented in /usr/share/doc/smm/03.fsck_ffs
> > > i dont see how these questions help at all.  what i mean is,
> > > there is nothing to compare the diagnostic data to anyway, so
> > > what is the answer going to be based on?  so far i have always
> > > only took the leap of faith and pressed yes or always..  what
> > > else is there to do?
> > 
> > make a dump of the partition before going to execute potentially data
> > destroying actions?
> 
> yes, this is sound advice of course.  but what are you going
> to do with the dump if say, fsck is not able to revive the fs?
> "dump" it back, run fsck again and answer "no" at a couple of
> fsck prompts?  how is it going to change anything in the end?

Well, if fsck can't revive your partition, you can always try different
tools. Something like fsdb may be able to recover part or all of your
filesystem even in cases where fsck loses the plot. There is also the
Sleuth kit.

And if all else fails, you can always write your own software/grep
through the raw disk/etc. fsck is great at what it does, but it's not
the only game in town.

Needless to say, restoring from backup is easier than reconstructing a
filesystem from a hex dump of the disk. But sometimes you don't have
backups...

Joachim



Re: automating 'fsck -y' after a power failure

2009-10-04 Thread bofh
What does fsck mean?  I always thought it was those strange bearded
sysadmins private cuss word as they always seem to scream *fsck yes
damnit!!!* whenever the system crashes

On 10/2/09, frantisek holop  wrote:
> hmm, on Fri, Oct 02, 2009 at 07:31:39PM +0200, Otto Moerbeek said that
>> > fsck -y
>> >
>> > after a power or other type of failure,
>> > in cases the automatic file system check fails?
>>
>> If that was a wisething to do, we would have already done so. In other
>> words, it is not wise. It's foolish.
>
> as usually, i absolutely agree with you Otto.
>
> however.
>
> please all the people in the room raise their hands who have the
> faintest idea about what 95% of the questions that fsck is going to ask
> them on a seriously borked fs mean.  my hat goes off to them.
>
> here's the thing: even though every single diagnostic message
> fsck may produce is documented in /usr/share/doc/smm/03.fsck_ffs
> i dont see how these questions help at all.  what i mean is,
> there is nothing to compare the diagnostic data to anyway, so
> what is the answer going to be based on?  so far i have always
> only took the leap of faith and pressed yes or always..  what
> else is there to do?
>
> a couple of months ago, after a certain incident on my notebook
> i was presented with a borked suberblock and after i have
> figured out that the backup superblock were usable, i just
> crossed my fingers and after a dry run i started fsck.
>
> i got some 7700 'UNKNOWN FILE TYPE's, an unallocated root inode,
> bad magic numbers for CGs and fsck messages i have never had the
> luck meeting with before... (should read 03.fsck_ffs one of
> these days probably -- but even then, i would just say yes
> on every question)
>
> unfortunately i dont have a transcript of that fsck session,
> i do however have a "screenshot" of the last phase:
>
> ** Phase 5 - Check Cyl groups
> CG 0: BAD MAGIC NUMBER
> FREE BLK COUNT(S) WRONG IN SUPERBLK
> SALVAGE? yes
>
> SUMMARY INFORMATION BAD
> SALVAGE? yes
>
> BLK(S) MISSING IN BIT MAPS
> SALVAGE? yes
>
> 118774 files, 4966785 used, 2542705 free (17073 frags, 315704 blocks, 0.2%
> fragmentation)
>
> UPDATE STANDARD SUPERBLOCK? yes
>
>
> MARK FILE SYSTEM CLEAN? yes
>
>
> * FILE SYSTEM WAS MODIFIED *
>
> (for the curious: all my files survived under lost+found.  i was
> as happy as it can be)
>
> if fsck thinks there is a problem, there is nothing left but to press y
> anyway.  although i'd very much like to read stories of other admins
> doing otherwise.
>
> -f
> --
> atheism is a non-prophet organization.
>
>

-- 
Sent from my mobile device

http://www.glumbert.com/media/shift
http://www.youtube.com/watch?v=tGvHNNOLnCk
"This officer's men seem to follow him merely out of idle curiosity."
-- Sandhurst officer cadet evaluation.
"Securing an environment of Windows platforms from abuse - external or
internal - is akin to trying to install sprinklers in a fireworks
factory where smoking on the job is permitted."  -- Gene Spafford
learn french:  http://www.youtube.com/watch?v=30v_g83VHK4



Re: automating 'fsck -y' after a power failure

2009-10-04 Thread Otto Moerbeek
On Sun, Oct 04, 2009 at 07:58:06PM +0200, frantisek holop wrote:

> hmm, on Fri, Oct 02, 2009 at 10:49:56PM +0200, Otto Moerbeek said that
> > > here's the thing: even though every single diagnostic message
> > > fsck may produce is documented in /usr/share/doc/smm/03.fsck_ffs
> > > i dont see how these questions help at all.  what i mean is,
> > > there is nothing to compare the diagnostic data to anyway, so
> > > what is the answer going to be based on?  so far i have always
> > > only took the leap of faith and pressed yes or always..  what
> > > else is there to do?
> > 
> > make a dump of the partition before going to execute potentially data
> > destroying actions?
> 
> yes, this is sound advice of course.  but what are you going
> to do with the dump if say, fsck is not able to revive the fs?
> "dump" it back, run fsck again and answer "no" at a couple of
> fsck prompts?  how is it going to change anything in the end?
> 

You have several options: consult an expert and indeed answer n to
some of the prompts, mount -f the fs and recover your most important
files, use the image as a test case to improve fsck_ffs...  there are
probably more cases why having a dump of the inconsistent fs can be good.

-Otto



Re: automating 'fsck -y' after a power failure

2009-10-04 Thread frantisek holop
hmm, on Fri, Oct 02, 2009 at 10:49:56PM +0200, Otto Moerbeek said that
> > here's the thing: even though every single diagnostic message
> > fsck may produce is documented in /usr/share/doc/smm/03.fsck_ffs
> > i dont see how these questions help at all.  what i mean is,
> > there is nothing to compare the diagnostic data to anyway, so
> > what is the answer going to be based on?  so far i have always
> > only took the leap of faith and pressed yes or always..  what
> > else is there to do?
> 
> make a dump of the partition before going to execute potentially data
> destroying actions?

yes, this is sound advice of course.  but what are you going
to do with the dump if say, fsck is not able to revive the fs?
"dump" it back, run fsck again and answer "no" at a couple of
fsck prompts?  how is it going to change anything in the end?

-f
-- 
forget everything, as one day everything will forget you.



Re: automating 'fsck -y' after a power failure

2009-10-03 Thread Anthony Roberts
What I tend to do for those is just make the filesystems for that machine
read-only.

This is inconvenient to set up/use for several reasons, but it helps make
machines indifferent to surprise reboots. It's handy if the site has
unreliable power (eg solar/battery out in the bush somewhere) or even
simply because people don't realize random Soekris boxes in wiring cabinets
might need to be shut down cleanly.

-Anthony

On Sat, 3 Oct 2009 11:14:16 -0300, "Jose Fragoso"

wrote:
> Hi,
> 
>> If that was a wisething to do, we would have already done so. In other
>> words, it is not wise. It's foolish.
>>
>>  -Otto
> 
> I totally agree with you. This should not be in the release.
> 
> However, I have a few obsd boxes working at places where I can
> not reach with ease. What I want to avoid is telling a client
> (who does not know anything about unix or Xbsd), by phone, to
> run 'fsck -y', when the system does not boot, as a last resource,
> before I have to go there myself. Sometimes, not even a console
> is available.
> 
> Thanks for your insight.
> 
> Regards,
> 
> Jose



Re: automating 'fsck -y' after a power failure

2009-10-03 Thread Jose Fragoso
Hi,

> If that was a wisething to do, we would have already done so. In other
> words, it is not wise. It's foolish.
>
>   -Otto

I totally agree with you. This should not be in the release.

However, I have a few obsd boxes working at places where I can
not reach with ease. What I want to avoid is telling a client
(who does not know anything about unix or Xbsd), by phone, to
run 'fsck -y', when the system does not boot, as a last resource,
before I have to go there myself. Sometimes, not even a console
is available.

Thanks for your insight.

Regards,

Jose

--
An Excellent Credit Score is 750
See Yours in Just 2 Easy Steps!



Re: automating 'fsck -y' after a power failure

2009-10-03 Thread Mauro Rezzonico

Otto Moerbeek wrote:

Note that I said "dump the partition", not "dump the filesystem".

Oops. you mean dd(1)... sorry for the noise

--
Mauro Rezzonico , Como, Italia
"Maybe this world is another planet's hell" - H.Huxley



Re: automating 'fsck -y' after a power failure

2009-10-03 Thread Otto Moerbeek
On Sat, Oct 03, 2009 at 12:12:39AM +0200, Mauro Rezzonico wrote:

> Otto Moerbeek wrote:
> >make a dump of the partition before going to execute potentially data
> >destroying actions?
> 
> So you can dump a botched filesystem? The manpage says nothing about that...
> Well it doesn't say the contrary but...
> 
> So, question is: Can you *really* dump a "borked fs"?

Note that I said "dump the partition", not "dump the filesystem".

-Otto



Re: automating 'fsck -y' after a power failure

2009-10-02 Thread Robert
On Sat, 03 Oct 2009 00:12:39 +0200
Mauro Rezzonico  wrote:

> Otto Moerbeek wrote:
> > make a dump of the partition before going to execute potentially
> > data destroying actions?
> 
> So you can dump a botched filesystem? The manpage says nothing about
> that... Well it doesn't say the contrary but...
> 
> So, question is: Can you *really* dump a "borked fs"?
> 

Think 'dd', to have a second chance at messing up the data,
or work from the image to restore files. (See what i did there? ;)

-Robert



Re: automating 'fsck -y' after a power failure

2009-10-02 Thread Mauro Rezzonico

Otto Moerbeek wrote:

make a dump of the partition before going to execute potentially data
destroying actions?


So you can dump a botched filesystem? The manpage says nothing about that...
Well it doesn't say the contrary but...

So, question is: Can you *really* dump a "borked fs"?

--
Mauro Rezzonico , Como, Italia
"Maybe this world is another planet's hell" - H.Huxley



Re: automating 'fsck -y' after a power failure

2009-10-02 Thread Otto Moerbeek
On Fri, Oct 02, 2009 at 10:38:16PM +0200, frantisek holop wrote:

> hmm, on Fri, Oct 02, 2009 at 07:31:39PM +0200, Otto Moerbeek said that
> > > fsck -y
> > > 
> > > after a power or other type of failure,
> > > in cases the automatic file system check fails?
> > 
> > If that was a wisething to do, we would have already done so. In other
> > words, it is not wise. It's foolish.
> 
> as usually, i absolutely agree with you Otto.
> 
> however.
> 
> please all the people in the room raise their hands who have the
> faintest idea about what 95% of the questions that fsck is going to ask
> them on a seriously borked fs mean.  my hat goes off to them.
> 
> here's the thing: even though every single diagnostic message
> fsck may produce is documented in /usr/share/doc/smm/03.fsck_ffs
> i dont see how these questions help at all.  what i mean is,
> there is nothing to compare the diagnostic data to anyway, so
> what is the answer going to be based on?  so far i have always
> only took the leap of faith and pressed yes or always..  what
> else is there to do?

make a dump of the partition before going to execute potentially data
destroying actions?

-Otto
> 
> a couple of months ago, after a certain incident on my notebook
> i was presented with a borked suberblock and after i have
> figured out that the backup superblock were usable, i just
> crossed my fingers and after a dry run i started fsck.
> 
> i got some 7700 'UNKNOWN FILE TYPE's, an unallocated root inode,
> bad magic numbers for CGs and fsck messages i have never had the
> luck meeting with before... (should read 03.fsck_ffs one of
> these days probably -- but even then, i would just say yes
> on every question)
> 
> unfortunately i dont have a transcript of that fsck session,
> i do however have a "screenshot" of the last phase:
> 
> ** Phase 5 - Check Cyl groups
> CG 0: BAD MAGIC NUMBER
> FREE BLK COUNT(S) WRONG IN SUPERBLK
> SALVAGE? yes
> 
> SUMMARY INFORMATION BAD
> SALVAGE? yes
> 
> BLK(S) MISSING IN BIT MAPS
> SALVAGE? yes
> 
> 118774 files, 4966785 used, 2542705 free (17073 frags, 315704 blocks, 0.2% 
> fragmentation)
> 
> UPDATE STANDARD SUPERBLOCK? yes
> 
> 
> MARK FILE SYSTEM CLEAN? yes
> 
> 
> * FILE SYSTEM WAS MODIFIED *
> 
> (for the curious: all my files survived under lost+found.  i was
> as happy as it can be)
> 
> if fsck thinks there is a problem, there is nothing left but to press y
> anyway.  although i'd very much like to read stories of other admins
> doing otherwise.
> 
> -f
> -- 
> atheism is a non-prophet organization.



Re: automating 'fsck -y' after a power failure

2009-10-02 Thread Brad Tilley
On Fri, Oct 2, 2009 at 4:38 PM, frantisek holop  wrote:

> if fsck thinks there is a problem, there is nothing left but to press y
> anyway. B although i'd very much like to read stories of other admins
> doing otherwise.

Put a rock on the 'y' key and go get some coffee.



Re: automating 'fsck -y' after a power failure

2009-10-02 Thread frantisek holop
hmm, on Fri, Oct 02, 2009 at 07:31:39PM +0200, Otto Moerbeek said that
> > fsck -y
> > 
> > after a power or other type of failure,
> > in cases the automatic file system check fails?
> 
> If that was a wisething to do, we would have already done so. In other
> words, it is not wise. It's foolish.

as usually, i absolutely agree with you Otto.

however.

please all the people in the room raise their hands who have the
faintest idea about what 95% of the questions that fsck is going to ask
them on a seriously borked fs mean.  my hat goes off to them.

here's the thing: even though every single diagnostic message
fsck may produce is documented in /usr/share/doc/smm/03.fsck_ffs
i dont see how these questions help at all.  what i mean is,
there is nothing to compare the diagnostic data to anyway, so
what is the answer going to be based on?  so far i have always
only took the leap of faith and pressed yes or always..  what
else is there to do?

a couple of months ago, after a certain incident on my notebook
i was presented with a borked suberblock and after i have
figured out that the backup superblock were usable, i just
crossed my fingers and after a dry run i started fsck.

i got some 7700 'UNKNOWN FILE TYPE's, an unallocated root inode,
bad magic numbers for CGs and fsck messages i have never had the
luck meeting with before... (should read 03.fsck_ffs one of
these days probably -- but even then, i would just say yes
on every question)

unfortunately i dont have a transcript of that fsck session,
i do however have a "screenshot" of the last phase:

** Phase 5 - Check Cyl groups
CG 0: BAD MAGIC NUMBER
FREE BLK COUNT(S) WRONG IN SUPERBLK
SALVAGE? yes

SUMMARY INFORMATION BAD
SALVAGE? yes

BLK(S) MISSING IN BIT MAPS
SALVAGE? yes

118774 files, 4966785 used, 2542705 free (17073 frags, 315704 blocks, 0.2% 
fragmentation)

UPDATE STANDARD SUPERBLOCK? yes


MARK FILE SYSTEM CLEAN? yes


* FILE SYSTEM WAS MODIFIED *

(for the curious: all my files survived under lost+found.  i was
as happy as it can be)

if fsck thinks there is a problem, there is nothing left but to press y
anyway.  although i'd very much like to read stories of other admins
doing otherwise.

-f
-- 
atheism is a non-prophet organization.



Re: automating 'fsck -y' after a power failure

2009-10-02 Thread Otto Moerbeek
On Fri, Oct 02, 2009 at 09:15:41AM -0300, Jose Fragoso wrote:

> Hi,
> 
> Is it possible to automate the process of
> running
> 
> fsck -y
> 
> after a power or other type of failure,
> in cases the automatic file system check fails?

If that was a wisething to do, we would have already done so. In other
words, it is not wise. It's foolish.

-Otto



Re: automating 'fsck -y' after a power failure

2009-10-02 Thread Marcos Laufer
Jose, this is an ugly modification in /etc/rc but it should do what you 
need.


Search for the line that starts with 8) and modify it to look like this:



   8)
   echo "Corro FSCK de emergencia..."
   fsck -y ; fsck_st=$?
   if [ $fsck_st != 0 ]; then
 echo "Automatic file system check failed; help!"
 exit 1
   fi
   ;;


Regards,
Marcos


Jose Fragoso wrote:

Hi,

Is it possible to automate the process of
running

fsck -y

after a power or other type of failure,
in cases the automatic file system check fails?

Thanks in advance.

Regards,

Jose

--
An Excellent Credit Score is 750
See Yours in Just 2 Easy Steps!




automating 'fsck -y' after a power failure

2009-10-02 Thread Jose Fragoso
Hi,

Is it possible to automate the process of
running

fsck -y

after a power or other type of failure,
in cases the automatic file system check fails?

Thanks in advance.

Regards,

Jose

--
An Excellent Credit Score is 750
See Yours in Just 2 Easy Steps!