52

I'm running e2fsk on a very large (1TB+) ext3 disk with

e2fsck -v /dev/sda1

from RIPLinux booted with PXE.

I get

e2fsck 1.41.6 (30-May-2009)
/dev/sda1 contains a file system with errors, check forced.
Pass 1: Checking inodes, blocks, and sizes

and then a very long pause...

How do I get some idea of activity?

Ideally a count of completed items vs total and some kind of ETA.

Zoredache
  • 128,755
  • 40
  • 271
  • 413
Tim Abell
  • 1,311
  • 3
  • 10
  • 21
  • However, it can be a while after the "Pass 1: Checking inodes, blocks, and sizes" message before the completion bar starts showing. I suspect there is an early phase of Pass 1 that doesn't update the completion bar, but on really large disks takes a significant amount of time. – user2864482 Aug 13 '14 at 01:11

4 Answers4

84

The -C flag will display a progress bar. Performance differences depending on how fsck is called.

And very cool, if e2fsck is already running, you can send a USR1 signal for it to start displaying a progress bar. USR2 to stop. Example:

killall -USR1 e2fsck

From FSCK(8):

   -C     Display completion/progress bars for those filesys-
          tems  checkers (currently only for ext2) which sup-
          port them.   Fsck will manage the filesystem check-
          ers  so  that  only  one  of  them  will  display a
          progress bar at a time.

From E2FSCK(8):

   -C fd  This  option  causes  e2fsck  to  write  completion
          information  to  the  specified  file descriptor so
          that the progress of the filesystem  check  can  be
          monitored.   This  option is typically used by pro-
          grams  which  are  running  e2fsck.   If  the  file
          descriptor specified is 0, e2fsck will print a com-
          pletion bar as it goes about  its  business.   This
          requires  that e2fsck is running on a video console
          or terminal.
Warner
  • 23,440
  • 2
  • 57
  • 69
  • 2
    It looks like your man page is for a different version of e2fsck. I'll post an answer from my version, but it's very close and your answer was enough to make me read the right bit of the man page. Thanks very much! – Tim Abell Mar 03 '10 at 15:40
  • Ah, good call-- I've updated. You're welcome. – Warner Mar 03 '10 at 15:46
  • 4
    Hmm...today I learned (the USR signal for getting that output from fsck). Thanks for the knowledge, @Warner. – Bart Silverstrim Aug 20 '11 at 02:22
  • 3
    The -USR1 flag is invaluable. I created an account here just so I could upvote. – Rajesh J Advani Aug 15 '14 at 12:39
  • The -USR1 flag is invaluable, my os is CentOS Linux 7.6. I can't get the e2fsck progress bar – stack Mar 10 '21 at 01:17
  • Note that this is an upper case -C ! Lower case -c will cause e2fsck to call the badblocks tool which is usually not what you want. Guess who just found out the hard way? Note to self: Don't just copy any random command lines from the internet, always check the documentation first. – dummzeuch Jul 11 '22 at 13:08
22

from man page for version 1.41

   -C fd  This option causes e2fsck to write completion information to the specified file descriptor so that the progress of the
          filesystem  check  can be monitored.  This option is typically used by programs which are running e2fsck.  If the file
          descriptor number is negative, then absolute value of the file descriptor will be used, and the  progress  information
          will  be  suppressed  initially.  It can later be enabled by sending the e2fsck process a SIGUSR1 signal.  If the file
          descriptor specified is 0, e2fsck will print a completion bar as it goes  about  its  business.   This  requires  that
          e2fsck is running on a video console or terminal.

so I guess the answer is

e2fsck -C 0 /dev/sda1
Tim Abell
  • 1,311
  • 3
  • 10
  • 21
5

ps -ef | grep fsck

  5079  5007 47 00:55 pts/1    00:08:25 /sbin/fsck.ext3 -yv /dev/hda2

with the process ID,

kill -USR1 5079

ben
  • 59
  • 1
  • 1
  • 3
    This answer is the same as the accepted answer, except it provides no contextual information to help the user understand *why* they're following your instructions. For the future please note that we prefer answers that explain both the How and the **Why** of a solution (the "teach a man to fish" principle). – voretaq7 Dec 08 '12 at 04:28
  • [root@io01 183302]# ps -ef | grep sck root 183302 183003 99 Feb22 pts/3 15-15:22:39 e2fsck -fp /dev/mapper/ost301 – stack Mar 10 '21 at 01:22
  • [root@io01 183302]# kill -USR1 183302 [root@io01 183302]# – stack Mar 10 '21 at 01:22
  • it displays nothing – stack Mar 10 '21 at 01:23
3

Why?

BSD Systems and their descendants have SIGINFO signal. It makes programs to output their current status to the console. A lot of basic BSD tools know about this signal and support it. You can send this signal to a current process using Ctrl+T.

SysV systems have no such signal and no Ctrl+T too. Some of the Linux tools support SIGUSR1 instead. I know only about "dd" and "e2fsck" but there can be more. There is no Ctrl+? shortcut to send it, so you have to do it manually by using "kill -USR1" on the pid of the process.

Most other programs will react to SIGUSR1 the same way they react to SIGTERM (exit) so don't send this signal unless you know that it's supported.

Dmitry Ilyin
  • 573
  • 2
  • 5