Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a KVM server and one of my guest machine is crashed and prompting form fsck check. Now I dont have console access or dont have the root access of the guest VM.

Is there any way that I can run the fsck from the hypervisor ?

I use centos 6.1 as my hypervisor

share|improve this question

install libguestfs:

# yum install libguestfs-tools

use guestfish to open the disk image:

# guestfish -a /path/to/diskimage.img

Welcome to guestfish, the libguestfs filesystem interactive shell for
editing virtual machine filesystems.

Type: 'help' for help on commands
      'man' to read the manual
      'quit' to quit the shell   
<fs> run
<fs> list-filesystems
/dev/vda1: ext4
/dev/system/lv_root: ext4
/dev/system/lv_swap: swap

and fsck the problematic filesystem:

<fs> fsck /dev/system/lv_root
fsck should have 2 parameter(s)
type 'help fsck' for help on fsck
<fs> fsck  ext4 /dev/system/lv_root

good luck!

share|improve this answer
+1 looks like an interesting set of tools to try out – Coops Apr 17 '12 at 13:55
Broken in debian7 for me. – sjas Jun 19 '15 at 13:55

You might be able to mount the file on the loopback interface and fsck it. From the site , use:

losetup -f
/dev/loop0 see that loop0 here is the next free device, then assign the disk image to that point.

losetup /dev/loop0 disk.raw

kpartx is used to create devices to access it.

kpartx -av /dev/loop0

Then you should be able to use fsck.

fsck.ext3 -f /dev/mapper/loop0p1
fsck.ext3 -f /dev/mapper/loop0p2

...and so on. The page is about converting systems to run on KVM, but this part cited above may put you on track to do an fsck repair; I'd add the caution that you should do this with a copy of your image file instead of the base image file, just in case something goes wrong.

share|improve this answer
This will only work on raw images, not qcow2 – dyasny Apr 17 '12 at 12:48
Long shot, the image could be converted to raw, fsck'd, then converted back. Roundabout, but could work. – Bart Silverstrim Apr 17 '12 at 12:54
might take days, if the image is large and/or is on a slow lun – dyasny Apr 17 '12 at 16:28
shrug if it works when other options's still something that could be tried. – Bart Silverstrim Apr 17 '12 at 16:44
to complete the answer: when finished with repairing, the partition mapping and loop device can be removed like this: sync; kpartx -dv /dev/loop0; losetup -d /dev/loop0 – maxschlepzig Mar 17 at 22:19

Besides what Bart Silverstrim suggested, I can see two ways:

  1. use libguestfs to mount and manipulate the images
  2. boot the VM with a liveCD ISO attached, and either reset the fsck flag or run it using the liveCD
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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