If you're running an instance of Ubuntu JeOS (Just Enough OS - very barebones versions of popular linux distributions such as Suse, Ubuntu and CentOS) on KVM (or another hypervisor) you'll find that it doesn't run an fsck on the virtual disks at boot, even if the maximum time between checks has elapsed or the maximum number of mounts until test has been passed. This wad of words explains how to mount qcow2 files to either access files within them, or to run block level operations like fsck on them.
Luckily, it's easy to make a qcow2 image file appear as a block device on the host. Here are some pages: 1, 2 and 3 describing how it's done.
So, firstly modprobe the nbd driver:
root@nostromo:/home/vm# modprobe nbd max_part=63 root@nostromo:/home/vm#
nbd is the Network Block Device and should be available as a module in any standard Linux kernel. The max_part= is a useful feature of the nbd driver and the linux loopback device that will scan the device for partitions and present them as individual devices in /dev, rather than requiring you to fdisk/parted, calculate offsets and create loopback devices. You should now see new devices such as:
root@nostromo:/home/vm# ls /dev/nbd* /dev/nbd0 /dev/nbd0p2 /dev/nbd10 /dev/nbd12 /dev/nbd14 /dev/nbd2 /dev/nbd4 /dev/nbd6 /dev/nbd8 /dev/nbd0p1 /dev/nbd1 /dev/nbd11 /dev/nbd13 /dev/nbd15 /dev/nbd3 /dev/nbd5 /dev/nbd7 /dev/nbd9
Next, connect the qcow2 file as a block device:
root@nostromo:/home/vm/vm-guest/ubuntu-kvm# qemu-nbd -c /dev/nbd0 tmpctHyEZ.qcow2 root@nostromo:/home/vm/vm-guest/ubuntu-kvm#
The qemu-nbd tool is available in the qemu-utils Ubuntu package.
Once that's done, you could do anything you can do with a block device; mount the partitions ( mount /dev/nbd0p1 /mnt/foo ), or just dd the contents elsewhere like a raw image file, or to a physical partition.
But we don't want to do that, we're here to fsck. I happen to know the first partition is an ext4 partition, so let's check the partition first:
root@nostromo:/home/vm/vm-guest/ubuntu-kvm# fsck.ext4 -n /dev/nbd0p1 e2fsck 1.42.9 (4-Feb-2014) /dev/nbd0p1 has been mounted 70 times without being checked, check forced. Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information /dev/nbd0p1: 23990/488640 files (0.2% non-contiguous), 206230/1952873 blocks root@nostromo:/home/vm/vm-guest/ubuntu-kvm#
That would simply run a check on the partition. To check and fix (behaviour akin to the boot time checking on most Linux distributions) use the -p switch instead of -n (and -f to force the check): fsck.ext4 -f -p /dev/nbd0p1
I happen to know that the second partition /dev/nbd0p2 is a swap partition, so I won't be fscking that.
Once you've finished with the block device, disconnect it, but also run sync just in case:
root@nostromo:/home/vm/vm-guest/ubuntu-kvm# sync root@nostromo:/home/vm/vm-guest/ubuntu-kvm# qemu-nbd -d /dev/nbd0 /dev/nbd0 disconnected root@nostromo:/home/vm/vm-guest/ubuntu-kvm# sync root@nostromo:/home/vm/vm-guest/ubuntu-kvm#
That's it. Hope it was useful.
And I'd like to apologise about the title.

There was simply no other way to phrase it.