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

  • Patch your WHM/cPanel machine for heartbleedPatch your WHM/cPanel machine for heartbleed You’ve certainly heard about Heartbleed by now. If not, you can read more about this vulnerability at Heartbleed.com. Continue reading this post to find out if you’re vulnerable, and how […]
  • Import MySQL database from command lineImport MySQL database from command line You’ll need to import a database via command line from time to time – I’ll normally opt for this anyway. After seeing how easy it is, you’ll probably end up using the command line instead […]
  • Send mail via the command lineSend mail via the command line During your stint as a Linux administrator, you’ll likely want to send mail from the server you are working on. Whether its sending a quick test message or emailing yourself a file, it can […]

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

*