xfs Filesystem corruption using rawdisk partitions

Discussions related to using VirtualBox on Linux hosts.
Post Reply
EddieA
Posts: 4
Joined: 3. Apr 2009, 21:48
Primary OS: Linux other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Linux, Windows, Solaris

xfs Filesystem corruption using rawdisk partitions

Post by EddieA »

Let me preface this by saying I have the same issue running under VMWare, although it doesn't seem as prevalent in VirtualBox.

I'm trying to build a new "root" partition on an existing disk. I've tried a number of times now, and every time I've ended up with a corrupt filesystem. I'm trying to do it this way because I can't shut the server down in order to create the new system.

My existing disk is /dev/hda, which has the following partions: /dev/hda1 is an active xfs filesystem. /dev/hda2 is unused. /dev/hda4 is a Linux swap.

In my VM I added a hard disk, as "rawdisk" and then included "partitions 2". I also added 2 Virtual disks as well.

The following sequence nearly always results in a corrupted filesystem on /dev/hda2.

Boot the VM from a Slackware DVD image.
Install Slackware on /dev/hda2, which includes formatting /dev/hda2 as xfs.
poweroff the VM.
Run xfs_check /dev/hda2, which doesn't find any errors.
Mount /dev/hda2 on existing system, and copy 2 directory trees from /dev/hda1 to /dev/hda2.
Unmount /dev/hda2.
Run xfs_check /dev/hda2, which again doesn't find any errors.
Boot the VM, again from the Slackware DVD image, but add the kernel parameters "root=/dev/hda2 rdinit= ro".
poweroff the VM.
Run xfs_check, which now complains that there are errors on the filesystem. If the corruption hasn't happened here, it will almost certainly occur the next time I boot, and poweroff.

The partition is never mounted to the host and the VM at the same time. It is always unmounted from the host before starting the VM. The VM is always powered down before mounting the partition on the host. Both are running the same kernel version, and xfs version

Does anyone have any idea why this could be happening. I'm running VirtualBox 2.1.4.

Cheers,

Eddie
Sasquatch
Volunteer
Posts: 17798
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

Re: xfs Filesystem corruption using rawdisk partitions

Post by Sasquatch »

It shouldn't matter, but have you tried a different file system? And what did you use to create the RAW VMDK image?
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
EddieA
Posts: 4
Joined: 3. Apr 2009, 21:48
Primary OS: Linux other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Linux, Windows, Solaris

Re: xfs Filesystem corruption using rawdisk partitions

Post by EddieA »

No, I haven't tried another filesystem, as I was trying to mirror my current root filesystem. Let me try a couple of others for grins and giggles.

I tried both using a vmdk created by VMWare and also one created with "VBoxManage internalcommands createrawvmdk -filename /..path../hda2.vmdk -rawdisk /dev/hda -partitions 2".

Cheers,
Eddie
EddieA
Posts: 4
Joined: 3. Apr 2009, 21:48
Primary OS: Linux other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Linux, Windows, Solaris

Re: xfs Filesystem corruption using rawdisk partitions

Post by EddieA »

Well, reiserfs is very unhappy as well. After the 2nd re-boot, it would even finish booting any more. Modules not found, programs not executable, directories missing, etc.

Strange thing is though, fsck.reiserfs doesn't report any problems with the partition, and if I mount it on the host, everything looks good. Hmmmmm.

Cheers,
Eddie
EddieA
Posts: 4
Joined: 3. Apr 2009, 21:48
Primary OS: Linux other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Linux, Windows, Solaris

Re: xfs Filesystem corruption using rawdisk partitions

Post by EddieA »

Not sure if this is relevant, or not. I noticed that if I power down the VM, and then immediately after the power down I run an xfs_check on the host, I get this:

Code: Select all

ERROR: The filesystem has valuable metadata changes in a logwhich needs to
be replayed.  Mount the filesystem to replay the log, and unmount it before
re-running xfs_check.  If you are unable to mount the filesystem, then use
the xfs_repair -L option to destroy the log and attempt a repair.
Note that destroying the log may cause corruption -- please attempt a mount
of the filesystem before doing this.
It's only a few seconds after the VM is powered off does xfs_check come back clean. I'm guessing that this is the hard disk cache being flushed.

I still can't see how this could affect what I'm doing, because if this data wasn't flushed out, when the disk is next mounted, the log would be replayed, and the data synced up. Plus, I'm running an xfs_check between each step, and only continuing when that comes back "clean".

Or, am I missing something to do with how the buffers are written to the the disk, and how the cache works, under both a "power down" situation for the VM, and a mount/write/umount sequence on the host, as I only seen to get the corruption, in the VM, following a mount/write/umount on the host.

Cheers,
Eddie
Post Reply