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?

up vote 50 down vote accepted

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

  • That did it! Thanks! – user1836587 Sep 26 '14 at 15:32

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. 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.

  • 5
    This worked for me. Simply doing "touch /forcefsck" doesn't solve it, I had to enable FSCKFIX also. – Florin Andrei Aug 26 '15 at 23:10
  • 1
    Same here; just doing sudo touch /forcefsck before rebooting did not work on an Ubuntu 14.04 system, but this answer did. – Teemu Leisti Dec 22 '15 at 8:10
  • I had to do one other step - a modification to /etc/fstab as described here: nathanpfry.com/… That's odd because the last time I had this happen, I used your answer and it worked as is. – childofsoong Sep 19 '16 at 17:11
  • 2
    Thanks, this resolved it for me on an ec2 instance from AWS. I didn't have to reboot from the console, a simple sudo reboot with your changes resolved this. – Ralph Dec 7 '16 at 8:21
  • This also fixed the issue on my local computer. I believe this should be marked as best. – Arda Mar 16 '17 at 9:00

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.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.