Run fsck on a XenServer Virtual Machine

Rob —  June 11, 2013 — 3 Comments

You hope that you won’t ever need to, but you may one day need to run fsck on a Linux XenServer VM that won’t boot.. no worries, attach the storage from that VM on another VM and run it from there!

Let’s set it up with VM1 and VM2, where VM1 is the one that you need to run a manual fsck on.

1. Shut down VM1 (if it’s not down already..)
2. Enter the console on the xenserver and list the VMs – grab the vm-uuid of VM2.

3. Now get the vdi-uuid of the vdi you want to access:

4. Create the vbd – it will echo the vbd-uuid after this command:

5. Now, ‘plug’ it in to VM1

You should now see a new partition in /proc/partitions

When you’re done with it, unplug the vbd:

Then you can destroy the temporary vbd:

Added 3/24/2014:
If you’re trying to run fsck on an LVM volume, then you’ll need to activate it first, otherwise you’ll get a bad superblock error.. and it won’t fsck correctly.

First, find out what the name is for your lvm’s volume group:

Next, activate it:

Next, run fsck on it, automatically fixing the errors:

When finished, deactivate it:

Related posts from Linux Brigade!

  • Install XenServer via usb flash driveInstall XenServer via usb flash drive USB Flash drives are getting cheaper and cheaper lately. I just picked up few at staples – 16GB flash drives for just under $8. I like to use them to install Linux – I always seem to […]
  • Install nrpe on XenServerInstall nrpe on XenServer If you are using nagios in your hosting environment and need to install nrpe on your XenServer servers, here’s a good way to do it.
    I’m using XenServer 6.1 (latest version).

    First, […]

  • Lock down your SSH port/accessLock down your SSH port/access The instant a Linux server is connected to a public network it starts getting hit by attackers. There are people out there running programs constantly against IP ranges and they’ve hit […]
  • Move MySQL tmp directoryMove MySQL tmp directory You’ll eventually run into a client who has a crashed table in their database – this table will be pretty large – maybe even larger than the system’s default temporary directory (usually […]
  • Download Linux – Links to 20 popular distributionsDownload Linux – Links to 20 popular distributions I always find myself telling people to just download Linux. This usually follows up with “which distribution” and i’ll recommend a couple but always end with “try a few and see which one […]

3 responses to Run fsck on a XenServer Virtual Machine

  1. Great and detailed guide, thanks! As you said I hope I won’t ever need to do this but if I do I have bookmarked this post just incase.

  2. Yes! This is another one for my server maintenance cheat sheet. Unfortunately, Murphy’s Law is a very active part of my life, so I appreciate having this resource for “just in case”. Thanks!

  3. When I do the listing, I see 2, one saying device: hda and the other devide: hdd (and vdi-uuid: Not in database). So I used the first one, and when I try to plug it, it says that expected the state of the vm to be powered on.

Leave a Reply to Jorge Cancel reply

Text formatting is available via select HTML.

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url=""> 

*