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?

2

5 Answers 5

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

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

8
  • 6
    This worked for me. Simply doing "touch /forcefsck" doesn't solve it, I had to enable FSCKFIX also. Commented Aug 26, 2015 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. Commented Dec 22, 2015 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. Commented Sep 19, 2016 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
    Commented Dec 7, 2016 at 8:21
  • This also fixed the issue on my local computer. I believe this should be marked as best.
    – Arda
    Commented Mar 16, 2017 at 9:00
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.
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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .