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.
Got something to add? Send me email.
More Articles by Tony Lawrence © 2011-06-02 Tony Lawrence
Computers have been taught to distrust each other and will reject attempted connections most of the time. Nowadays, most computers and firewalls are utterly rude about it: it would be like asking someone to dance and having them ignore you as though you were invisible and inaudible. (Tony Lawrence)