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

  • Back up all of your mysql databases nightlyBack up all of your mysql databases nightly Have you ever wanted to make your own MySQL database backups?  You can use this script I wrote to make a backup of all databases, then save each one in a dated backup directory.  It will […]
  • Valve’s Steambox will help Linux gamingValve’s Steambox will help Linux gaming If you’re a gamer, then you’ve heard of the steambox. This is Valve’s answer to the xbox, ouya, etc.. offering gaming in your living room.

    They’ll be announcing something today at 10am […]

  • Globally disable directory listing on WHM/cPanelGlobally disable directory listing on WHM/cPanel One of the things that WHM/cPanel servers have on by default is directory listing. This is something you don’t want – but it’s easy to fix!

    1. Log into WHM
    2. Apache Configuration […]

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

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

*