62

On login to EC2 (Ubuntu) instance, I see

*** /dev/xvda1 should be checked for errors ***

I can't fsck /dev/xvda1 because it is mounted, and sudo umount /dev/xvda1 fails because it is in use. lsof shows

jbd2/xvda  172               root  cwd       DIR              202,1     4096          2 /
jbd2/xvda  172               root  rtd       DIR              202,1     4096          2 /
jbd2/xvda  172               root  txt   unknown                                        /proc/172/exe

and kill -SIGKILL 172 is ineffective.

What to do?

5 Answers5

104

For our ec2 ubuntu instance, the above answers did not work completely.

On Ubuntu, by default, the check is not enabled in the rcS file. So

  1. Edit rcS file sudo vi /etc/default/rcS

below the line

#FSCKFIX=no

Add

FSCKFIX=yes
  1. Edit fstab file: sudo vi /etc/fstab

Look for the the record for / and if the last digit is 0 change it to 1. The last field is fsckorder and is used by fsck to decide the order of checking disks. If the value is 0 that disk is skipped.

For e.g.,

LABEL=cloudimg-rootfs   /        ext4   defaults,discard        0 0

to

LABEL=cloudimg-rootfs   /        ext4   defaults,discard        0 1 
  1. Create /forcefsck file: sudo touch /forcefsck

Reboot from ec2 console.

Revert the fsckorder value from 1 to 0 in /etc/fstab Delete the line FSCKFIX=yes to get back rcS file to original state.

Hope it helps.

51

Most Linuxes these days should perform a forced fsck at boot time when the file /forcefsck is present on the system. If you are at liberty to reboot the VM, run

touch /forcefsck

Then reboot at your convenience

Sgaduuw
  • 1,843
7

Since you cannot boot into live disc, this is may sounds a bit weird, but i guess it'll do the job)

high level:

  • boot into new (another) instance.
  • attach storage from old instance to new (current).
  • run fsck.
  • detach storage from new (current) and reattach it to old instance.
alexus
  • 13,667
1

I just do 3 steps below and issue resolved.

  1. Add "FSCKFIX=yes" to /etc/default/rcS
  2. sudo touch /forcefsck
  3. sudo reboot

Thanks all.

0

Follow these three steps:

  1. Edit rcS file
    sudo vi /etc/default/rcS

below the line

# FSCKFIX=no

Add FSCKFIX=yes

  1. Then do this:

sudo touch /forcefsck

  1. Reboot from EC2 console.

You can login back and check it has gone away

Original answer here

ddreliv
  • 101