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, […]

  • Turn off unneeded services on your Linux machineTurn off unneeded services on your Linux machine One of the easiest ways to start securing your server (and speeding it up) is to turn off unnecessary services that are usually running by default. This little script will go through and […]
  • Keep your WordPress site secure!Keep your WordPress site secure! I work for a hosting company. On average, I’ll clean up at least 3-4 WordPress sites each month for our clients. Most of the time, they’re running on old versions of WordPress and have […]
  • LFD: Excessive resource usage If you run the CSF/LFD firewall on your server then you’ve no doubt seen the emails complaining about high resource usage for various accounts. This small tutorial will show you how to […]

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 ohyesuare 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=""> 

*