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

  • Block Countries from your server easily with CSFBlock Countries from your server easily with CSF If you don’t have a need for certain international visitors to your Linux server, its easy to block them out!  First, you’ll need to make sure that CSF is installed.  You can follow our […]
  • Install Ubuntu / Xubuntu from USBInstall Ubuntu / Xubuntu from USB Installing via USB is much better/easier than via cd/dvd simply because it’s not going to get scratched up, you can easily carry it around with you to loan to friends, etc..

    Let’s set […]

  • Migrate CXS license from one server to anotherMigrate CXS license from one server to another When you upgrade servers, you usually like to take things you paid for with you to your new one. This will show you how.

    So you want to migrate CXS license from one server 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

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

*