APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed
RSS Feeds RSS Feeds











(OLDER) <- More Stuff -> (NEWER) (NEWEST)
Printer Friendly Version


Why does fsck need a scratch file?


Fsck often doesn't even have a "scratch" file option today, though with terabyte disks it is possible to imagine a system with not enough ram for fsck. However, modern fsck's know how to use swap, so this gets a bit easier, but see Running fsck on Large Paritions in FreeBSD too.

The problem is that fsck has to keep track of a lot of information. If the disk is very large and you have a lot of files, you might not have enough ram for fsck to do its job. Assuming available swap, it can work it through, but the new versions offer another option.

If you have a Linux system and man or info page for "e2fsck.conf" (it goes in /etc), your fsck might be able to use a scratch directory - and it can be pretty smart about it too. If you have a newer e2fsck, your e2fsck.conf can include these options:


THE [scratch_files] STANZA

The following relations are defined in the [scratch_files] stanza.

directory

If the directory named by this relation exists and is
writeable, then e2fsck will attempt to use this directory
to store scratch files instead of using in-memory data
structures.

numdirs_threshold

If this relation is set, then in-memory data structures
be used if the number of directories in the filesystem
are fewer than amount specified.

dirinfo

This relation controls whether or not the scratch file
directory is used instead of an in-memory data structure
for directory information. It defaults to true.

icount

This relation controls whether or not the scratch file
directory is used instead of an in-memory data structure
when tracking inode counts. It defaults to true.
 

You'd use set dirinfo to false if your filesystem had an large number of individual files and not so many directories. You'd set icount false if the reverse were true. Otherwise, you'd leave them alone (true).

That's a lot more control than we had with the old "-t" option!

It won't do you much good for root - fsck can't use the fs it is checking! I hope that it is unnecessary to remind you that you must run fsck on UMNOUNTED filesystems or (for root) in single user mode. The fsck should try to keep you from making that mistake, but I have had customers create quite a mess this way.

See Fear of using fsck also.












The rest of this page has to do with old SCO Unix fsck and scratchfiles.


There is an archaic limit to how large a filesystem fsck+ADM can check using available memory (archaic because it hasn't kept up with the growth in system memory). The exact limit is not something that appears to be documented anywhere, and may also vary between versions and different filesystem types. When this size is exceeded, fsck will want to use a scratch file to hold information while it's running. Before I continue, please read the man page for the -t option to fsck, and pay particular attention to the warning about following it with a space. Failure to do so may destroy data.

You may have been prompted at the time you installed the OS to create a scratch division if your root filesystem was too large for fsck to check. If so, you might wish to edit /etc/default/filesys to specify that this should be used if the system has to check the root filesystem after a crash. Add -t /dev/scratch (or whatever you called the scratch filesystem) in the fsckflags= entry for /dev/root.

For any filesystem other than root, you can generally use a temporary file on your root filesystem as a scratch file. fsck will create it and delete it automatically, once you've told it what file to use. I usually use /tmp/scratch.

If, however, you find you need to fsck /dev/root, which is too big to check without a scratch file and you don't have a scratch filesystem, you still have some choices. A blank (but formatted) floppy diskette will often do the trick (specify /dev/fd0). If you're running fsck in single-user mode and you can guarantee that no swapping has taken place and no swapping will take place while you're running fsck, you could use /dev/swap.

Otherwise it needs to be something NOT on the root filesystem, like /u/scratch (does not have to exist) if you have a separate /u filesystem.

For Unix 3.2v4.2 and ODT 3.0, see uod418a, which provides a new fsck which may eliminate the need for a scratch file.


If this page was useful to you, please help others find it:  





1 comment




More Articles by Tony Lawrence - Find me on Google+



Click here to add your comments





Thu Jun 2 23:12:11 2011: 9522   KenPorter

gravatar


Are there any tools that can measure a filesystem and hint at how to set the dirinfo or icount options?



Don't miss responses! Subscribe to Comments by RSS or by Email

Click here to add your comments


If you want a picture to show with your comment, go get a Gravatar



LOD Communications, Inc.

Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.

Publishing your articles here

Jump to Comments



Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.

Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.

We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.

pavatar.jpg

This post tagged:

       - BSD
       - Disks/Filesystems
       - FSCK
       - Linux
       - SCO_OSR5
       - Troubleshooting


















My Troubleshooting E-Book will show you how to solve tough problems on Linux and Unix systems!


book graphic unix and linux troubleshooting guide



Buy Kerio from a dealer
who knows tech:
I sell and support

Kerio Connect Mail server, Control, Workspace and Operator licenses and subscription renewals